annotate lisp/packages/vc.el @ 177:6075d714658b r20-3b15

Import from CVS: tag r20-3b15
author cvs
date Mon, 13 Aug 2007 09:51:16 +0200
parents 929b76928fce
children b405438285a2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; vc.el --- drive a version-control system from within Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
3 ;; Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
5 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
6 ;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de>
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
7 ;; Maintainer: (ClearCase) Rod Whitby <rwhitby@geocities.com>
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
8 ;; XEmacs conversion: Steve Baur <steve@altair.xemacs.org>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
10 ;; This file is part of GNU Emacs.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
13 ;; it under the terms of the GNU General Public License as published by
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
17 ;; GNU Emacs is distributed in the hope that it will be useful,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
20 ;; GNU General Public License for more details.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
25 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; This mode is fully documented in the Emacs user's manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; This was designed and implemented by Eric Raymond <esr@snark.thyrsus.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Paul Eggert <eggert@twinsun.com>, Sebastian Kremer <sk@thp.uni-koeln.de>,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; and Richard Stallman contributed valuable criticism, support, and testing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; CVS support was added by Per Cederqvist <ceder@lysator.liu.se>
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
35 ;; in Jan-Feb 1994. Further enhancements came from ttn.netcom.com and
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
36 ;; Andre Spiegel <spiegel@inf.fu-berlin.de>.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Supported version-control systems presently include SCCS, RCS, and CVS.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
39 ;;
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
40 ;; Some features will not work with old RCS versions. Where
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
41 ;; appropriate, VC finds out which version you have, and allows or
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
42 ;; disallows those features (stealing locks, for example, works only
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
43 ;; from 5.6.2 onwards).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; Even initial checkins will fail if your RCS version is so old that ci
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; doesn't understand -t-; this has been known to happen to people running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; NExTSTEP 3.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
48 ;; You can support the RCS -x option by adding pairs to the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
49 ;; vc-master-templates list.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; Proper function of the SCCS diff commands requires the shellscript vcdiff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; to be installed somewhere on Emacs's path for executables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; If your site uses the ChangeLog convention supported by Emacs, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; function vc-comment-to-change-log should prove a useful checkin hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; This code depends on call-process passing back the subprocess exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; status. Thus, you need Emacs 18.58 or later to run it. For the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; vc-directory command to work properly as documented, you need 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; You also need Emacs 19's ring.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; The vc code maintains some internal state in order to reduce expensive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; version-control operations to a minimum. Some names are only computed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; once. If you perform version control operations with RCS/SCCS/CVS while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; vc's back is turned, or move/rename master files while vc is running,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; vc may get seriously confused. Don't do these things!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; Developer's notes on some concurrency issues are included at the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; the file.
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
70 ;;
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
71 ;; Rudimentary ClearCase support by Rod Whitby <rwhitby@geocities.com>.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
72 ;; I (Rod Whitby) intend to maintain the rudimentary functionality that is
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
73 ;; currently in this file. At some time in the future (don't hold your
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
74 ;; breath), I intend to merge the functionality of the cc-vc package
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
75 ;; (separately available from /rtfm.mit.edu:/pub/cc-vc/) into this file.
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
76 ;; I am not the maintainer of cc-vc, nor am I the maintainer of the
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
77 ;; non-ClearCase parts of this file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (require 'vc-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (require 'ring)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
82 (eval-when-compile (require 'dired)) ; for dired-map-over-marks macro
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (if (not (assoc 'vc-parent-buffer minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 (setq minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 (cons '(vc-parent-buffer vc-parent-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
89 ;; To implement support for a new version-control system, add another
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
90 ;; branch to the vc-backend-dispatch macro and fill it in in each
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
91 ;; call. The variable vc-master-templates in vc-hooks.el will also
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
92 ;; have to change.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
93
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
94 (defmacro vc-backend-dispatch (f s r c)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
95 "Execute FORM1, FORM2 or FORM3 for SCCS, RCS or CVS respectively.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
96 If FORM3 is `RCS', use FORM2 for CVS as well as RCS.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
97 \(CVS shares some code with RCS)."
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
98 (list 'let (list (list 'type (list 'vc-backend f)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
99 (list 'cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
100 (list (list 'eq 'type (quote 'SCCS)) s) ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
101 (list (list 'eq 'type (quote 'RCS)) r) ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
102 (list (list 'eq 'type (quote 'CVS)) ;; CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
103 (if (eq c 'RCS) r c))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
104 )))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
105
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; General customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (defvar vc-suppress-confirm nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "*If non-nil, treat user as expert; suppress yes-no prompts on some things.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defvar vc-initial-comment nil
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
111 "*If non-nil, prompt for initial comment when a file is registered.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 (defvar vc-command-messages nil
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
113 "*If non-nil, display run messages from back-end commands.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
114 (defvar vc-register-switches nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
115 "*A string or list of strings specifying extra switches passed
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
116 to the register program by \\[vc-register].")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 (defvar vc-checkin-switches nil
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
118 "*A string or list of strings specifying extra switches passed
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
119 to the checkin program by \\[vc-checkin].")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (defvar vc-checkout-switches nil
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
121 "*A string or list of strings specifying extra switches passed
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
122 to the checkout program by \\[vc-checkout].")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
123 (defvar vc-directory-exclusion-list '("SCCS" "RCS" "CVS")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
124 "*A list of directory names ignored by functions that recursively
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
125 walk file trees.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (defconst vc-maximum-comment-ring-size 32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 "Maximum number of saved comments in the comment ring.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
130 ;;; This is duplicated in diff.el.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
131 ;;; XEmacs: remove
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
132 ;;(defvar diff-switches "-c"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
133 ;; "*A string or list of strings specifying switches to be be passed to diff.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
134
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
135 ;;;###autoload
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
136 (defvar vc-before-checkin-hook nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
137 "*Normal hook (list of functions) run before a file gets checked in.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
138 See `run-hooks'.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (defvar vc-checkin-hook nil
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
142 "*Normal hook (List of functions) run after a checkin is done.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
143 See `run-hooks'.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;; Header-insertion hair
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defvar vc-header-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 '((SCCS "\%W\%") (RCS "\$Id\$") (CVS "\$Id\$"))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
149 "*Header keywords to be inserted by `vc-insert-headers'.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
150 Must be a list of two-element lists, the first element of each must
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
151 be `RCS', `CVS', or `SCCS'. The second element is the string to
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
152 be inserted for this particular backend.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (defvar vc-static-header-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 '(("\\.c$" .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n#endif /* lint */\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "*Associate static header string templates with file types. A \%s in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 template is replaced with the first string associated with the file's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 version-control type in `vc-header-alist'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (defvar vc-comment-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 '((nroff-mode ".\\\"" ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 "*Special comment delimiters to be used in generating vc headers only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 Add an entry in this list if you need to override the normal comment-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 and comment-end variables. This will only be necessary if the mode language
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 is sensitive to blank lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; Default is to be extra careful for super-user.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
168 (defvar vc-checkout-carefully (= (user-uid) 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 "*Non-nil means be extra-careful in checkout.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 Verify that the file really is not locked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 and that its contents match what the master file says.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
173 (defvar vc-rcs-release nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
174 "*The release number of your RCS installation, as a string.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
175 If nil, VC itself computes this value when it is first needed.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
176
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
177 (defvar vc-sccs-release nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
178 "*The release number of your SCCS installation, as a string.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
179 If nil, VC itself computes this value when it is first needed.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
180
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
181 (defvar vc-cvs-release nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
182 "*The release number of your CVS installation, as a string.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
183 If nil, VC itself computes this value when it is first needed.")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
184
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; Variables the user doesn't need to know about.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (defvar vc-log-entry-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defvar vc-log-operation nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (defvar vc-log-after-operation-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defvar vc-checkout-writable-buffer-hook 'vc-checkout-writable-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; In a log entry buffer, this is a local variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; that points to the buffer for which it was made
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; (either a file, or a VC dired buffer).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defvar vc-parent-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 (defvar vc-parent-buffer-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (defvar vc-log-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 (defvar vc-log-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (defconst vc-name-assoc-file "VC-names")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defvar vc-dired-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (make-variable-buffer-local 'vc-dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
204 (defvar vc-comment-ring (make-ring vc-maximum-comment-ring-size))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (defvar vc-comment-ring-index nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defvar vc-last-comment-match nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
208 ;; Back-portability to Emacs 18
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
209
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
210 (defun file-executable-p-18 (f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
211 (let ((modes (file-modes f)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
212 (and modes (not (zerop (logand 292))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
213
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
214 (defun file-regular-p-18 (f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
215 (let ((attributes (file-attributes f)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
216 (and attributes (not (car attributes)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
217
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
218 ; Conditionally rebind some things for Emacs 18 compatibility
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
219 (if (not (boundp 'minor-mode-map-alist))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
220 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
221 (setq compilation-old-error-list nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
222 (fset 'file-executable-p 'file-executable-p-18)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
223 (fset 'shrink-window-if-larger-than-buffer 'beginning-of-buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
224 ))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
225
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
226 (if (not (fboundp 'file-regular-p))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
227 (fset 'file-regular-p 'file-regular-p-18))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
228
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
229 ;;; Find and compare backend releases
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
230
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
231 (defun vc-backend-release (backend)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
232 ;; Returns which backend release is installed on this system.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
233 (cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
234 ((eq backend 'RCS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
235 (or vc-rcs-release
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
236 (and (zerop (vc-do-command nil nil "rcs" nil nil "-V"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
237 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
238 (set-buffer (get-buffer "*vc*"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
239 (setq vc-rcs-release
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
240 (car (vc-parse-buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
241 '(("^RCS version \\([0-9.]+ *.*\\)" 1)))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
242 (setq vc-rcs-release 'unknown)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
243 ((eq backend 'CVS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
244 (or vc-cvs-release
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
245 (and (zerop (vc-do-command nil 1 "cvs" nil nil "-v"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
246 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
247 (set-buffer (get-buffer "*vc*"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
248 (setq vc-cvs-release
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
249 (car (vc-parse-buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
250 '(("^Concurrent Versions System (CVS) \\([0-9.]+\\)"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
251 1)))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
252 (setq vc-cvs-release 'unknown)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
253 ((eq backend 'SCCS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
254 vc-sccs-release)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
256 (defun vc-release-greater-or-equal (r1 r2)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
257 ;; Compare release numbers, represented as strings.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
258 ;; Release components are assumed cardinal numbers, not decimal
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
259 ;; fractions (5.10 is a higher release than 5.9). Omitted fields
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
260 ;; are considered lower (5.6.7 is earlier than 5.6.7.1).
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
261 ;; Comparison runs till the end of the string is found, or a
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
262 ;; non-numeric component shows up (5.6.7 is earlier than "5.6.7 beta",
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
263 ;; which is probably not what you want in some cases).
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
264 ;; This code is suitable for existing RCS release numbers.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
265 ;; CVS releases are handled reasonably, too (1.3 < 1.4* < 1.5).
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
266 (let (v1 v2 i1 i2)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
267 (catch 'done
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
268 (or (and (string-match "^\\.?\\([0-9]+\\)" r1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
269 (setq i1 (match-end 0))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
270 (setq v1 (string-to-number (match-string 1 r1)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
271 (or (and (string-match "^\\.?\\([0-9]+\\)" r2)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
272 (setq i2 (match-end 0))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
273 (setq v2 (string-to-number (match-string 1 r2)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
274 (if (> v1 v2) (throw 'done t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
275 (if (< v1 v2) (throw 'done nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
276 (throw 'done
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
277 (vc-release-greater-or-equal
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
278 (substring r1 i1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
279 (substring r2 i2)))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
280 (throw 'done t)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
281 (or (and (string-match "^\\.?\\([0-9]+\\)" r2)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
282 (throw 'done nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
283 (throw 'done t)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
284
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
285 (defun vc-backend-release-p (backend release)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
286 ;; Return t if we have RELEASE of BACKEND or better
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
287 (let (i r (ri 0) (ii 0) is rs (installation (vc-backend-release backend)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
288 (if (not (eq installation 'unknown))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
289 (cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
290 ((or (eq backend 'RCS) (eq backend 'CVS))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
291 (vc-release-greater-or-equal installation release))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
292
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
293 ;;; functions that operate on RCS revision numbers
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
294
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
295 (defun vc-trunk-p (rev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
296 ;; return t if REV is a revision on the trunk
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
297 (not (eq nil (string-match "\\`[0-9]+\\.[0-9]+\\'" rev))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
298
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
299 (defun vc-branch-part (rev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
300 ;; return the branch part of a revision number REV
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
301 (substring rev 0 (string-match "\\.[0-9]+\\'" rev)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
302
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
303 ;; File property caching
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (defun vc-clear-context ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 "Clear all cached file properties and the comment ring."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (fillarray vc-file-prop-obarray nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;; Note: there is potential for minor lossage here if there is an open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; log buffer with a nonzero local value of vc-comment-ring-index.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
311 (setq vc-comment-ring (make-ring vc-maximum-comment-ring-size)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
312
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
313 (defun vc-file-clear-masterprops (file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
314 ;; clear all properties of FILE that were retrieved
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
315 ;; from the master file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
316 (vc-file-setprop file 'vc-latest-version nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
317 (vc-file-setprop file 'vc-your-latest-version nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
318 (vc-backend-dispatch file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
319 (progn ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
320 (vc-file-setprop file 'vc-master-locks nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
321 (progn ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
322 (vc-file-setprop file 'vc-default-branch nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
323 (vc-file-setprop file 'vc-head-version nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
324 (vc-file-setprop file 'vc-master-workfile-version nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
325 (vc-file-setprop file 'vc-master-locks nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
326 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
327 (vc-file-setprop file 'vc-cvs-status nil))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
328
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
329 (defun vc-head-version (file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
330 ;; Return the RCS head version of FILE
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
331 (cond ((vc-file-getprop file 'vc-head-version))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
332 (t (vc-fetch-master-properties file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
333 (vc-file-getprop file 'vc-head-version))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; Random helper functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
337 (defun vc-latest-on-branch-p (file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
338 ;; return t iff the current workfile version of FILE is
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
339 ;; the latest on its branch.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
340 (vc-backend-dispatch file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
341 ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
342 (string= (vc-workfile-version file) (vc-latest-version file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
343 ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
344 (let ((workfile-version (vc-workfile-version file)) tip-version)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
345 (if (vc-trunk-p workfile-version)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
346 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
347 ;; Re-fetch the head version number. This is to make
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
348 ;; sure that no-one has checked in a new version behind
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
349 ;; our back.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
350 (vc-fetch-master-properties file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
351 (string= (vc-file-getprop file 'vc-head-version)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
352 workfile-version))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
353 ;; If we are not on the trunk, we need to examine the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
354 ;; whole current branch. (vc-master-workfile-version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
355 ;; is not what we need.)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
356 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
357 (set-buffer (get-buffer-create "*vc-info*"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
358 (vc-insert-file (vc-name file) "^desc")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
359 (setq tip-version (car (vc-parse-buffer (list (list
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
360 (concat "^\\(" (regexp-quote (vc-branch-part workfile-version))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
361 "\\.[0-9]+\\)\ndate[ \t]+\\([0-9.]+\\);") 1 2)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
362 (if (get-buffer "*vc-info*")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
363 (kill-buffer (get-buffer "*vc-info*")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
364 (string= tip-version workfile-version))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
365 ;; CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
366 t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
367
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (defun vc-registration-error (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (error "File %s is not under version control" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (error "Buffer %s is not associated with a file" (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (defvar vc-binary-assoc nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
375 ;; XEmacs: Function referred to in vc-hooks.el
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
376 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (defun vc-find-binary (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 "Look for a command anywhere on the subprocess-command search path."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (or (cdr (assoc name vc-binary-assoc))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
380 (catch 'found
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
381 (mapcar
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
382 (function
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
383 (lambda (s)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
384 (if s
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
385 (let ((full (concat s "/" name)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
386 (if (file-executable-p full)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
387 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
388 (setq vc-binary-assoc
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
389 (cons (cons name full) vc-binary-assoc))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
390 (throw 'found full)))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
391 exec-path)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
392 nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
394 (defun vc-do-command (buffer okstatus command file last &rest flags)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "Execute a version-control command, notifying user and checking for errors.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
396 Output from COMMAND goes to BUFFER, or *vc* if BUFFER is nil.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 The command is successful if its exit status does not exceed OKSTATUS.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
398 (If OKSTATUS is nil, that means to ignore errors.)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
399 The last argument of the command is the master name of FILE if LAST is
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
400 `MASTER', or the workfile of FILE if LAST is `WORKFILE'; this is appended
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
401 to an optional list of FLAGS."
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
402 (and file (setq file (expand-file-name file)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
403 (if (not buffer) (setq buffer "*vc*"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
404 (if vc-command-messages
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
405 (message "Running %s on %s..." command file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
406 (let ((obuf (current-buffer)) (camefrom (current-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (squeezed nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (vc-file (and file (vc-name file)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
409 (olddir default-directory)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 status)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
411 (set-buffer (get-buffer-create buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (set (make-local-variable 'vc-parent-buffer) camefrom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (set (make-local-variable 'vc-parent-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (concat " from " (buffer-name camefrom)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
415 (setq default-directory olddir)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (function (lambda (s) (and s (setq squeezed (append squeezed (list s))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (if (and vc-file (eq last 'MASTER))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (setq squeezed (append squeezed (list vc-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if (eq last 'WORKFILE)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
425 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
426 (let* ((pwd (expand-file-name default-directory))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
427 (preflen (length pwd)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
428 (if (string= (substring file 0 preflen) pwd)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
429 (setq file (substring file preflen))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
430 (setq squeezed (append squeezed (list file)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
431 (let ((exec-path (append vc-path exec-path))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 ;; Add vc-path to PATH for the execution of this command.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
433 (process-environment
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
434 (cons (concat "PATH=" (getenv "PATH")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
435 path-separator
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
436 (mapconcat 'identity vc-path path-separator))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
437 process-environment))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
438 (w32-quote-process-args t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq status (apply 'call-process command nil t nil squeezed)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (goto-char (point-max))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
441 (set-buffer-modified-p nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (forward-line -1)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
443 (if (or (not (integerp status)) (and okstatus (< okstatus status)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (progn
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
445 (pop-to-buffer buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (shrink-window-if-larger-than-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (error "Running %s...FAILED (%s)" command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (if (integerp status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (format "status %d" status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 status))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (if vc-command-messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (message "Running %s...OK" command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 )
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
456 (set-buffer obuf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 ;;; Save a bit of the text around POSN in the current buffer, to help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 ;;; us find the corresponding position again later. This works even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 ;;; if all markers are destroyed or corrupted.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
463 ;;; A lot of this was shamelessly lifted from Sebastian Kremer's rcs.el mode.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (defun vc-position-context (posn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (list posn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (buffer-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 (buffer-substring posn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (min (point-max) (+ posn 100)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;;; Return the position of CONTEXT in the current buffer, or nil if we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;;; couldn't find it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (defun vc-find-position-by-context (context)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (let ((context-string (nth 2 context)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (if (equal "" context-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (let ((diff (- (nth 1 context) (buffer-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (if (< diff 0) (setq diff (- diff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (goto-char (nth 0 context))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (if (or (search-forward context-string nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 ;; Can't use search-backward since the match may continue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 ;; after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (progn (goto-char (- (point) diff (length context-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 ;; goto-char doesn't signal an error at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 ;; beginning of buffer like backward-char would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (search-forward context-string nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;; to beginning of OSTRING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (- (point) (length context-string))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
490 (defun vc-buffer-context ()
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
491 ;; Return a list '(point-context mark-context reparse); from which
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
492 ;; vc-restore-buffer-context can later restore the context.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (let ((point-context (vc-position-context (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ;; Use mark-marker to avoid confusion in transient-mark-mode.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
495 (mark-context (if (eq (marker-buffer (mark-marker #+xemacs t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
496 (current-buffer))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
497 (vc-position-context (mark-marker #+xemacs t))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
498 ;; Make the right thing happen in transient-mark-mode.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
499 (mark-active nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; We may want to reparse the compilation buffer after revert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (reparse (and (boundp 'compilation-error-list) ;compile loaded
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
502 (let ((curbuf (current-buffer)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
503 ;; Construct a list; each elt is nil or a buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
504 ;; iff that buffer is a compilation output buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
505 ;; that contains markers into the current buffer.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
506 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
507 (mapcar (function
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
508 (lambda (buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
509 (set-buffer buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
510 (let ((errors (or
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
511 compilation-old-error-list
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
512 compilation-error-list))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
513 (buffer-error-marked-p nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
514 (while (and (consp errors)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
515 (not buffer-error-marked-p))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
516 (and (markerp (cdr (car errors)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
517 (eq buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
518 (marker-buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
519 (cdr (car errors))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
520 (setq buffer-error-marked-p t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
521 (setq errors (cdr errors)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
522 (if buffer-error-marked-p buffer))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
523 (buffer-list)))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
524 (list point-context mark-context reparse)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
526 (defun vc-restore-buffer-context (context)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
527 ;; Restore point/mark, and reparse any affected compilation buffers.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
528 ;; CONTEXT is that which vc-buffer-context returns.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
529 (let ((point-context (nth 0 context))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
530 (mark-context (nth 1 context))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
531 (reparse (nth 2 context)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;; Reparse affected compilation buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (while reparse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (if (car reparse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (set-buffer (car reparse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (let ((compilation-last-buffer (current-buffer)) ;select buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 ;; Record the position in the compilation buffer of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; the last error next-error went to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (error-pos (marker-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (car (car-safe compilation-error-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ;; Reparse the error messages as far as they were parsed before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (compile-reinitialize-errors '(4) compilation-parsing-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;; Move the pointer up to find the error we were at before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ;; reparsing. Now next-error should properly go to the next one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (while (and compilation-error-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (/= error-pos (car (car compilation-error-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (setq compilation-error-list (cdr compilation-error-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (setq reparse (cdr reparse)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 ;; Restore point and mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (let ((new-point (vc-find-position-by-context point-context)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (if new-point (goto-char new-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (if mark-context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (let ((new-mark (vc-find-position-by-context mark-context)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (if new-mark (set-mark new-mark))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
558 (defun vc-revert-buffer1 (&optional arg no-confirm)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
559 ;; Revert buffer, try to keep point and mark where user expects them in spite
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
560 ;; of changes because of expanded version-control key words.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
561 ;; This is quite important since otherwise typeahead won't work as expected.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
562 (interactive "P")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
563 (widen)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
564 (let ((context (vc-buffer-context)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
565 ;; t means don't call normal-mode; that's to preserve various minor modes.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
566 (revert-buffer arg no-confirm t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
567 (vc-restore-buffer-context context)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
568
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defun vc-buffer-sync (&optional not-urgent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 ;; Make sure the current buffer and its working file are in sync
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 ;; NOT-URGENT means it is ok to continue if the user says not to save.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (if (or vc-suppress-confirm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (if not-urgent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (error "Aborted")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (defun vc-workfile-unchanged-p (file &optional want-differences-if-changed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 ;; Has the given workfile changed since last checkout?
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
584 (let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
585 (lastmod (nth 5 (file-attributes file))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
586 (or (equal checkout-time lastmod)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
587 (and (or (not checkout-time) want-differences-if-changed)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
588 (let ((unchanged (zerop (vc-backend-diff file nil nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
589 (not want-differences-if-changed)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
590 ;; 0 stands for an unknown time; it can't match any mod time.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
591 (vc-file-setprop file 'vc-checkout-time (if unchanged lastmod 0))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
592 unchanged)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (defun vc-next-action-on-file (file verbose &optional comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;;; If comment is specified, it will be used as an admin or checkin comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (let ((vc-file (vc-name file))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
597 (vc-type (vc-backend file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
598 owner version buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 ;; if there is no master file corresponding, create one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ((not vc-file)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
603 (vc-register verbose comment)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
604 (if vc-initial-comment
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
605 (setq vc-log-after-operation-hook
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
606 'vc-checkout-writable-buffer-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (vc-checkout-writable-buffer file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
609 ;; CVS: changes to the master file need to be
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
610 ;; merged back into the working file
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 ((and (eq vc-type 'CVS)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
612 (or (eq (vc-cvs-status file) 'needs-checkout)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
613 (eq (vc-cvs-status file) 'needs-merge)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
614 (if (or vc-dired-mode
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
615 (yes-or-no-p
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
616 (format "%s is not up-to-date. Merge in changes now? "
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
617 (buffer-name))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (progn
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
619 (if vc-dired-mode
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
620 (and (setq buffer (get-file-buffer file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
621 (buffer-modified-p buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
622 (switch-to-buffer-other-window buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
623 (vc-buffer-sync t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
624 (setq buffer (current-buffer))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
625 (vc-buffer-sync t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
626 (if (and buffer (buffer-modified-p buffer)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (not (yes-or-no-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 "Buffer %s modified; merge file on disc anyhow? "
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
630 (buffer-name buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (error "Merge aborted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (if (not (zerop (vc-backend-merge-news file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 ;; Overlaps detected - what now? Should use some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 ;; fancy RCS conflict resolving package, or maybe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 ;; emerge, but for now, simply warn the user with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;; message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (message "Conflicts detected!"))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
638 (and buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
639 (vc-resynch-buffer file t (not (buffer-modified-p buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (error "%s needs update" (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
642 ;; If there is no lock on the file, assert one and get it.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
643 ;; (With implicit checkout, make sure not to lose unsaved changes.)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
644 ((progn (and (eq (vc-checkout-model file) 'implicit)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
645 (buffer-modified-p buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
646 (vc-buffer-sync))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
647 (not (setq owner (vc-locking-user file))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
648 (if (and vc-checkout-carefully
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
649 (not (vc-workfile-unchanged-p file t)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
650 (if (save-window-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
651 (pop-to-buffer "*vc-diff*")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
652 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
653 (insert-string (format "Changes to %s since last lock:\n\n"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
654 file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
655 (not (beep))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
656 (yes-or-no-p
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
657 (concat "File has unlocked changes, "
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
658 "claim lock retaining changes? ")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
659 (progn (vc-backend-steal file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
660 (vc-mode-line file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
661 (if (not (yes-or-no-p "Revert to checked-in version, instead? "))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
662 (error "Checkout aborted")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
663 (vc-revert-buffer1 t t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
664 (vc-checkout-writable-buffer file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
665 )
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
666 (if verbose
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
667 (if (not (eq vc-type 'SCCS))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
668 (vc-checkout file nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
669 (read-string "Branch or version to move to: "))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
670 (error "Sorry, this is not implemented for SCCS"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
671 (if (vc-latest-on-branch-p file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
672 (vc-checkout-writable-buffer file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
673 (if (yes-or-no-p
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
674 "This is not the latest version. Really lock it? ")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
675 (vc-checkout-writable-buffer file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
676 (if (yes-or-no-p "Lock the latest version instead? ")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
677 (vc-checkout-writable-buffer file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
678 (if (vc-trunk-p (vc-workfile-version file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
679 "" ;; this means check out latest on trunk
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
680 (vc-branch-part (vc-workfile-version file)))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
681 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
683 ;; a checked-out version exists, but the user may not own the lock
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
684 ((and (not (eq vc-type 'CVS))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
685 (not (string-equal owner (vc-user-login-name))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
686 (if comment
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
687 (error "Sorry, you can't steal the lock on %s this way" file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
688 (and (eq vc-type 'RCS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
689 (not (vc-backend-release-p 'RCS "5.6.2"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
690 (error "File is locked by %s" owner))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
691 (vc-steal-lock
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
692 file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
693 (if verbose (read-string "Version to steal: ")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
694 (vc-workfile-version file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
695 owner))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
696
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
697 ;; OK, user owns the lock on the file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
698 (t
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
699 (if vc-dired-mode
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
700 (find-file-other-window file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
701 (find-file file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
703 ;; give luser a chance to save before checking in.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
704 (vc-buffer-sync)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
706 ;; Revert if file is unchanged and buffer is too.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
707 ;; If buffer is modified, that means the user just said no
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
708 ;; to saving it; in that case, don't revert,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
709 ;; because the user might intend to save
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
710 ;; after finishing the log entry.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
711 (if (and (vc-workfile-unchanged-p file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
712 (not (buffer-modified-p)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
713 ;; DO NOT revert the file without asking the user!
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
714 (cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
715 ((yes-or-no-p "Revert to master version? ")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
716 (vc-backend-revert file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
717 (vc-resynch-window file t t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
719 ;; user may want to set nonstandard parameters
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
720 (if verbose
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
721 (setq version (read-string "New version level: ")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
722
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
723 ;; OK, let's do the checkin
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
724 (vc-checkin file version comment)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
725 )))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (defun vc-next-action-dired (file rev comment)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
728 ;; Do a vc-next-action-on-file on all the marked files, possibly
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
729 ;; passing on the log comment we've just entered.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
730 (let ((configuration (current-window-configuration))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
731 (dired-buffer (current-buffer))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
732 (dired-dir default-directory))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
733 (dired-map-over-marks
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
734 (let ((file (dired-get-filename)) p
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
735 (default-directory default-directory))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (message "Processing %s..." file)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
737 ;; Adjust the default directory so that checkouts
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
738 ;; go to the right place.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
739 (setq default-directory (file-name-directory file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (vc-next-action-on-file file nil comment)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
741 (set-buffer dired-buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
742 (setq default-directory dired-dir)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
743 (vc-dired-update-line file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
744 (set-window-configuration configuration)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
745 (message "Processing %s...done" file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
746 nil t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 ;; Here's the major entry point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (defun vc-next-action (verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 "Do the next logical checkin or checkout operation on the current file.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
753 If you call this from within a VC dired buffer with no files marked,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
754 it will operate on the file in the current line.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
755 If you call this from within a VC dired buffer, and one or more
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
756 files are marked, it will accept a log message and then operate on
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
757 each one. The log message will be used as a comment for any register
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
758 or checkin operations, but ignored when doing checkouts. Attempted
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
759 lock steals will raise an error.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
760 A prefix argument lets you specify the version number to use.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 For RCS and SCCS files:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 If the file is not already registered, this registers it for version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 control and then retrieves a writable, locked copy for editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 If the file is registered and not locked by anyone, this checks out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 a writable and locked file ready for editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 If the file is checked out and locked by the calling user, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 first checks to see if the file has changed since checkout. If not,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 it performs a revert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 If the file has been changed, this pops up a buffer for entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 of a log message; when the message has been entered, it checks in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 resulting changes along with the log message as change commentary. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 the variable `vc-keep-workfiles' is non-nil (which is its default), a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 read-only copy of the changed file is left in place afterwards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 If the file is registered and locked by someone else, you are given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 the option to steal the lock.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 For CVS files:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 If the file is not already registered, this registers it for version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 control. This does a \"cvs add\", but no \"cvs commit\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 If the file is added but not committed, it is committed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 If your working file is changed, but the repository file is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 unchanged, this pops up a buffer for entry of a log message; when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 message has been entered, it checks in the resulting changes along
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 with the logmessage as change commentary. A writable file is retained.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 If the repository file is changed, you are asked if you want to
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
787 merge in the changes into your working copy."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 (catch 'nogo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (let ((files (dired-get-marked-files)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
793 (if (string= ""
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
794 (mapconcat
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
795 (function (lambda (f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
796 (if (eq (vc-backend f) 'CVS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
797 (if (or (eq (vc-cvs-status f) 'locally-modified)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
798 (eq (vc-cvs-status f) 'locally-added))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
799 "@" "")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
800 (if (vc-locking-user f) "@" ""))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
801 files ""))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
802 (vc-next-action-dired nil nil "dummy")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
803 (vc-start-entry nil nil nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
804 "Enter a change comment for the marked files."
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
805 'vc-next-action-dired))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
806 (throw 'nogo nil)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (pop-to-buffer vc-parent-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (vc-next-action-on-file buffer-file-name verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (vc-registration-error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ;;; These functions help the vc-next-action entry point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
815 (defun vc-checkout-writable-buffer (&optional file rev)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 "Retrieve a writable copy of the latest version of the current buffer's file."
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
817 (vc-checkout (or file (buffer-file-name)) t rev)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (defun vc-register (&optional override comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 "Register the current file into your version-control system."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (interactive "P")
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
824 (or buffer-file-name
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
825 (error "No visited file"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (let ((master (vc-name buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (and master (file-exists-p master)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (error "This file is already registered"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (and master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (not (y-or-n-p "Previous master file has vanished. Make a new one? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (error "This file is already registered")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; Watch out for new buffers of size 0: the corresponding file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 ;; does not exist yet, even though buffer-modified-p is nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (if (and (not (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (not (file-exists-p buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (set-buffer-modified-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (vc-buffer-sync)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
839 (cond ((not vc-make-backup-files)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
840 ;; inhibit backup for this buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
841 (make-local-variable 'backup-inhibited)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
842 (setq backup-inhibited t)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (vc-admin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (and override
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (format "Initial version level for %s: " buffer-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 (defun vc-resynch-window (file &optional keep noquery)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;; If the given file is in the current buffer,
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
852 ;; either revert on it so we see expanded keywords,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ;; or unvisit it (depending on vc-keep-workfiles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ;; NOQUERY if non-nil inhibits confirmation for reverting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;; NOQUERY should be t *only* if it is known the only difference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ;; between the buffer and the file is due to RCS rather than user editing!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (and (string= buffer-file-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (if keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (progn
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
860 ;; temporarily remove vc-find-file-hook, so that
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
861 ;; we don't lose the properties
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
862 (remove-hook 'find-file-hooks 'vc-find-file-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (vc-revert-buffer1 t noquery)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
864 (add-hook 'find-file-hooks 'vc-find-file-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (vc-mode-line buffer-file-name))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
866 (kill-buffer (current-buffer)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
868 (defun vc-resynch-buffer (file &optional keep noquery)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
869 ;; if FILE is currently visited, resynch its buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
870 (let ((buffer (get-file-buffer file)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
871 (if buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
872 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
873 (set-buffer buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
874 (vc-resynch-window file keep noquery)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
875
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
876 (defun vc-start-entry (file rev comment msg action &optional after-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ;; Accept a comment for an operation on FILE revision REV. If COMMENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ;; is nil, pop up a VC-log buffer, emit MSG, and set the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ;; action on close to ACTION; otherwise, do action immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ;; Remember the file's buffer in vc-parent-buffer (current one if no file).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ;; AFTER-HOOK specifies the local value for vc-log-operation-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (let ((parent (if file (find-file-noselect file) (current-buffer))))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
883 (if vc-before-checkin-hook
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
884 (if file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
885 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
886 (set-buffer parent)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
887 (run-hooks 'vc-before-checkin-hook))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
888 (run-hooks 'vc-before-checkin-hook)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (if comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (set-buffer (get-buffer-create "*VC-log*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (pop-to-buffer (get-buffer-create "*VC-log*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (set (make-local-variable 'vc-parent-buffer) parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (set (make-local-variable 'vc-parent-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (concat " from " (buffer-name vc-parent-buffer)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
895 (if file (vc-mode-line file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
896 (vc-log-mode file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (make-local-variable 'vc-log-after-operation-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (if after-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (setq vc-log-after-operation-hook after-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (setq vc-log-operation action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (setq vc-log-version rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (if comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (if (eq comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (vc-finish-logentry t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (insert comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 (vc-finish-logentry nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (message "%s Type C-c C-c when done." msg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (defun vc-admin (file rev &optional comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 "Check a file into your version-control system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 FILE is the unmodified name of the file. REV should be the base version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 level to check it in under. COMMENT, if specified, is the checkin comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (vc-start-entry file rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (or comment (not vc-initial-comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 "Enter initial comment." 'vc-backend-admin
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
918 nil))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
920 ;; XEmacs: Function referred to in vc-hooks.el.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
921 ;;;###autoload
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
922 (defun vc-checkout (file &optional writable rev)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 "Retrieve a copy of the latest version of the given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ;; If ftp is on this system and the name matches the ange-ftp format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 ;; for a remote file, the user is trying something that won't work.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
926 (if (and (string-match "^/[^/:]+:" file) (vc-find-binary "ftp"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
927 (error "Sorry, you can't check out files over FTP"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
928 (vc-backend-checkout file writable rev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
929 (vc-resynch-buffer file t t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (defun vc-steal-lock (file rev &optional owner)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 "Steal the lock on the current workfile."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (let (file-description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (if (not owner)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (setq owner (vc-locking-user file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (if rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (setq file-description (format "%s:%s" file rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (setq file-description file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (if (not (y-or-n-p (format "Take the lock on %s from %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 file-description owner)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (error "Steal cancelled"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (pop-to-buffer (get-buffer-create "*VC-mail*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (setq default-directory (expand-file-name "~/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (auto-save-mode auto-save-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (mail-setup owner (format "Stolen lock on %s" file-description) nil nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (list (list 'vc-finish-steal file rev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (format "I stole the lock on %s, " file-description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (current-time-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 ".\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (message "Please explain why you stole the lock. Type C-c C-c when done.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;; This is called when the notification has been sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (defun vc-finish-steal (file version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (vc-backend-steal file version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (if (get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (set-buffer (get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (vc-resynch-window file t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (defun vc-checkin (file &optional rev comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 "Check in the file specified by FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 The optional argument REV may be a string specifying the new version level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 \(if nil increment the current level). The file is either retained with write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 permissions zeroed, or deleted (according to the value of `vc-keep-workfiles').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 If the back-end is CVS, a writable workfile is always kept.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 COMMENT is a comment string; if omitted, a buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 popped up to accept a comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (vc-start-entry file rev comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 "Enter a change comment." 'vc-backend-checkin
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
974 'vc-checkin-hook))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;;; Here is a checkin hook that may prove useful to sites using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 ;;; ChangeLog facility supported by Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (defun vc-comment-to-change-log (&optional whoami file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 "Enter last VC comment into change log file for current buffer's file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 Optional arg (interactive prefix) non-nil means prompt for user name and site.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 Second arg is file name of change log. \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 If nil, uses `change-log-default-name'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (interactive (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (list current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (prompt-for-change-log-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 ;; Make sure the defvar for add-log-current-defun-function has been executed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ;; before binding it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (require 'add-log)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
989 (let (;; Extract the comment first so we get any error before doing anything.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (comment (ring-ref vc-comment-ring 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 ;; Don't let add-change-log-entry insert a defun name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (add-log-current-defun-function 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 ;; Call add-log to do half the work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (add-change-log-entry whoami file-name t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 ;; Insert the VC comment, leaving point before it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (setq end (save-excursion (insert comment) (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (if (looking-at "\\s *\\s(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ;; It starts with an open-paren, as in "(foo): Frobbed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ;; So remove the ": " add-log inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (delete-char -2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ;; Canonicalize the white space between the file name and comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (just-one-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 ;; Indent rest of the text the same way add-log indented the first line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 (let ((indentation (current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 (while (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (indent-to indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (setq end (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 ;; Fill the inserted text, preserving open-parens at bol.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1012 (let ((paragraph-separate (concat paragraph-separate "\\|\\s *\\s("))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1013 (paragraph-start (concat paragraph-start "\\|\\s *\\s(")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (fill-region (point) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 ;; Canonicalize the white space at the end of the entry so it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 ;; separated from the next entry by a single blank line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (skip-syntax-forward " " end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (delete-char (- (skip-syntax-backward " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (or (eobp) (looking-at "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (insert "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (defun vc-finish-logentry (&optional nocomment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 "Complete the operation implied by the current log entry."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 ;; Check and record the comment, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (if (not nocomment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 ;; Comment too long?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (vc-backend-logentry-check vc-log-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ;; Record the comment in the comment ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (ring-insert vc-comment-ring (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 ;; Sync parent buffer in case the user modified it while editing the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 ;; But not if it is a vc-dired buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 (set-buffer vc-parent-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (or vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (vc-buffer-sync)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1044 (if (not vc-log-operation) (error "No log operation is pending"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1045 ;; save the parameters held in buffer-local variables
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1046 (let ((log-operation vc-log-operation)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1047 (log-file vc-log-file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1048 (log-version vc-log-version)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1049 (log-entry (buffer-string))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1050 (after-hook vc-log-after-operation-hook))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 ;; Return to "parent" buffer of this checkin and remove checkin window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 (pop-to-buffer vc-parent-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (let ((logbuf (get-buffer "*VC-log*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (delete-windows-on logbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (kill-buffer logbuf))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1056 ;; OK, do it to it
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1057 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1058 (funcall log-operation
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1059 log-file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1060 log-version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1061 log-entry))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 ;; Now make sure we see the expanded headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (vc-resynch-window buffer-file-name vc-keep-workfiles t))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1065 (run-hooks after-hook 'vc-finish-logentry-hook)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 ;; Code for access to the comment ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (defun vc-previous-comment (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 "Cycle backwards through comment history."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (interactive "*p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (let ((len (ring-length vc-comment-ring)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1073 (cond ((<= len 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 (message "Empty comment ring")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (ding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 ;; Initialize the index on the first use of this command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 ;; so that the first M-p gets index 0, and the first M-n gets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 ;; index -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (if (null vc-comment-ring-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 (setq vc-comment-ring-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (if (> arg 0) -1
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1084 (if (< arg 0) 1 0))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (setq vc-comment-ring-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 (mod (+ vc-comment-ring-index arg) len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (message "%d" (1+ vc-comment-ring-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (insert (ring-ref vc-comment-ring vc-comment-ring-index))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (defun vc-next-comment (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 "Cycle forwards through comment history."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 (interactive "*p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (vc-previous-comment (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (defun vc-comment-search-reverse (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 "Searches backwards through comment history for substring match."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 (interactive "sComment substring: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 (if (string= str "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (setq str vc-last-comment-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 (setq vc-last-comment-match str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 (if (null vc-comment-ring-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 (setq vc-comment-ring-index -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (let ((str (regexp-quote str))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1104 (len (ring-length vc-comment-ring))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (n (1+ vc-comment-ring-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (while (and (< n len) (not (string-match str (ring-ref vc-comment-ring n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (setq n (+ n 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (cond ((< n len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (vc-previous-comment (- n vc-comment-ring-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (t (error "Not found")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (defun vc-comment-search-forward (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 "Searches forwards through comment history for substring match."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 (interactive "sComment substring: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 (if (string= str "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (setq str vc-last-comment-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 (setq vc-last-comment-match str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (if (null vc-comment-ring-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (setq vc-comment-ring-index 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (let ((str (regexp-quote str))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1121 (len (ring-length vc-comment-ring))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (n vc-comment-ring-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (while (and (>= n 0) (not (string-match str (ring-ref vc-comment-ring n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (setq n (- n 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (cond ((>= n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (vc-next-comment (- n vc-comment-ring-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (t (error "Not found")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 ;; Additional entry points for examining version histories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (defun vc-diff (historic &optional not-urgent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 "Display diffs between file versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 Normally this compares the current file and buffer with the most recent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 checked in version of that file. This uses no arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 With a prefix argument, it reads the file name to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 and two version designators specifying which versions to compare."
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1138 (interactive (list current-prefix-arg t))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (set-buffer (find-file-noselect (dired-get-filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (while vc-parent-buffer
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1142 (pop-to-buffer vc-parent-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 (if historic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (call-interactively 'vc-version-diff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 (if (or (null buffer-file-name) (null (vc-name buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 "There is no version-control master associated with this buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (let ((file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 unchanged)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (or (and file (vc-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (vc-registration-error file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (vc-buffer-sync not-urgent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (setq unchanged (vc-workfile-unchanged-p buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (if unchanged
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1155 (message "No changes to %s since latest version" file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (vc-backend-diff file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 ;; Ideally, we'd like at this point to parse the diff so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 ;; the buffer effectively goes into compilation mode and we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 ;; can visit the old and new change locations via next-error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 ;; Unfortunately, this is just too painful to do. The basic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 ;; problem is that the `old' file doesn't exist to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 ;; visited. This plays hell with numerous assumptions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 ;; the diff.el and compile.el machinery.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1164 (set-buffer "*vc-diff*")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (setq default-directory (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (if (= 0 (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (setq unchanged t)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1169 (message "No changes to %s since latest version" file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1170 (pop-to-buffer "*vc-diff*")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (shrink-window-if-larger-than-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (not unchanged))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 171
diff changeset
1175 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (defun vc-version-diff (file rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 "For FILE, report diffs between two stored versions REL1 and REL2 of it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 If FILE is a directory, generate diffs between versions for all registered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 files in or below it."
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1180 (interactive "FFile or directory to diff: \nsOlder version: \nsNewer version: ")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (if (string-equal rel1 "") (setq rel1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (if (string-equal rel2 "") (setq rel2 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (if (file-directory-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (let ((camefrom (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (set-buffer (get-buffer-create "*vc-status*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (set (make-local-variable 'vc-parent-buffer) camefrom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (set (make-local-variable 'vc-parent-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (concat " from " (buffer-name camefrom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (insert "Diffs between "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (or rel1 "last version checked in")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 " and "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (or rel2 "current workfile(s)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ":\n\n")
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1195 (set-buffer (get-buffer-create "*vc-diff*"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (cd file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (vc-file-tree-walk
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1198 default-directory
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (function (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (message "Looking at %s" f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (not (file-directory-p f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (vc-registered f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 (vc-backend-diff f rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (append-to-buffer "*vc-status*" (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (pop-to-buffer "*vc-status*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 (insert "\nEnd of diffs.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (if (zerop (vc-backend-diff file rel1 rel2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (message "No changes to %s between %s and %s." file rel1 rel2)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1214 (pop-to-buffer "*vc-diff*"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 (defun vc-version-other-window (rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 "Visit version REV of the current buffer in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 If the current buffer is named `F', the version is named `F.~REV~'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 If `F.~REV~' already exists, it is used instead of being re-created."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (interactive "sVersion to visit (default is latest version): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (set-buffer (find-file-noselect (dired-get-filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (while vc-parent-buffer
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1225 (pop-to-buffer vc-parent-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (if (and buffer-file-name (vc-name buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (let* ((version (if (string-equal rev "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 (vc-latest-version buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (filename (concat buffer-file-name ".~" version "~")))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1231 (or (file-exists-p filename)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1232 (vc-backend-checkout buffer-file-name nil version filename))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1233 (find-file-other-window filename))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (vc-registration-error buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 ;; Header-insertion code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (defun vc-insert-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 "Insert headers in a file for use with your version-control system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 Headers desired are inserted at the start of the buffer, and are pulled from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 the variable `vc-header-alist'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (find-file-other-window (dired-get-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (while vc-parent-buffer
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1247 (pop-to-buffer vc-parent-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (if (or (not (vc-check-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (y-or-n-p "Version headers already exist. Insert another set? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (let* ((delims (cdr (assq major-mode vc-comment-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (comment-start-vc (or (car delims) comment-start "#"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (comment-end-vc (or (car (cdr delims)) comment-end ""))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1257 (hdstrings (cdr (assoc (vc-backend (buffer-file-name)) vc-header-alist))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1258 (mapcar (function (lambda (s)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1259 (insert comment-start-vc "\t" s "\t"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1260 comment-end-vc "\n")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 hdstrings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (if vc-static-header-alist
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1263 (mapcar (function (lambda (f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1264 (if (string-match (car f) buffer-file-name)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1265 (insert (format (cdr f) (car hdstrings))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 vc-static-header-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1270 (defun vc-clear-headers ()
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1271 ;; Clear all version headers in the current buffer, i.e. reset them
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1272 ;; to the nonexpanded form. Only implemented for RCS, yet.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1273 ;; Don't lose point and mark during this.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1274 (let ((context (vc-buffer-context)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1275 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1276 (while (re-search-forward "\\$\\([A-Za-z]+\\): [^\\$]+\\$" nil t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1277 (replace-match "$\\1$"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1278 (vc-restore-buffer-context context)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1279
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1280 ;; The VC directory major mode. Coopt Dired for this.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 ;; All VC commands get mapped into logical equivalents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1283 (define-derived-mode vc-dired-mode dired-mode "Dired under VC"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1284 "The major mode used in VC directory buffers. It is derived from Dired.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 All Dired commands operate normally. Users currently locking listed files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 are listed in place of the file's owner and group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 Keystrokes bound to VC commands will execute as though they had been called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 on a buffer attached to the file named in the current Dired buffer line."
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1289 (setq vc-dired-mode t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1290
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1291 (define-key vc-dired-mode-map "\C-xv" vc-prefix-map)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1292 (define-key vc-dired-mode-map "g" 'vc-dired-update)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1293 (define-key vc-dired-mode-map "=" 'vc-diff)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1294
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1295 (defun vc-dired-state-info (file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1296 ;; Return the string that indicates the version control status
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1297 ;; on a VC dired line.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1298 (let ((cvs-state (and (eq (vc-backend file) 'CVS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1299 (vc-cvs-status file))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1300 (if cvs-state
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1301 (cond ((eq cvs-state 'up-to-date) nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1302 ((eq cvs-state 'needs-checkout) "patch")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1303 ((eq cvs-state 'locally-modified) "modified")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1304 ((eq cvs-state 'needs-merge) "merge")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1305 ((eq cvs-state 'unresolved-conflict) "conflict")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1306 ((eq cvs-state 'locally-added) "added"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1307 (vc-locking-user file))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 (defun vc-dired-reformat-line (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 ;; Hack a directory-listing line, plugging in locking-user info in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 ;; place of the user and group info. Should have the beneficial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 ;; side-effect of shortening the listing line. Each call starts with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 ;; point immediately following the dired mark area on the line to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 ;; hacked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 ;; Simplest possible one:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 ;; (insert (concat x "\t")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 ;; This code, like dired, assumes UNIX -l format.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1320 (let ((pos (point)) limit perm owner date-and-file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1321 (end-of-line)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1322 (setq limit (point))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1323 (goto-char pos)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1324 (cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1325 ((or
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1326 (re-search-forward ;; owner and group
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1327 "\\([drwxlts-]+ \\) *[0-9]+ \\([^ ]+\\) +[^ ]+ +[0-9]+\\( [^ 0-9]+ [0-9 ][0-9] .*\\)"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1328 limit t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1329 (re-search-forward ;; only owner displayed
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1330 "\\([drwxlts-]+ \\) *[0-9]+ \\([^ ]+\\) +[0-9]+\\( [^ 0-9]+ [0-9 ][0-9] .*\\)"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1331 limit t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1332 (setq perm (match-string 1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1333 owner (match-string 2)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1334 date-and-file (match-string 3)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1335 ((re-search-forward ;; OS/2 -l format, no links, owner, group
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1336 "\\([drwxlts-]+ \\) *[0-9]+\\( [^ 0-9]+ [0-9 ][0-9] .*\\)"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1337 limit t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1338 (setq perm (match-string 1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1339 date-and-file (match-string 2))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1340 (if x (setq x (concat "(" x ")")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1341 (let ((rep (substring (concat x " ") 0 10)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1342 (replace-match (concat perm rep date-and-file)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1343
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1344 (defun vc-dired-update-line (file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1345 ;; Update the vc-dired listing line of file -- it is assumed
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1346 ;; that point is already on this line. Don't use dired-do-redisplay
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1347 ;; for this, because it cannot handle the way vc-dired deals with
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1348 ;; subdirectories.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1349 (beginning-of-line)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1350 (forward-char 2)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1351 (let ((start (point)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1352 (forward-line 1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1353 (beginning-of-line)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1354 (delete-region start (point))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1355 (insert-directory file dired-listing-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1356 (forward-line -1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1357 (end-of-line)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1358 (delete-char (- (length file)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1359 (insert (substring file (length (expand-file-name default-directory))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1360 (goto-char start))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1361 (vc-dired-reformat-line (vc-dired-state-info file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1363 (defun vc-dired-update (verbose)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1364 (interactive "P")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1365 (vc-directory default-directory verbose))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1366
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1367 ;;; Note in Emacs 18 the following defun gets overridden
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1368 ;;; with the symbol 'vc-directory-18. See below.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 ;;;###autoload
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1370 (defun vc-directory (dirname verbose)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1371 "Show version-control status of the current directory and subdirectories.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1372 Normally it creates a Dired buffer that lists only the locked files
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1373 in all these directories. With a prefix argument, it lists all files."
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1374 (interactive "DDired under VC (directory): \nP")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1375 (require 'dired)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1376 (setq dirname (expand-file-name dirname))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1377 ;; force a trailing slash
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1378 (if (not (eq (elt dirname (1- (length dirname))) ?/))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1379 (setq dirname (concat dirname "/")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1380 (let (nonempty
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1381 (dl (if (featurep 'xemacs)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 151
diff changeset
1382 (+ 1 (length (directory-file-name (expand-file-name dirname))))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1383 (length dirname)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1384 (filelist nil) (statelist nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1385 (old-dir default-directory)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1386 dired-buf
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1387 dired-buf-mod-count)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1388 (vc-file-tree-walk
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1389 dirname
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1390 (function
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1391 (lambda (f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1392 (if (vc-registered f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1393 (let ((state (vc-dired-state-info f)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1394 (and (or verbose state)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1395 (setq filelist (cons (substring f dl) filelist))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1396 (setq statelist (cons state statelist))))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1397 (save-window-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1398 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1399 ;; This uses a semi-documented feature of dired; giving a switch
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1400 ;; argument forces the buffer to refresh each time.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1401 (setq dired-buf
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1402 (dired-internal-noselect
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1403 (cons dirname (nreverse filelist))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1404 dired-listing-switches 'vc-dired-mode))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1405 (setq nonempty (not (eq 0 (length filelist))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1406 (switch-to-buffer dired-buf)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1407 ;; Make a few modifications to the header
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1408 (setq buffer-read-only nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1409 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1410 (forward-line 1) ;; Skip header line
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1411 (let ((start (point))) ;; Erase (but don't remove) the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1412 (end-of-line) ;; "wildcard" line.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1413 (delete-region start (point)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1414 (beginning-of-line)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (if nonempty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (progn
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1417 ;; Plug the version information into the individual lines
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (lambda (x)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1421 (forward-char 2) ;; skip dired's mark area
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1422 (vc-dired-reformat-line x)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1423 (forward-line 1))) ;; go to next line
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1424 (nreverse statelist))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1425 (if (featurep 'xemacs)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1426 (dired-insert-set-properties (point-min) (point-max)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (goto-char (point-min))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1429 (dired-next-line 2)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 )
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1431 (dired-next-line 1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1432 (insert " ")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1433 (setq buffer-read-only t)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (message "No files are currently %s under %s"
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1435 (if verbose "registered" "locked") dirname))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1438 ;; Emacs 18 version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1439 (defun vc-directory-18 (verbose)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1440 "Show version-control status of all files under the current directory."
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1441 (interactive "P")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1442 (let (nonempty (dir default-directory))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1443 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1444 (set-buffer (get-buffer-create "*vc-status*"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1445 (erase-buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1446 (cd dir)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1447 (vc-file-tree-walk
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1448 default-directory
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1449 (function (lambda (f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1450 (if (vc-registered f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1451 (let ((user (vc-locking-user f)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1452 (if (or user verbose)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1453 (insert (format
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1454 "%s %s\n"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1455 (concat user) f))))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1456 (setq nonempty (not (zerop (buffer-size)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1457
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1458 (if nonempty
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1459 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1460 (pop-to-buffer "*vc-status*" t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1461 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1462 (shrink-window-if-larger-than-buffer)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1463 (message "No files are currently %s under %s"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1464 (if verbose "registered" "locked") default-directory))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1465 )
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1466
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1467 (or (boundp 'minor-mode-map-alist)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1468 (fset 'vc-directory 'vc-directory-18))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 ;; Named-configuration support for SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (defun vc-add-triple (name file rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (save-excursion
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1474 (find-file (expand-file-name
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1475 vc-name-assoc-file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1476 (file-name-as-directory
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1477 (expand-file-name (vc-backend-subdirectory-name file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1478 (file-name-directory file)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (insert name "\t:\t" file "\t" rev "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (basic-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (defun vc-record-rename (file newname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (save-excursion
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1487 (find-file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1488 (expand-file-name
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1489 vc-name-assoc-file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1490 (file-name-as-directory
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1491 (expand-file-name (vc-backend-subdirectory-name file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1492 (file-name-directory file)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 ;; (replace-regexp (concat ":" (regexp-quote file) "$") (concat ":" newname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 (while (re-search-forward (concat ":" (regexp-quote file) "$") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (replace-match (concat ":" newname) nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (basic-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (defun vc-lookup-triple (file name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 ;; Return the numeric version corresponding to a named snapshot of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 ;; If name is nil or a version number string it's just passed through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (cond ((null name) name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 ((let ((firstchar (aref name 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (and (>= firstchar ?0) (<= firstchar ?9)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (t
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1509 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1510 (set-buffer (get-buffer-create "*vc-info*"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1511 (vc-insert-file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1512 (expand-file-name
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1513 vc-name-assoc-file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1514 (file-name-as-directory
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1515 (expand-file-name (vc-backend-subdirectory-name file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1516 (file-name-directory file)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1517 (prog1
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1518 (car (vc-parse-buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1519 (list (list (concat name "\t:\t" file "\t\\(.+\\)") 1))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1520 (kill-buffer "*vc-info*"))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1521 ))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 ;; Named-configuration entry points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1525 (defun vc-snapshot-precondition ()
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1526 ;; Scan the tree below the current directory.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1527 ;; If any files are locked, return the name of the first such file.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1528 ;; (This means, neither snapshot creation nor retrieval is allowed.)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1529 ;; If one or more of the files are currently visited, return `visited'.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1530 ;; Otherwise, return nil.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1531 (let ((status nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1532 (catch 'vc-locked-example
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1533 (vc-file-tree-walk
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1534 default-directory
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1535 (function (lambda (f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1536 (and (vc-registered f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1537 (if (vc-locking-user f) (throw 'vc-locked-example f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1538 (if (get-file-buffer f) (setq status 'visited)))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1539 status)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (defun vc-create-snapshot (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 "Make a snapshot called NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 The snapshot is made from all registered files at or below the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 directory. For each file, the version level of its latest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 version becomes part of the named configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (interactive "sNew snapshot name: ")
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1548 (let ((result (vc-snapshot-precondition)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1549 (if (stringp result)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1550 (error "File %s is locked" result)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 (vc-file-tree-walk
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1552 default-directory
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (function (lambda (f) (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (vc-name f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 (vc-backend-assign-name f name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (defun vc-retrieve-snapshot (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 "Retrieve the snapshot called NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 This function fails if any files are locked at or below the current directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 Otherwise, all registered files are checked out (unlocked) at their version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 levels in the snapshot."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (interactive "sSnapshot name to retrieve: ")
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1565 (let ((result (vc-snapshot-precondition))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1566 (update nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1567 (if (stringp result)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1568 (error "File %s is locked" result)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1569 (if (eq result 'visited)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1570 (setq update (yes-or-no-p "Update the affected buffers? ")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (vc-file-tree-walk
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1572 default-directory
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (function (lambda (f) (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (vc-name f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (vc-error-occurred
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1576 (vc-backend-checkout f nil name)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1577 (if update (vc-resynch-buffer f t t)))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 ;; Miscellaneous other entry points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (defun vc-print-log ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 "List the change log of the current buffer in a window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (set-buffer (find-file-noselect (dired-get-filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (while vc-parent-buffer
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1589 (pop-to-buffer vc-parent-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (if (and buffer-file-name (vc-name buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (let ((file buffer-file-name))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1592 (vc-backend-print-log file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (pop-to-buffer (get-buffer-create "*vc*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (setq default-directory (file-name-directory file))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1595 (goto-char (point-max)) (forward-line -1)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 (while (looking-at "=*\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (delete-char (- (match-end 0) (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (if (looking-at "[\b\t\n\v\f\r ]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (delete-char (- (match-end 0) (match-beginning 0))))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1602 (shrink-window-if-larger-than-buffer)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1603 ;; move point to the log entry for the current version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1604 (and (not (eq (vc-backend file) 'SCCS))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1605 (re-search-forward
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1606 ;; also match some context, for safety
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1607 (concat "----\nrevision " (vc-workfile-version file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1608 "\\(\tlocked by:.*\n\\|\n\\)date: ") nil t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1609 ;; set the display window so that
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1610 ;; the whole log entry is displayed
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1611 (let (start end lines)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1612 (beginning-of-line) (forward-line -1) (setq start (point))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1613 (if (not (re-search-forward "^----*\nrevision" nil t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1614 (setq end (point-max))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1615 (beginning-of-line) (forward-line -1) (setq end (point)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1616 (setq lines (count-lines start end))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1617 (cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1618 ;; if the global information and this log entry fit
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1619 ;; into the window, display from the beginning
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1620 ((< (count-lines (point-min) end) (window-height))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1621 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1622 (recenter 0)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1623 (goto-char start))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1624 ;; if the whole entry fits into the window,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1625 ;; display it centered
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1626 ((< (1+ lines) (window-height))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1627 (goto-char start)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1628 (recenter (1- (- (/ (window-height) 2) (/ lines 2)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1629 ;; otherwise (the entry is too large for the window),
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1630 ;; display from the start
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1631 (t
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1632 (goto-char start)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1633 (recenter 0)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 )
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1635 (vc-registration-error buffer-file-name)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1636 )
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1637 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (defun vc-revert-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 "Revert the current buffer's file back to the latest checked-in version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 This asks for confirmation if the buffer contents are not identical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 to that version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 If the back-end is CVS, this will give you the most recent revision of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 the file on the branch you are editing."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (find-file-other-window (dired-get-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (while vc-parent-buffer
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1650 (pop-to-buffer vc-parent-buffer))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (let ((file buffer-file-name)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1652 ;; This operation should always ask for confirmation.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1653 (vc-suppress-confirm nil)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (obuf (current-buffer)) (changed (vc-diff nil t)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1655 (if (and changed (not (yes-or-no-p "Discard changes? ")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (progn
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1657 (if (and (window-dedicated-p (selected-window))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1658 (one-window-p t 'selected-frame))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1659 (make-frame-invisible (selected-frame))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1660 (delete-window))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (error "Revert cancelled"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (set-buffer obuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (if changed
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1664 (if (and (window-dedicated-p (selected-window))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1665 (one-window-p t 'selected-frame))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1666 (make-frame-invisible (selected-frame))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1667 (delete-window)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (vc-backend-revert file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (vc-resynch-window file t t)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1670 )
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1671 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (defun vc-cancel-version (norevert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 "Get rid of most recently checked in version of this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 A prefix argument means do not revert the buffer afterwards."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (find-file-other-window (dired-get-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (pop-to-buffer vc-parent-buffer))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1682 (cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1683 ((not (vc-registered (buffer-file-name)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1684 (vc-registration-error (buffer-file-name)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1685 ((eq (vc-backend (buffer-file-name)) 'CVS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1686 (error "Unchecking files under CVS is dangerous and not supported in VC"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1687 ((vc-locking-user (buffer-file-name))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1688 (error "This version is locked; use vc-revert-buffer to discard changes"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1689 ((not (vc-latest-on-branch-p (buffer-file-name)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1690 (error "This is not the latest version--VC cannot cancel it")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1691 (let* ((target (vc-workfile-version (buffer-file-name)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1692 (recent (if (vc-trunk-p target) "" (vc-branch-part target)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1693 (config (current-window-configuration)) done)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1694 (if (null (yes-or-no-p (format "Remove version %s from master? " target)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 nil
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1696 (setq norevert (or norevert (not
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1697 (yes-or-no-p "Revert buffer to most recent remaining version? "))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (vc-backend-uncheck (buffer-file-name) target)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1699 ;; Check out the most recent remaining version. If it fails, because
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1700 ;; the whole branch got deleted, do a double-take and check out the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1701 ;; version where the branch started.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1702 (while (not done)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1703 (condition-case err
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1704 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1705 (if norevert
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1706 ;; Check out locked, but only to disc, and keep
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1707 ;; modifications in the buffer.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1708 (vc-backend-checkout (buffer-file-name) t recent)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1709 ;; Check out unlocked, and revert buffer.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1710 (vc-checkout (buffer-file-name) nil recent))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1711 (setq done t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1712 ;; If the checkout fails, vc-do-command signals an error.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1713 ;; We catch this error, check the reason, correct the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1714 ;; version number, and try a second time.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1715 (error (set-buffer "*vc*")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1716 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1717 (if (search-forward "no side branches present for" nil t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1718 (progn (setq recent (vc-branch-part recent))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1719 ;; vc-do-command popped up a window with
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1720 ;; the error message. Get rid of it, by
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1721 ;; restoring the old window configuration.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1722 (set-window-configuration config))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1723 ;; No, it was some other error: re-signal it.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1724 (signal (car err) (cdr err))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1725 ;; If norevert, clear version headers and mark the buffer modified.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1726 (if norevert
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1727 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1728 (set-visited-file-name (buffer-file-name))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1729 (if (not vc-make-backup-files)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1730 ;; inhibit backup for this buffer
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1731 (progn (make-local-variable 'backup-inhibited)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1732 (setq backup-inhibited t)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1733 (if (eq (vc-backend (buffer-file-name)) 'RCS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1734 (progn (setq buffer-read-only nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1735 (vc-clear-headers)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1736 (vc-mode-line (buffer-file-name))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1737 (message "Version %s has been removed from the master" target)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1738 )))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 (defun vc-rename-file (old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 "Rename file OLD to NEW, and rename its master file likewise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (interactive "fVC rename file: \nFRename to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 ;; There are several ways of renaming files under CVS 1.3, but they all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ;; have serious disadvantages. See the FAQ (available from think.com in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ;; pub/cvs/). I'd rather send the user an error, than do something he might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ;; consider to be wrong. When the famous, long-awaited rename database is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 ;; implemented things might change for the better. This is unlikely to occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 ;; until CVS 2.0 is released. --ceder 1994-01-23 21:27:51
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1750 (if (eq (vc-backend old) 'CVS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1751 (error "Renaming files under CVS is dangerous and not supported in VC"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 (let ((oldbuf (get-file-buffer old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 (if (and oldbuf (buffer-modified-p oldbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 (error "Please save files before moving them"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (if (get-file-buffer new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (error "Already editing new file name"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (if (file-exists-p new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (error "New file already exists"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (let ((oldmaster (vc-name old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (if oldmaster
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 (progn
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1762 (if (vc-locking-user old)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 (error "Please check in files before moving them"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 (if (or (file-symlink-p oldmaster)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 ;; This had FILE, I changed it to OLD. -- rms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (file-symlink-p (vc-backend-subdirectory-name old)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1767 (error "This is not a safe thing to do in the presence of symbolic links"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (rename-file
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1769 oldmaster
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1770 (let ((backend (vc-backend old))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (newdir (or (file-name-directory new) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (newbase (file-name-nondirectory new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (catch 'found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (mapcar
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1775 (function
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (if (eq backend (cdr s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (let* ((newmaster (format (car s) newdir newbase))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (newmasterdir (file-name-directory newmaster)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 (if (or (not newmasterdir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (file-directory-p newmasterdir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (throw 'found newmaster))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 vc-master-templates)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 (error "New file lacks a version control directory"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 (if (or (not oldmaster) (file-exists-p old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 (rename-file old new)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1787 ; ?? Renaming a file might change its contents due to keyword expansion.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1788 ; We should really check out a new copy if the old copy was precisely equal
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1789 ; to some checked in version. However, testing for this is tricky....
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (if oldbuf
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1791 (save-excursion
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (set-buffer oldbuf)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1793 (let ((buffer-read-only buffer-read-only))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1794 (set-visited-file-name new))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1795 (vc-backend new)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1796 (vc-mode-line new)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 (set-buffer-modified-p nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 ;; This had FILE, I changed it to OLD. -- rms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 (vc-backend-dispatch old
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1800 (vc-record-rename old new) ;SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1801 nil ;RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1802 nil ;CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1803 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 ;;;###autoload
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1807 (defun vc-update-change-log (&rest args)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1808 "Find change log file and add entries from recent RCS/CVS logs.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1809 Normally, find log entries for all registered files in the default
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1810 directory using `rcs2log', which finds CVS logs preferentially.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1811 The mark is left at the end of the text prepended to the change log.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1812
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1813 With prefix arg of C-u, only find log entries for the current buffer's file.
74
54cc21c15cbb Import from CVS: tag r20-0b32
cvs
parents: 70
diff changeset
1814
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1815 With any numeric prefix arg, find log entries for all currently visited
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1816 files that are under version control. This puts all the entries in the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1817 log for the default directory, which may not be appropriate.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1818
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1819 From a program, any arguments are assumed to be filenames and are
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1820 passed to the `rcs2log' script after massaging to be relative to the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1821 default directory."
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 (cond ((consp current-prefix-arg) ;C-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 (list buffer-file-name))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1825 (current-prefix-arg ;Numeric argument.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 (let ((files nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (buffers (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (setq file (buffer-file-name (car buffers)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1831 (and file (vc-backend file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1832 (setq files (cons file files)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 (setq buffers (cdr buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 (t
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1836 ;; `rcs2log' will find the relevant RCS or CVS files
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1837 ;; relative to the curent directory if none supplied.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1838 nil)))
171
929b76928fce Import from CVS: tag r20-3b12
cvs
parents: 153
diff changeset
1839 (require 'add-log) ; XEmacs change
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1840 (let ((odefault default-directory)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1841 (full-name (or add-log-full-name
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1842 (user-full-name)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1843 (user-login-name)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1844 (format "uid%d" (number-to-string (user-uid)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1845 (mailing-address (or add-log-mailing-address
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1846 user-mail-address)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (find-file-other-window (find-change-log))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 (barf-if-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (vc-buffer-sync)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (message "Computing change log entries...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 (message "Computing change log entries... %s"
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1855 (if (eq 0 (apply 'call-process "rcs2log" nil '(t nil) nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1856 "-u"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1857 (concat (vc-user-login-name)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1858 "\t"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1859 full-name
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1860 "\t"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1861 mailing-address)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1862 (mapcar (function
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1863 (lambda (f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1864 (file-relative-name
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1865 (if (file-name-absolute-p f)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1866 f
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1867 (concat odefault f)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1868 args)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 "done" "failed"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1871 ;; Collect back-end-dependent stuff here
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 (defun vc-backend-admin (file &optional rev comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 ;; Register a file into the version-control system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 ;; Automatically retrieves a read-only version of the file with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 ;; keywords expanded if vc-keep-workfiles is non-nil, otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 ;; it deletes the workfile.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (vc-file-clearprops file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (or vc-default-back-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (setq vc-default-back-end (if (vc-find-binary "rcs") 'RCS 'SCCS)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (message "Registering %s..." file)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1882 (let ((switches
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1883 (if (stringp vc-register-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1884 (list vc-register-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1885 vc-register-switches))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1886 (backend
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1887 (cond
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 ((file-exists-p (vc-backend-subdirectory-name)) vc-default-back-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 ((file-exists-p "RCS") 'RCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 ((file-exists-p "SCCS") 'SCCS)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1891 ((file-exists-p "CVS") 'CVS)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 (t vc-default-back-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 (cond ((eq backend 'SCCS)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1894 (apply 'vc-do-command nil 0 "admin" file 'MASTER ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1895 (and rev (concat "-r" rev))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1896 "-fb"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1897 (concat "-i" file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1898 (and comment (concat "-y" comment))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1899 (format
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1900 (car (rassq 'SCCS vc-master-templates))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1901 (or (file-name-directory file) "")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1902 (file-name-nondirectory file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1903 switches)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 (delete-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 (if vc-keep-workfiles
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1906 (vc-do-command nil 0 "get" file 'MASTER)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 ((eq backend 'RCS)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1908 (apply 'vc-do-command nil 0 "ci" file 'WORKFILE ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1909 ;; if available, use the secure registering option
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1910 (and (vc-backend-release-p 'RCS "5.6.4") "-i")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1911 (concat (if vc-keep-workfiles "-u" "-r") rev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1912 (and comment (concat "-t-" comment))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1913 switches))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1914 ((eq backend 'CVS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1915 (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE ;; CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1916 "add"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1917 (and comment (string-match "[^\t\n ]" comment)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1918 (concat "-m" comment))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1919 switches)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (message "Registering %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 (defun vc-backend-checkout (file &optional writable rev workfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 ;; Retrieve a copy of a saved version into a workfile
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1926 (let ((filename (or workfile file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1927 (file-buffer (get-file-buffer file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1928 switches)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929 (message "Checking out %s..." filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (save-excursion
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1931 ;; Change buffers to get local value of vc-checkout-switches.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1932 (if file-buffer (set-buffer file-buffer))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1933 (setq switches (if (stringp vc-checkout-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1934 (list vc-checkout-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1935 vc-checkout-switches))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1936 ;; Save this buffer's default-directory
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1937 ;; and use save-excursion to make sure it is restored
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1938 ;; in the same buffer it was saved in.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1939 (let ((default-directory default-directory))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1940 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1941 ;; Adjust the default-directory so that the check-out creates
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1942 ;; the file in the right place.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1943 (setq default-directory (file-name-directory filename))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1944 (vc-backend-dispatch file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1945 (progn ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1946 (and rev (string= rev "") (setq rev nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1947 (if workfile
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1948 ;; Some SCCS implementations allow checking out directly to a
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1949 ;; file using the -G option, but then some don't so use the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1950 ;; least common denominator approach and use the -p option
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1951 ;; ala RCS.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1952 (let ((vc-modes (logior (file-modes (vc-name file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1953 (if writable 128 0)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1954 (failed t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1955 (unwind-protect
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1956 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1957 (apply 'vc-do-command
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1958 nil 0 "/bin/sh" file 'MASTER "-c"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1959 ;; Some shells make the "" dummy argument into $0
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1960 ;; while others use the shell's name as $0 and
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1961 ;; use the "" as $1. The if-statement
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1962 ;; converts the latter case to the former.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1963 (format "if [ x\"$1\" = x ]; then shift; fi; \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1964 umask %o; exec >\"$1\" || exit; \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1965 shift; umask %o; exec get \"$@\""
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1966 (logand 511 (lognot vc-modes))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1967 (logand 511 (lognot (default-file-modes))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1968 "" ; dummy argument for shell's $0
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1969 filename
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1970 (if writable "-e")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1971 "-p"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1972 (and rev
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1973 (concat "-r" (vc-lookup-triple file rev)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1974 switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1975 (setq failed nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1976 (and failed (file-exists-p filename)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1977 (delete-file filename))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1978 (apply 'vc-do-command nil 0 "get" file 'MASTER ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1979 (if writable "-e")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1980 (and rev (concat "-r" (vc-lookup-triple file rev)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1981 switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1982 (vc-file-setprop file 'vc-workfile-version nil)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1983 (if workfile ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1984 ;; RCS doesn't let us check out into arbitrary file names directly.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1985 ;; Use `co -p' and make stdout point to the correct file.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1986 (let ((vc-modes (logior (file-modes (vc-name file))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1987 (if writable 128 0)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1988 (failed t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1989 (unwind-protect
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1990 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1991 (apply 'vc-do-command
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1992 nil 0 "/bin/sh" file 'MASTER "-c"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1993 ;; See the SCCS case, above, regarding the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1994 ;; if-statement.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1995 (format "if [ x\"$1\" = x ]; then shift; fi; \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1996 umask %o; exec >\"$1\" || exit; \
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1997 shift; umask %o; exec co \"$@\""
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1998 (logand 511 (lognot vc-modes))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
1999 (logand 511 (lognot (default-file-modes))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2000 "" ; dummy argument for shell's $0
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2001 filename
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2002 (if writable "-l")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2003 (concat "-p" rev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2004 switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2005 (setq failed nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2006 (and failed (file-exists-p filename) (delete-file filename))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2007 (let (new-version)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2008 ;; if we should go to the head of the trunk,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2009 ;; clear the default branch first
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2010 (and rev (string= rev "")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2011 (vc-do-command nil 0 "rcs" file 'MASTER "-b"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2012 ;; now do the checkout
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2013 (apply 'vc-do-command
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2014 nil 0 "co" file 'MASTER
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2015 ;; If locking is not strict, force to overwrite
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2016 ;; the writable workfile.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2017 (if (eq (vc-checkout-model file) 'implicit) "-f")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2018 (if writable "-l")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2019 (if rev (concat "-r" rev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2020 ;; if no explicit revision was specified,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2021 ;; check out that of the working file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2022 (let ((workrev (vc-workfile-version file)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2023 (if workrev (concat "-r" workrev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2024 nil)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2025 switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2026 ;; determine the new workfile version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2027 (save-excursion
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2028 (set-buffer "*vc*")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2029 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2030 (setq new-version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2031 (if (re-search-forward "^revision \\([0-9.]+\\).*\n" nil t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2032 (buffer-substring (match-beginning 1) (match-end 1)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2033 (vc-file-setprop file 'vc-workfile-version new-version)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2034 ;; if necessary, adjust the default branch
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2035 (and rev (not (string= rev ""))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2036 (vc-do-command nil 0 "rcs" file 'MASTER
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2037 (concat "-b" (if (vc-latest-on-branch-p file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2038 (if (vc-trunk-p new-version) nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2039 (vc-branch-part new-version))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2040 new-version))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2041 (if workfile ;; CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2042 ;; CVS is much like RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2043 (let ((failed t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2044 (unwind-protect
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2045 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2046 (apply 'vc-do-command
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2047 nil 0 "/bin/sh" file 'WORKFILE "-c"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2048 "exec >\"$1\" || exit; shift; exec cvs update \"$@\""
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2049 "" ; dummy argument for shell's $0
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2050 workfile
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2051 (concat "-r" rev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2052 "-p"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2053 switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2054 (setq failed nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2055 (and failed (file-exists-p filename) (delete-file filename))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2056 ;; default for verbose checkout: clear the sticky tag
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2057 ;; so that the actual update will get the head of the trunk
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2058 (and rev (string= rev "")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2059 (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2060 ;; If a revision was specified, check that out.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2061 (if rev
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2062 (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2063 (and writable (eq (vc-checkout-model file) 'manual) "-w")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2064 "update"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2065 (and rev (not (string= rev ""))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2066 (concat "-r" rev))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2067 switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2068 ;; If no revision was specified, simply make the file writable.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2069 (and writable
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2070 (or (eq (vc-checkout-model file) 'manual)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2071 (zerop (logand 128 (file-modes file))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2072 (set-file-modes file (logior 128 (file-modes file)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2073 (if rev (vc-file-setprop file 'vc-workfile-version nil))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2074 (cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2075 ((not workfile)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2076 (vc-file-clear-masterprops file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2077 (if writable
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2078 (vc-file-setprop file 'vc-locking-user (vc-user-login-name)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2079 (vc-file-setprop file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2080 'vc-checkout-time (nth 5 (file-attributes file)))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2081 (message "Checking out %s...done" filename))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (defun vc-backend-logentry-check (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (vc-backend-dispatch file
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2085 (if (>= (buffer-size) 512) ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2086 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2087 (goto-char 512)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2088 (error
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2089 "Log must be less than 512 characters; point is now at pos 512")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2090 nil ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2091 nil) ;; CVS
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (defun vc-backend-checkin (file rev comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 ;; Register changes to FILE as level REV with explanatory COMMENT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 ;; Automatically retrieves a read-only version of the file with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 ;; keywords expanded if vc-keep-workfiles is non-nil, otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 ;; it deletes the workfile.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2099 ;; Adaptation for RCS branch support: if this is an explicit checkin,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2100 ;; or if the checkin creates a new branch, set the master file branch
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2101 ;; accordingly.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (message "Checking in %s..." file)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2103 ;; "This log message intentionally left almost blank".
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2104 ;; RCS 5.7 gripes about white-space-only comments too.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2105 (or (and comment (string-match "[^\t\n ]" comment))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2106 (setq comment "*** empty log message ***"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 ;; Change buffers to get local value of vc-checkin-switches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (set-buffer (or (get-file-buffer file) (current-buffer)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2110 (let ((switches
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2111 (if (stringp vc-checkin-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2112 (list vc-checkin-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2113 vc-checkin-switches)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2114 ;; Clear the master-properties. Do that here, not at the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2115 ;; end, because if the check-in fails we want them to get
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2116 ;; re-computed before the next try.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2117 (vc-file-clear-masterprops file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2118 (vc-backend-dispatch file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2119 ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2120 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2121 (apply 'vc-do-command nil 0 "delta" file 'MASTER
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2122 (if rev (concat "-r" rev))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2123 (concat "-y" comment)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2124 switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2125 (vc-file-setprop file 'vc-locking-user 'none)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2126 (vc-file-setprop file 'vc-workfile-version nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2127 (if vc-keep-workfiles
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2128 (vc-do-command nil 0 "get" file 'MASTER))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2129 )
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2130 ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2131 (let ((old-version (vc-workfile-version file)) new-version)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2132 (apply 'vc-do-command nil 0 "ci" file 'MASTER
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2133 ;; if available, use the secure check-in option
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2134 (and (vc-backend-release-p 'RCS "5.6.4") "-j")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2135 (concat (if vc-keep-workfiles "-u" "-r") rev)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2136 (concat "-m" comment)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2137 switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2138 (vc-file-setprop file 'vc-locking-user 'none)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2139 (vc-file-setprop file 'vc-workfile-version nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2140
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2141 ;; determine the new workfile version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2142 (set-buffer "*vc*")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2143 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2144 (if (or (re-search-forward
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2145 "new revision: \\([0-9.]+\\);" nil t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2146 (re-search-forward
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2147 "reverting to previous revision \\([0-9.]+\\)" nil t))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2148 (progn (setq new-version (buffer-substring (match-beginning 1)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2149 (match-end 1)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2150 (vc-file-setprop file 'vc-workfile-version new-version)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2152 ;; if we got to a different branch, adjust the default
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2153 ;; branch accordingly
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2154 (cond
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2155 ((and old-version new-version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2156 (not (string= (vc-branch-part old-version)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2157 (vc-branch-part new-version))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2158 (vc-do-command nil 0 "rcs" file 'MASTER
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2159 (if (vc-trunk-p new-version) "-b"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2160 (concat "-b" (vc-branch-part new-version))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2161 ;; If this is an old RCS release, we might have
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2162 ;; to remove a remaining lock.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2163 (if (not (vc-backend-release-p 'RCS "5.6.2"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2164 ;; exit status of 1 is also accepted.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2165 ;; It means that the lock was removed before.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2166 (vc-do-command nil 1 "rcs" file 'MASTER
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2167 (concat "-u" old-version))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2168 ;; CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2169 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2170 ;; explicit check-in to the trunk requires a
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2171 ;; double check-in (first unexplicit) (CVS-1.3)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2172 (condition-case nil
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2173 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2174 (if (and rev (vc-trunk-p rev))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2175 (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2176 "ci" "-m" "intermediate"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2177 switches))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2178 (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2179 "ci" (if rev (concat "-r" rev))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2180 (concat "-m" comment)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2181 switches))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2182 (error (if (eq (vc-cvs-status file) 'needs-merge)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2183 ;; The CVS output will be on top of this message.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2184 (error "Type C-x 0 C-x C-q to merge in changes")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2185 (error "Check-in failed"))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2186 ;; determine and store the new workfile version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2187 (set-buffer "*vc*")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2188 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2189 (if (re-search-forward
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2190 "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" nil t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2191 (vc-file-setprop file 'vc-workfile-version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2192 (buffer-substring (match-beginning 2)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2193 (match-end 2)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2194 (vc-file-setprop file 'vc-workfile-version nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2195 ;; if this was an explicit check-in, remove the sticky tag
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2196 (if rev
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2197 (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2198 (vc-file-setprop file 'vc-locking-user 'none)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2199 (vc-file-setprop file 'vc-checkout-time
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2200 (nth 5 (file-attributes file)))))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2201 (message "Checking in %s...done" file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (defun vc-backend-revert (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 ;; Revert file to latest checked-in version.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2205 ;; (for RCS, to workfile version)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (message "Reverting %s..." file)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2207 (vc-file-clear-masterprops file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 (vc-backend-dispatch
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2209 file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2210 ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2211 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2212 (vc-do-command nil 0 "unget" file 'MASTER nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2213 (vc-do-command nil 0 "get" file 'MASTER nil))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2214 ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2215 (vc-do-command nil 0 "co" file 'MASTER
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2216 "-f" (concat "-u" (vc-workfile-version file)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2217 ;; CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2218 (progn
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2219 (delete-file file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2220 (vc-do-command nil 0 "cvs" file 'WORKFILE "update")))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2221 (vc-file-setprop file 'vc-locking-user 'none)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2222 (vc-file-setprop file 'vc-checkout-time (nth 5 (file-attributes file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 (message "Reverting %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 (defun vc-backend-steal (file &optional rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 ;; Steal the lock on the current workfile. Needs RCS 5.6.2 or later for -M.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (message "Stealing lock on %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 (vc-backend-dispatch file
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2230 (progn ;SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2231 (vc-do-command nil 0 "unget" file 'MASTER "-n" (if rev (concat "-r" rev)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2232 (vc-do-command nil 0 "get" file 'MASTER "-g" (if rev (concat "-r" rev)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2233 )
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2234 (vc-do-command nil 0 "rcs" file 'MASTER ;RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2235 "-M" (concat "-u" rev) (concat "-l" rev))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2236 (error "You cannot steal a CVS lock; there are no CVS locks to steal") ;CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2237 )
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2238 (vc-file-setprop file 'vc-locking-user (vc-user-login-name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (message "Stealing lock on %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 (defun vc-backend-uncheck (file target)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2243 ;; Undo the latest checkin.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (message "Removing last change from %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (vc-backend-dispatch file
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2246 (vc-do-command nil 0 "rmdel" file 'MASTER (concat "-r" target))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2247 (vc-do-command nil 0 "rcs" file 'MASTER (concat "-o" target))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2248 nil ;; this is never reached under CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2249 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (message "Removing last change from %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (defun vc-backend-print-log (file)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2254 ;; Get change log associated with FILE.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (vc-backend-dispatch
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2256 file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2257 (vc-do-command nil 0 "prs" file 'MASTER)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2258 (vc-do-command nil 0 "rlog" file 'MASTER)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2259 (vc-do-command nil 0 "cvs" file 'WORKFILE "log")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 (defun vc-backend-assign-name (file name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 ;; Assign to a FILE's latest version a given NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 (vc-backend-dispatch file
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2264 (vc-add-triple name file (vc-latest-version file)) ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2265 (vc-do-command nil 0 "rcs" file 'MASTER (concat "-n" name ":")) ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2266 (vc-do-command nil 0 "cvs" file 'WORKFILE "tag" name) ;; CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2267 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 (defun vc-backend-diff (file &optional oldvers newvers cmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 ;; Get a difference report between two versions of FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 ;; Get only a brief comparison report if CMP, a difference report otherwise.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2273 (let ((backend (vc-backend file)) options status
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2274 (diff-switches-list (if (listp diff-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2275 diff-switches
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2276 (list diff-switches))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 ((eq backend 'SCCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 (setq oldvers (vc-lookup-triple file oldvers))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2280 (setq newvers (vc-lookup-triple file newvers))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2281 (setq options (append (list (and cmp "--brief") "-q"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2282 (and oldvers (concat "-r" oldvers))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2283 (and newvers (concat "-r" newvers)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2284 (and (not cmp) diff-switches-list)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2285 (apply 'vc-do-command "*vc-diff*" 1 "vcdiff" file 'MASTER options))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2286 ((eq backend 'RCS)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2287 (if (not oldvers) (setq oldvers (vc-workfile-version file)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2288 ;; If we know that --brief is not supported, don't try it.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2289 (setq cmp (and cmp (not (eq vc-rcsdiff-knows-brief 'no))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2290 (setq options (append (list (and cmp "--brief") "-q"
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2291 (concat "-r" oldvers)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2292 (and newvers (concat "-r" newvers)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2293 (and (not cmp) diff-switches-list)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2294 (setq status (apply 'vc-do-command "*vc-diff*" 2
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2295 "rcsdiff" file 'WORKFILE options))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2296 ;; If --brief didn't work, do a double-take and remember it
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2297 ;; for the future.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2298 (if (eq status 2)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2299 (prog1
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2300 (apply 'vc-do-command "*vc-diff*" 1 "rcsdiff" file 'WORKFILE
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2301 (if cmp (cdr options) options))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2302 (if cmp (setq vc-rcsdiff-knows-brief 'no)))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2303 ;; If --brief DID work, remember that, too.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2304 (and cmp (not vc-rcsdiff-knows-brief)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2305 (setq vc-rcsdiff-knows-brief 'yes))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2306 status))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 ;; CVS is different.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 ((eq backend 'CVS)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2309 (if (string= (vc-workfile-version file) "0")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 ;; This file is added but not yet committed; there is no master file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 (if (or oldvers newvers)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2312 (error "No revisions of %s exist" file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2313 (if cmp 1 ;; file is added but not committed,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2314 ;; we regard this as "changed".
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2315 ;; diff it against /dev/null.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2316 (apply 'vc-do-command
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2317 "*vc-diff*" 1 "diff" file 'WORKFILE
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2318 (append (if (listp diff-switches)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2319 diff-switches
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2320 (list diff-switches)) '("/dev/null")))))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2321 ;; cmp is not yet implemented -- we always do a full diff.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 (apply 'vc-do-command
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2323 "*vc-diff*" 1 "cvs" file 'WORKFILE "diff"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 (and oldvers (concat "-r" oldvers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 (and newvers (concat "-r" newvers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 (if (listp diff-switches)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2327 diff-switches
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2328 (list diff-switches)))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 (vc-registration-error file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 (defun vc-backend-merge-news (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 ;; Merge in any new changes made to FILE.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2334 (message "Merging changes into %s..." file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2335 (prog1
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2336 (vc-backend-dispatch
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2337 file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2338 (error "vc-backend-merge-news not meaningful for SCCS files") ;SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2339 (error "vc-backend-merge-news not meaningful for RCS files") ;RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2340 (save-excursion ; CVS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2341 (vc-file-clear-masterprops file)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2342 (vc-file-setprop file 'vc-workfile-version nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2343 (vc-file-setprop file 'vc-locking-user nil)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2344 (vc-do-command nil 0 "cvs" file 'WORKFILE "update")
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2345 ;; CVS doesn't return an error code if conflicts are detected.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2346 ;; Since we want to warn the user about it (and possibly start
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2347 ;; emerge later), scan the output and see if this occurred.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2348 (set-buffer (get-buffer "*vc*"))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2349 (goto-char (point-min))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2350 (if (re-search-forward "^cvs update: conflicts found in .*" nil t)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2351 1 ;; error code for caller
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2352 0 ;; no conflict detected
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2353 )))
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2354 (message "Merging changes into %s...done" file)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 (defun vc-check-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 "Check if the current file has any headers in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 (vc-backend-dispatch buffer-file-name
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2362 (re-search-forward "%[MIRLBSDHTEGUYFPQCZWA]%" nil t) ;; SCCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2363 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t) ;; RCS
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2364 'RCS ;; CVS works like RCS in this regard.
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2365 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 ;; Back-end-dependent stuff ends here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 ;; Set up key bindings for use while editing log messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2372 (defun vc-log-mode (&optional file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 "Minor mode for driving version-control tools.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 These bindings are added to the global keymap when you enter this mode:
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2375 \\[vc-next-action] perform next logical version-control operation on current file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2376 \\[vc-register] register current file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2377 \\[vc-toggle-read-only] like next-action, but won't register files
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2378 \\[vc-insert-headers] insert version-control headers in current file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2379 \\[vc-print-log] display change history of current file
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2380 \\[vc-revert-buffer] revert buffer to latest version
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2381 \\[vc-cancel-version] undo latest checkin
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2382 \\[vc-diff] show diffs between file versions
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2383 \\[vc-version-other-window] visit old version in another window
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2384 \\[vc-directory] show all files locked by any user in or below .
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2385 \\[vc-update-change-log] add change log entry from recent checkins
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 While you are entering a change log message for a version, the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 additional bindings will be in effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2390 \\[vc-finish-logentry] proceed with check in, ending log message entry
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 Whenever you do a checkin, your log comment is added to a ring of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 saved comments. These can be recalled as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2395 \\[vc-next-comment] replace region with next message in comment ring
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2396 \\[vc-previous-comment] replace region with previous message in comment ring
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2397 \\[vc-comment-search-reverse] search backward for regexp in the comment ring
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2398 \\[vc-comment-search-forward] search backward for regexp in the comment ring
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 Entry to the change-log submode calls the value of text-mode-hook, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 the value of vc-log-mode-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 Global user options:
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2404 vc-initial-comment If non-nil, require user to enter a change
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2405 comment upon first checkin of the file.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2407 vc-keep-workfiles Non-nil value prevents workfiles from being
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2408 deleted when changes are checked in
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2410 vc-suppress-confirm Suppresses some confirmation prompts,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2411 notably for reversions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2413 vc-header-alist Which keywords to insert when adding headers
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2414 with \\[vc-insert-headers]. Defaults to
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2415 '(\"\%\W\%\") under SCCS, '(\"\$Id\$\") under
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2416 RCS and CVS.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2418 vc-static-header-alist By default, version headers inserted in C files
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2419 get stuffed in a static string area so that
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2420 ident(RCS/CVS) or what(SCCS) can see them in
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2421 the compiled object code. You can override
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2422 this by setting this variable to nil, or change
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2423 the header template by changing it.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2425 vc-command-messages if non-nil, display run messages from the
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2426 actual version-control utilities (this is
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2427 intended primarily for people hacking vc
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2428 itself).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 (set-syntax-table text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 (use-local-map vc-log-entry-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 (setq major-mode 'vc-log-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 (setq mode-name "VC-Log")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 (make-local-variable 'vc-log-file)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2437 (setq vc-log-file file)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 (make-local-variable 'vc-log-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 (make-local-variable 'vc-comment-ring-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 (setq buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 (run-hooks 'text-mode-hook 'vc-log-mode-hook)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2443 )
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 ;; Initialization code, to be done just once at load-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 (if vc-log-entry-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 (setq vc-log-entry-mode (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 (define-key vc-log-entry-mode "\M-n" 'vc-next-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 (define-key vc-log-entry-mode "\M-p" 'vc-previous-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 (define-key vc-log-entry-mode "\M-r" 'vc-comment-search-reverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 (define-key vc-log-entry-mode "\M-s" 'vc-comment-search-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 (define-key vc-log-entry-mode "\C-c\C-c" 'vc-finish-logentry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 ;;; These things should probably be generally available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2458 (defun vc-file-tree-walk (dirname func &rest args)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2459 "Walk recursively through DIRNAME.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 Invoke FUNC f ARGS on each non-directory file f underneath it."
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2461 (vc-file-tree-walk-internal (expand-file-name dirname) func args)
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2462 (message "Traversing directory %s...done" dirname))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 (defun vc-file-tree-walk-internal (file func args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 (if (not (file-directory-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 (apply func file args)
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2467 (message "Traversing directory %s..." (abbreviate-file-name file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 (let ((dir (file-name-as-directory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 (lambda (f) (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 (string-equal f ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 (string-equal f "..")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 (member f vc-directory-exclusion-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 (let ((dirf (concat dir f)))
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2476 (or
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2477 (file-symlink-p dirf) ;; Avoid possible loops
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2478 (vc-file-tree-walk-internal dirf func args))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 (directory-files dir)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 (provide 'vc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 ;;; DEVELOPER'S NOTES ON CONCURRENCY PROBLEMS IN THIS CODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 ;;; These may be useful to anyone who has to debug or extend the package.
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2486 ;;; (Note that this information corresponds to versions 5.x. Some of it
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2487 ;;; might have been invalidated by the additions to support branching
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2488 ;;; and RCS keyword lookup. AS, 1995/03/24)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 ;;; A fundamental problem in VC is that there are time windows between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 ;;; vc-next-action's computations of the file's version-control state and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 ;;; the actions that change it. This is a window open to lossage in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 ;;; multi-user environment; someone else could nip in and change the state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 ;;; of the master during it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 ;;; The performance problem is that rlog/prs calls are very expensive; we want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 ;;; to avoid them as much as possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 ;;; ANALYSIS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 ;;; The performance problem, it turns out, simplifies in practice to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 ;;; problem of making vc-locking-user fast. The two other functions that call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 ;;; prs/rlog will not be so commonly used that the slowdown is a problem; one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 ;;; makes snapshots, the other deletes the calling user's last change in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 ;;; master.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 ;;; The race condition implies that we have to either (a) lock the master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 ;;; during the entire execution of vc-next-action, or (b) detect and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 ;;; recover from errors resulting from dispatch on an out-of-date state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 ;;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2511 ;;; Alternative (a) appears to be infeasible. The problem is that we can't
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 ;;; guarantee that the lock will ever be removed. Suppose a user starts a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 ;;; checkin, the change message buffer pops up, and the user, having wandered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 ;;; off to do something else, simply forgets about it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 ;;; Alternative (b), on the other hand, works well with a cheap way to speed up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 ;;; vc-locking-user. Usually, if a file is registered, we can read its locked/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 ;;; unlocked state and its current owner from its permissions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 ;;; This shortcut will fail if someone has manually changed the workfile's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 ;;; permissions; also if developers are munging the workfile in several
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 ;;; directories, with symlinks to a master (in this latter case, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ;;; permissions shortcut will fail to detect a lock asserted from another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 ;;; directory).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 ;;; Note that these cases correspond exactly to the errors which could happen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 ;;; because of a competing checkin/checkout race in between two instances of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;;; vc-next-action.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 ;;; For VC's purposes, a workfile/master pair may have the following states:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 ;;; A. Unregistered. There is a workfile, there is no master.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 ;;; B. Registered and not locked by anyone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 ;;; C. Locked by calling user and unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 ;;; D. Locked by the calling user and changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 ;;; E. Locked by someone other than the calling user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 ;;; This makes for 25 states and 20 error conditions. Here's the matrix:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 ;;; VC's idea of state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 ;;; |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 ;;; V Actual state RCS action SCCS action Effect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 ;;; A B C D E
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 ;;; A . 1 2 3 4 ci -u -t- admin -fb -i<file> initial admin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 ;;; B 5 . 6 7 8 co -l get -e checkout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 ;;; C 9 10 . 11 12 co -u unget; get revert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 ;;; D 13 14 15 . 16 ci -u -m<comment> delta -y<comment>; get checkin
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2552 ;;; E 17 18 19 20 . rcs -u -M -l unget -n ; get -g steal lock
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 ;;; All commands take the master file name as a last argument (not shown).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 ;;; In the discussion below, a "self-race" is a pathological situation in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 ;;; which VC operations are being attempted simultaneously by two or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 ;;; Emacsen running under the same username.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 ;;; The vc-next-action code has the following windows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 ;;; Window P:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 ;;; Between the check for existence of a master file and the call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 ;;; admin/checkin in vc-buffer-admin (apparent state A). This window may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 ;;; never close if the initial-comment feature is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 ;;; Window Q:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 ;;; Between the call to vc-workfile-unchanged-p in and the immediately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 ;;; following revert (apparent state C).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 ;;; Window R:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 ;;; Between the call to vc-workfile-unchanged-p in and the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 ;;; checkin (apparent state D). This window may never close.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 ;;; Window S:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 ;;; Between the unlock and the immediately following checkout during a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 ;;; revert operation (apparent state C). Included in window Q.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 ;;; Window T:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 ;;; Between vc-locking-user and the following checkout (apparent state B).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 ;;; Window U:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 ;;; Between vc-locking-user and the following revert (apparent state C).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 ;;; Includes windows Q and S.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 ;;; Window V:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 ;;; Between vc-locking-user and the following checkin (apparent state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 ;;; D). This window may never be closed if the user fails to complete the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 ;;; checkin message. Includes window R.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 ;;; Window W:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 ;;; Between vc-locking-user and the following steal-lock (apparent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 ;;; state E). This window may never close if the user fails to complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 ;;; the steal-lock message. Includes window X.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596 ;;; Window X:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597 ;;; Between the unlock and the immediately following re-lock during a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 ;;; steal-lock operation (apparent state E). This window may never cloce
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 ;;; if the user fails to complete the steal-lock message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 ;;; Errors:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 ;;; Apparent state A ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2605 ;;; 1. File looked unregistered but is actually registered and not locked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2606 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2607 ;;; Potential cause: someone else's admin during window P, with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2608 ;;; caller's admin happening before their checkout.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2609 ;;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2610 ;;; RCS: Prior to version 5.6.4, ci fails with message
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2611 ;;; "no lock set by <user>". From 5.6.4 onwards, VC uses the new
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2612 ;;; ci -i option and the message is "<file>,v: already exists".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2613 ;;; SCCS: admin will fail with error (ad19).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2614 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2615 ;;; We can let these errors be passed up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2616 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2617 ;;; 2. File looked unregistered but is actually locked by caller, unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2618 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2619 ;;; Potential cause: self-race during window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 ;;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2621 ;;; RCS: Prior to version 5.6.4, reverts the file to the last saved
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2622 ;;; version and unlocks it. From 5.6.4 onwards, VC uses the new
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2623 ;;; ci -i option, failing with message "<file>,v: already exists".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 ;;; SCCS: will fail with error (ad19).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 ;;; Either of these consequences is acceptable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 ;;; 3. File looked unregistered but is actually locked by caller, changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 ;;; Potential cause: self-race during window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 ;;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2632 ;;; RCS: Prior to version 5.6.4, VC registers the caller's workfile as
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2633 ;;; a delta with a null change comment (the -t- switch will be
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2634 ;;; ignored). From 5.6.4 onwards, VC uses the new ci -i option,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2635 ;;; failing with message "<file>,v: already exists".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 ;;; SCCS: will fail with error (ad19).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 ;;; 4. File looked unregistered but is locked by someone else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 ;;; Potential cause: someone else's admin during window P, with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 ;;; caller's admin happening *after* their checkout.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 ;;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2643 ;;; RCS: Prior to version 5.6.4, ci fails with a
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2644 ;;; "no lock set by <user>" message. From 5.6.4 onwards,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2645 ;;; VC uses the new ci -i option, failing with message
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2646 ;;; "<file>,v: already exists".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 ;;; SCCS: will fail with error (ad19).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 ;;; We can let these errors be passed up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 ;;; Apparent state B ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 ;;; 5. File looked registered and not locked, but is actually unregistered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 ;;; Potential cause: master file got nuked during window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 ;;; RCS: will fail with "RCS/<file>: No such file or directory"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2658 ;;; SCCS: will fail with error ut4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 ;;; We can let these errors be passed up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 ;;; 6. File looked registered and not locked, but is actually locked by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 ;;; calling user and unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 ;;; Potential cause: self-race during window T.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 ;;; RCS: in the same directory as the previous workfile, co -l will fail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 ;;; with "co error: writable foo exists; checkout aborted". In any other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 ;;; directory, checkout will succeed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 ;;; SCCS: will fail with ge17.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 ;;; Either of these consequences is acceptable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 ;;; 7. File looked registered and not locked, but is actually locked by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 ;;; calling user and changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 ;;; As case 6.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 ;;; 8. File looked registered and not locked, but is actually locked by another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 ;;; user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 ;;; Potential cause: someone else checks it out during window T.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 ;;; RCS: co error: revision 1.3 already locked by <user>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 ;;; SCCS: fails with ge4 (in directory) or ut7 (outside it).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 ;;; We can let these errors be passed up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 ;;; Apparent state C ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 ;;; 9. File looks locked by calling user and unchanged, but is unregistered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 ;;; As case 5.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 ;;; 10. File looks locked by calling user and unchanged, but is actually not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 ;;; locked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 ;;; Potential cause: a self-race in window U, or by the revert's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 ;;; landing during window X of some other user's steal-lock or window S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 ;;; of another user's revert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 ;;; RCS: succeeds, refreshing the file from the identical version in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 ;;; the master.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 ;;; SCCS: fails with error ut4 (p file nonexistent).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 ;;; Either of these consequences is acceptable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 ;;; 11. File is locked by calling user. It looks unchanged, but is actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 ;;; changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 ;;; Potential cause: the file would have to be touched by a self-race
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 ;;; during window Q.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 ;;; The revert will succeed, removing whatever changes came with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 ;;; the touch. It is theoretically possible that work could be lost.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 ;;; 12. File looks like it's locked by the calling user and unchanged, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 ;;; it's actually locked by someone else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 ;;; Potential cause: a steal-lock in window V.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 ;;; RCS: co error: revision <rev> locked by <user>; use co -r or rcs -u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 ;;; SCCS: fails with error un2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 ;;; We can pass these errors up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 ;;; Apparent state D ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 ;;; 13. File looks like it's locked by the calling user and changed, but it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 ;;; actually unregistered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 ;;; Potential cause: master file got nuked during window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 ;;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2734 ;;; RCS: Prior to version 5.6.4, checks in the user's version as an
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2735 ;;; initial delta. From 5.6.4 onwards, VC uses the new ci -j
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2736 ;;; option, failing with message "no such file or directory".
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 ;;; SCCS: will fail with error ut4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 ;;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2739 ;;; This case is kind of nasty. Under RCS prior to version 5.6.4,
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2740 ;;; VC may fail to detect the loss of previous version information.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2741 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 ;;; 14. File looks like it's locked by the calling user and changed, but it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 ;;; actually unlocked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 ;;; Potential cause: self-race in window V, or the checkin happening
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 ;;; during the window X of someone else's steal-lock or window S of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 ;;; someone else's revert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 ;;; RCS: ci will fail with "no lock set by <user>".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 ;;; SCCS: delta will fail with error ut4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 ;;; 15. File looks like it's locked by the calling user and changed, but it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 ;;; actually locked by the calling user and unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 ;;; Potential cause: another self-race --- a whole checkin/checkout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 ;;; sequence by the calling user would have to land in window R.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 ;;; SCCS: checks in a redundant delta and leaves the file unlocked as usual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 ;;; RCS: reverts to the file state as of the second user's checkin, leaving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 ;;; the file unlocked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 ;;; It is theoretically possible that work could be lost under RCS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 ;;; 16. File looks like it's locked by the calling user and changed, but it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 ;;; actually locked by a different user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 ;;; RCS: ci error: no lock set by <user>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 ;;; SCCS: unget will fail with error un2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 ;;; We can pass these errors up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 ;;; Apparent state E ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 ;;; 17. File looks like it's locked by some other user, but it's actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 ;;; unregistered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 ;;; As case 13.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 ;;; 18. File looks like it's locked by some other user, but it's actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 ;;; unlocked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 ;;; Potential cause: someone released a lock during window W.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 ;;; RCS: The calling user will get the lock on the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 ;;; SCCS: unget -n will fail with cm4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 ;;; Either of these consequences will be OK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 ;;; 19. File looks like it's locked by some other user, but it's actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 ;;; locked by the calling user and unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 ;;; Potential cause: the other user relinquishing a lock followed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 ;;; a self-race, both in window W.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 ;;; Under both RCS and SCCS, both unlock and lock will succeed, making
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 ;;; the sequence a no-op.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 ;;; 20. File looks like it's locked by some other user, but it's actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 ;;; locked by the calling user and changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 ;;; As case 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 ;;; PROBLEM CASES:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 ;;; In order of decreasing severity:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 ;;;
151
59463afc5666 Import from CVS: tag r20-3b2
cvs
parents: 144
diff changeset
2807 ;;; Cases 11 and 15 are the only ones that potentially lose work.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 ;;; They would require a self-race for this to happen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 ;;; Case 13 in RCS loses information about previous deltas, retaining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 ;;; only the information in the current workfile. This can only happen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 ;;; if the master file gets nuked in window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 ;;; Case 3 in RCS and case 15 under SCCS insert a redundant delta with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 ;;; no change comment in the master. This would require a self-race in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 ;;; window P or R respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 ;;; Cases 2, 10, 19 and 20 do extra work, but make no changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 ;;; Unfortunately, it appears to me that no recovery is possible in these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 ;;; cases. They don't yield error messages, so there's no way to tell that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 ;;; a race condition has occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 ;;; All other cases don't change either the workfile or the master, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 ;;; trigger command errors which the user will see.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 ;;; Thus, there is no explicit recovery code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 ;;; vc.el ends here