aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond2007-10-06 11:14:32 +0000
committerEric S. Raymond2007-10-06 11:14:32 +0000
commit61de26cb850764423287d3435c70cffaf6c576a1 (patch)
tree52e1f8ee4f7a905cad561c5891aa9c9e297433ae
parentca7442e8459befc944ff810e5b8e366bd75994fd (diff)
downloademacs-61de26cb850764423287d3435c70cffaf6c576a1.tar.gz
emacs-61de26cb850764423287d3435c70cffaf6c576a1.zip
Port various comments from new VC to reduce the noise in the diff.
Rename vc-revert-buffer1 to vc-revert-buffer-internal. Patch in the new vc-create-repo function to go with the header comment about it already present. No changes to existing logic.
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/vc.el91
2 files changed, 74 insertions, 24 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 96c142b3024..9a6b052042f 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,6 +1,11 @@
12007-10-06 Eric S. Raymond <esr@snark.thyrsus.com> 12007-10-06 Eric S. Raymond <esr@snark.thyrsus.com>
2 2
3 * vc.el: workfile version -> focus version change. 3 * vc.el: workfile version -> focus version change. Port various
4 comments from new VC to reduce the noise in the diff.
5 Patch in the new vc-create-repo function to go with the
6 header comment about it already present.
7 There are changes to existing logic in this patch.
8 *vc.el (vc-revert-buffer1): Rename to to vc-revert-buffer-internal.
4 9
52007-10-06 Aaron Hawley <aaronh@garden.org> 102007-10-06 Aaron Hawley <aaronh@garden.org>
6 11
diff --git a/lisp/vc.el b/lisp/vc.el
index b9c2efff34e..042f9191737 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -27,8 +27,9 @@
27;;; Credits: 27;;; Credits:
28 28
29;; VC was initially designed and implemented by Eric S. Raymond 29;; VC was initially designed and implemented by Eric S. Raymond
30;; <esr@snark.thyrsus.com>. Over the years, many people have 30;; <esr@thyrsus.com> in 1992. Over the years, many other people have
31;; contributed substantial amounts of work to VC. These include: 31;; contributed substantial amounts of work to VC. These include:
32;;
32;; Per Cederqvist <ceder@lysator.liu.se> 33;; Per Cederqvist <ceder@lysator.liu.se>
33;; Paul Eggert <eggert@twinsun.com> 34;; Paul Eggert <eggert@twinsun.com>
34;; Sebastian Kremer <sk@thp.uni-koeln.de> 35;; Sebastian Kremer <sk@thp.uni-koeln.de>
@@ -39,6 +40,24 @@
39;; Andre Spiegel <spiegel@gnu.org> 40;; Andre Spiegel <spiegel@gnu.org>
40;; Richard Stallman <rms@gnu.org> 41;; Richard Stallman <rms@gnu.org>
41;; Thien-Thi Nguyen <ttn@gnu.org> 42;; Thien-Thi Nguyen <ttn@gnu.org>
43;;
44;; In July 2007 ESR returned and redesigned the mode to cope better
45;; with modern version-control systems that do commits by fileset
46;; rather than per individual file.
47;;
48;; Features in the new version:
49;; * Key commands (vc-next-action = C-x v v, vc-print-log = C-x v l, vc-revert
50;; = C-x v u, vc-rollback = C-x v c, vc-diff = C-x v =, vc-update = C-x v +)
51;; now operate on filesets rather than individual files.
52;; * The fileset for a command is either (a) all marked files in VC-dired
53;; mode, (b) the currently visited file if it's under version control,
54;; or (c) the current directory if the visited buffer is not under
55;; version control and a wildcarding-enable flag has been set.
56;;
57;; If you maintain a client of the mode or customize it in your .emacs,
58;; note that some backend functions which formerly took single file arguments
59;; now take a list of files. These include: register, checkin, print-log,
60;; rollback, and diff.
42 61
43;;; Commentary: 62;;; Commentary:
44 63
@@ -104,9 +123,11 @@
104;; 123;;
105;; * revision-granularity 124;; * revision-granularity
106;; 125;;
107;; Takes no arguments. Returns either 'file or 'repository. 126;; Takes no arguments. Returns either 'file or 'repository. Backends
108;; FIXME: What does this mean? Why "repository"? 127;; that return 'file have per-file revision numbering; backends
109;; 128;; that return 'repository have per-repository revision numbering,
129;; so a revision level implicitly identifies a changeset
130;;
110;; STATE-QUERYING FUNCTIONS 131;; STATE-QUERYING FUNCTIONS
111;; 132;;
112;; * registered (file) 133;; * registered (file)
@@ -143,7 +164,10 @@
143;; 164;;
144;; * workfile-version (file) 165;; * workfile-version (file)
145;; 166;;
146;; Return the current focus version of FILE. 167;; Return the current focus version of FILE. This is the version fetched
168;; by the last checkout or upate, not necessarily the same thing as the
169;; head or tip version. Should return "0" for a file added but not yet
170;; committed.
147;; 171;;
148;; - latest-on-branch-p (file) 172;; - latest-on-branch-p (file)
149;; 173;;
@@ -185,7 +209,7 @@
185;; 209;;
186;; STATE-CHANGING FUNCTIONS 210;; STATE-CHANGING FUNCTIONS
187;; 211;;
188;; * create-repo () 212;; * create-repo (backend)
189;; 213;;
190;; Create an empty repository in the current directory and initialize 214;; Create an empty repository in the current directory and initialize
191;; it so VC mode can add files to it. For file-oriented systems, this 215;; it so VC mode can add files to it. For file-oriented systems, this
@@ -261,7 +285,7 @@
261;; 285;;
262;; * revert (file &optional contents-done) 286;; * revert (file &optional contents-done)
263;; 287;;
264;; Revert FILE back to the current workfile version. If optional 288;; Revert FILE back to the current focus version. If optional
265;; arg CONTENTS-DONE is non-nil, then the contents of FILE have 289;; arg CONTENTS-DONE is non-nil, then the contents of FILE have
266;; already been reverted from a version backup, and this function 290;; already been reverted from a version backup, and this function
267;; only needs to update the status of FILE within the backend. 291;; only needs to update the status of FILE within the backend.
@@ -312,8 +336,7 @@
312;; 336;;
313;; - wash-log (file) 337;; - wash-log (file)
314;; 338;;
315;; Remove all non-comment information from the output of print-log. The 339;; Remove all non-comment information from the output of print-log.
316;; default implementation of this function works for RCS-style logs.
317;; 340;;
318;; - logentry-check () 341;; - logentry-check ()
319;; 342;;
@@ -324,7 +347,7 @@
324;; 347;;
325;; - comment-history (file) 348;; - comment-history (file)
326;; 349;;
327;; Return a string containing all log entries that were made for FILE. 350;; Return a string containing all log entries that were madoe for FILE.
328;; This is used for transferring a file from one backend to another, 351;; This is used for transferring a file from one backend to another,
329;; retaining comment information. The default implementation of this 352;; retaining comment information. The default implementation of this
330;; function does this by calling print-log and then wash-log, and 353;; function does this by calling print-log and then wash-log, and
@@ -590,7 +613,7 @@ These are passed to the checkin program by \\[vc-register]."
590 :version "20.3") 613 :version "20.3")
591 614
592(defcustom vc-dired-terse-display t 615(defcustom vc-dired-terse-display t
593 "If non-nil, show only locked files in VC Dired." 616 "If non-nil, show only locked or locally modified files in VC Dired."
594 :type 'boolean 617 :type 'boolean
595 :group 'vc 618 :group 'vc
596 :version "20.3") 619 :version "20.3")
@@ -651,7 +674,7 @@ See `run-hooks'."
651 674
652;;;###autoload 675;;;###autoload
653(defcustom vc-checkin-hook nil 676(defcustom vc-checkin-hook nil
654 "Normal hook (list of functions) run after a checkin is done. 677 "Normal hook (list of functions) run after commit or file checkin.
655See also `log-edit-done-hook'." 678See also `log-edit-done-hook'."
656 :type 'hook 679 :type 'hook
657 :options '(log-edit-comment-to-change-log) 680 :options '(log-edit-comment-to-change-log)
@@ -659,7 +682,7 @@ See also `log-edit-done-hook'."
659 682
660;;;###autoload 683;;;###autoload
661(defcustom vc-before-checkin-hook nil 684(defcustom vc-before-checkin-hook nil
662 "Normal hook (list of functions) run before a file is checked in. 685 "Normal hook (list of functions) run before a commit or a file checkin.
663See `run-hooks'." 686See `run-hooks'."
664 :type 'hook 687 :type 'hook
665 :group 'vc) 688 :group 'vc)
@@ -840,15 +863,15 @@ been updated to their corresponding values."
840 property (cdr setting))))) 863 property (cdr setting)))))
841 ,settings))) 864 ,settings)))
842 865
843;; Random helper functions
844
845;; Two macros for elisp programming 866;; Two macros for elisp programming
867
846;;;###autoload 868;;;###autoload
847(defmacro with-vc-file (file comment &rest body) 869(defmacro with-vc-file (file comment &rest body)
848 "Check out a writable copy of FILE if necessary, then execute BODY. 870 "Check out a writable copy of FILE if necessary, then execute BODY.
849Check in FILE with COMMENT (a string) after BODY has been executed. 871Check in FILE with COMMENT (a string) after BODY has been executed.
850FILE is passed through `expand-file-name'; BODY executed within 872FILE is passed through `expand-file-name'; BODY executed within
851`save-excursion'. If FILE is not under version control, or locked by 873`save-excursion'. If FILE is not under version control, or you are
874using a locking version-control system and the file is locked by
852somebody else, signal error." 875somebody else, signal error."
853 (declare (debug t) (indent 2)) 876 (declare (debug t) (indent 2))
854 (let ((filevar (make-symbol "file"))) 877 (let ((filevar (make-symbol "file")))
@@ -879,6 +902,8 @@ However, before executing BODY, find FILE, and after BODY, save buffer."
879 ,@body 902 ,@body
880 (save-buffer))))) 903 (save-buffer)))))
881 904
905;; Common command execution logic to be used by backends
906
882(defun vc-process-filter (p s) 907(defun vc-process-filter (p s)
883 "An alternative output filter for async process P. 908 "An alternative output filter for async process P.
884One difference with the default filter is that this inserts S after markers. 909One difference with the default filter is that this inserts S after markers.
@@ -1018,6 +1043,7 @@ that is inserted into the command line before the filename."
1018 ;; start-process does not support remote execution 1043 ;; start-process does not support remote execution
1019 (setq okstatus nil)) 1044 (setq okstatus nil))
1020 (if (eq okstatus 'async) 1045 (if (eq okstatus 'async)
1046 ;; Run asynchronously
1021 (let ((proc 1047 (let ((proc
1022 (let ((process-connection-type nil)) 1048 (let ((process-connection-type nil))
1023 (apply 'start-process command (current-buffer) command 1049 (apply 'start-process command (current-buffer) command
@@ -1219,12 +1245,15 @@ Only files already under version control are noticed."
1219 (if (not (vc-backend buffer-file-name)) 1245 (if (not (vc-backend buffer-file-name))
1220 (error "File %s is not under version control" buffer-file-name))))) 1246 (error "File %s is not under version control" buffer-file-name)))))
1221 1247
1248;;; Support for the C-x v v command. This is where all the single-file-oriented
1249;;; code from before the fileset rewrite lives.
1250
1222(defsubst vc-editable-p (file) 1251(defsubst vc-editable-p (file)
1223 "Return non-nil if FILE can be edited." 1252 "Return non-nil if FILE can be edited."
1224 (or (eq (vc-checkout-model file) 'implicit) 1253 (or (eq (vc-checkout-model file) 'implicit)
1225 (memq (vc-state file) '(edited needs-merge)))) 1254 (memq (vc-state file) '(edited needs-merge))))
1226 1255
1227(defun vc-revert-buffer1 (&optional arg no-confirm) 1256(defun vc-revert-buffer-internal (&optional arg no-confirm)
1228 "Revert buffer, keeping point and mark where user expects them. 1257 "Revert buffer, keeping point and mark where user expects them.
1229Try to be clever in the face of changes due to expanded version control 1258Try to be clever in the face of changes due to expanded version control
1230key words. This is important for typeahead to work as expected. 1259key words. This is important for typeahead to work as expected.
@@ -1453,7 +1482,7 @@ If VERBOSE is non-nil, query the user rather than using default parameters."
1453 (yes-or-no-p (concat "File has unlocked changes. " 1482 (yes-or-no-p (concat "File has unlocked changes. "
1454 "Claim lock retaining changes? "))) 1483 "Claim lock retaining changes? ")))
1455 (progn (vc-call steal-lock file) 1484 (progn (vc-call steal-lock file)
1456 (clear-visited-file-modtime) 1485 (clear-visited-file-modtime)
1457 ;; Must clear any headers here because they wouldn't 1486 ;; Must clear any headers here because they wouldn't
1458 ;; show that the file is locked now. 1487 ;; show that the file is locked now.
1459 (vc-clear-headers file) 1488 (vc-clear-headers file)
@@ -1462,7 +1491,7 @@ If VERBOSE is non-nil, query the user rather than using default parameters."
1462 (if (not (yes-or-no-p 1491 (if (not (yes-or-no-p
1463 "Revert to checked-in version, instead? ")) 1492 "Revert to checked-in version, instead? "))
1464 (error "Checkout aborted") 1493 (error "Checkout aborted")
1465 (vc-revert-buffer1 t t) 1494 (vc-revert-buffer-internal t t)
1466 (vc-checkout file t)))))))) 1495 (vc-checkout file t))))))))
1467 1496
1468(defun vc-next-action-dired (file rev comment) 1497(defun vc-next-action-dired (file rev comment)
@@ -1479,6 +1508,18 @@ Ignores FILE and REV, but passes on COMMENT."
1479 nil t)) 1508 nil t))
1480 (dired-move-to-filename)) 1509 (dired-move-to-filename))
1481 1510
1511(defun vc-create-repo (backend)
1512 "Create an empty repository in the current directory."
1513 (interactive
1514 (list
1515 (intern
1516 (upcase
1517 (completing-read
1518 "Create repository for: "
1519 (mapcar (lambda (b) (list (downcase (symbol-name b)))) vc-handled-backends)
1520 nil t)))))
1521 (vc-call-backend backend 'create-repo))
1522
1482;;;###autoload 1523;;;###autoload
1483(defun vc-register (&optional set-version comment) 1524(defun vc-register (&optional set-version comment)
1484 "Register the current file into a version control system. 1525 "Register the current file into a version control system.
@@ -1537,7 +1578,7 @@ rather than user editing!"
1537 (and (string= buffer-file-name file) 1578 (and (string= buffer-file-name file)
1538 (if keep 1579 (if keep
1539 (progn 1580 (progn
1540 (vc-revert-buffer1 t noquery) 1581 (vc-revert-buffer-internal t noquery)
1541 ;; TODO: Adjusting view mode might no longer be necessary 1582 ;; TODO: Adjusting view mode might no longer be necessary
1542 ;; after RMS change to files.el of 1999-08-08. Investigate 1583 ;; after RMS change to files.el of 1999-08-08. Investigate
1543 ;; this when we install the new VC. 1584 ;; this when we install the new VC.
@@ -2069,7 +2110,7 @@ See Info node `Merging'."
2069 (state (vc-state file)) 2110 (state (vc-state file))
2070 first-version second-version status) 2111 first-version second-version status)
2071 (cond 2112 (cond
2072 ((stringp state) 2113 ((stringp state) ;; Locking VCses only
2073 (error "File is locked by %s" state)) 2114 (error "File is locked by %s" state))
2074 ((not (vc-editable-p file)) 2115 ((not (vc-editable-p file))
2075 (if (y-or-n-p 2116 (if (y-or-n-p
@@ -2595,7 +2636,7 @@ its name; otherwise return nil."
2595 backup-file))))) 2636 backup-file)))))
2596 2637
2597(defun vc-revert-file (file) 2638(defun vc-revert-file (file)
2598 "Revert FILE back to the version it was based on." 2639 "Revert FILE back to the repository version it was based on."
2599 (with-vc-properties 2640 (with-vc-properties
2600 file 2641 file
2601 (let ((backup-file (vc-version-backup-file file))) 2642 (let ((backup-file (vc-version-backup-file file)))
@@ -2832,6 +2873,11 @@ log entries should be gathered."
2832 (vc-call-backend (vc-responsible-backend default-directory) 2873 (vc-call-backend (vc-responsible-backend default-directory)
2833 'update-changelog args)) 2874 'update-changelog args))
2834 2875
2876;;; The default back end. Assumes RCS-like version numbering.
2877
2878(defun vc-default-revision-granularity ()
2879 (error "Your backend will not work with this version of VC mode."))
2880
2835;; functions that operate on RCS revision numbers. This code should 2881;; functions that operate on RCS revision numbers. This code should
2836;; also be moved into the backends. It stays for now, however, since 2882;; also be moved into the backends. It stays for now, however, since
2837;; it is used in code below. 2883;; it is used in code below.
@@ -3543,7 +3589,6 @@ The annotations are relative to the current time, unless overridden by OFFSET."
3543(defun vc-file-tree-walk (dirname func &rest args) 3589(defun vc-file-tree-walk (dirname func &rest args)
3544 "Walk recursively through DIRNAME. 3590 "Walk recursively through DIRNAME.
3545Invoke FUNC f ARGS on each VC-managed file f underneath it." 3591Invoke FUNC f ARGS on each VC-managed file f underneath it."
3546 ;; FIXME: Kill this function.
3547 (vc-file-tree-walk-internal (expand-file-name dirname) func args) 3592 (vc-file-tree-walk-internal (expand-file-name dirname) func args)
3548 (message "Traversing directory %s...done" dirname)) 3593 (message "Traversing directory %s...done" dirname))
3549 3594