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