]> code.delx.au - gnu-emacs/blobdiff - lisp/vc.el
(mh-version): Use mh-e-RCS-id rather than mh-e-version
[gnu-emacs] / lisp / vc.el
index 59457863b9a48d24fdc9146a05c36d4241499ea3..190cdc254be2792d548cf336d0a8c0321c9f5059 100644 (file)
@@ -1,6 +1,6 @@
 ;;; vc.el --- drive a version-control system from within Emacs
 
-;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
 
 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
 ;; Modified by:
@@ -21,8 +21,9 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;;; Commentary:
 
@@ -189,7 +190,7 @@ If nil, VC itself computes this value when it is first needed.")
 (defvar vc-dired-mode nil)
 (make-variable-buffer-local 'vc-dired-mode)
 
-(defvar vc-comment-ring nil)
+(defvar vc-comment-ring (make-ring vc-maximum-comment-ring-size))
 (defvar vc-comment-ring-index nil)
 (defvar vc-last-comment-match nil)
 
@@ -296,7 +297,7 @@ If nil, VC itself computes this value when it is first needed.")
   (fillarray vc-file-prop-obarray nil)
   ;; Note: there is potential for minor lossage here if there is an open
   ;; log buffer with a nonzero local value of vc-comment-ring-index.
-  (setq vc-comment-ring nil))
+  (setq vc-comment-ring (make-ring vc-maximum-comment-ring-size)))
 
 (defun vc-file-clear-masterprops (file)
   ;; clear all properties of FILE that were retrieved
@@ -710,7 +711,8 @@ to an optional list of FLAGS."
        (dired-buffer (current-buffer))
        (dired-dir default-directory))
     (dired-map-over-marks
-     (let ((file (dired-get-filename)) p)
+     (let ((file (dired-get-filename)) p
+          (default-directory default-directory))
        (message "Processing %s..." file)
        ;; Adjust the default directory so that checkouts
        ;; go to the right place.
@@ -1004,8 +1006,6 @@ If nil, uses `change-log-default-name'."
        ;; Comment too long?
        (vc-backend-logentry-check vc-log-file)
        ;; Record the comment in the comment ring
-       (if (null vc-comment-ring)
-           (setq vc-comment-ring (make-ring vc-maximum-comment-ring-size)))
        (ring-insert vc-comment-ring (buffer-string))
        ))
   ;; Sync parent buffer in case the user modified it while editing the comment.
@@ -1108,7 +1108,7 @@ Normally this compares the current file and buffer with the most recent
 checked in version of that file.  This uses no arguments.
 With a prefix argument, it reads the file name to use
 and two version designators specifying which versions to compare."
-  (interactive "P")
+  (interactive (list current-prefix-arg t))
   (if vc-dired-mode
       (set-buffer (find-file-noselect (dired-get-filename))))
   (while vc-parent-buffer
@@ -1727,7 +1727,10 @@ A prefix argument means do not revert the buffer afterwards."
     (if oldbuf
        (save-excursion
          (set-buffer oldbuf)
-         (set-visited-file-name new)
+         (let ((buffer-read-only buffer-read-only))
+           (set-visited-file-name new))
+         (vc-backend new)
+         (vc-mode-line new)
          (set-buffer-modified-p nil))))
   ;; This had FILE, I changed it to OLD. -- rms.
   (vc-backend-dispatch old
@@ -1768,12 +1771,10 @@ From a program, any arguments are passed to the `rcs2log' script."
                              f)))
                         (directory-files RCS nil "...\\|^[^.]\\|^.[^.]")))))))
   (let ((odefault default-directory)
-       (full-name (if (boundp 'add-log-full-name)
-                      add-log-full-name
-                    (user-full-name)))
-       (mailing-address (if (boundp 'add-log-mailing-address)
-                            add-log-mailing-address
-                          user-mail-address)))
+       (full-name (or add-log-full-name
+                      (user-full-name)))
+       (mailing-address (or add-log-mailing-address
+                            user-mail-address)))
     (find-file-other-window (find-change-log))
     (barf-if-buffer-read-only)
     (vc-buffer-sync)
@@ -1850,7 +1851,6 @@ From a program, any arguments are passed to the `rcs2log' script."
   ;; Retrieve a copy of a saved version into a workfile
   (let ((filename (or workfile file))
        (file-buffer (get-file-buffer file))
-       (old-default-dir default-directory)
        switches)
     (message "Checking out %s..." filename)
     (save-excursion
@@ -1859,148 +1859,152 @@ From a program, any arguments are passed to the `rcs2log' script."
       (setq switches (if (stringp vc-checkout-switches)
                         (list vc-checkout-switches)
                       vc-checkout-switches))
-      ;; Adjust the default-directory so that the check-out creates 
-      ;; the file in the right place. The old value is restored below.
-      (setq default-directory (file-name-directory filename))
-      (vc-backend-dispatch file
-        (progn  ;; SCCS
-          (and rev (string= rev "") (setq rev nil))
-          (if workfile  
-              ;; Some SCCS implementations allow checking out directly to a
-              ;; file using the -G option, but then some don't so use the
-              ;; least common denominator approach and use the -p option
-              ;; ala RCS.
-              (let ((vc-modes (logior (file-modes (vc-name file))
-                                      (if writable 128 0)))
-                    (failed t))
-                (unwind-protect
-                    (progn
-                      (apply 'vc-do-command
-                             nil 0 "/bin/sh" file 'MASTER "-c"
-                             ;; Some shells make the "" dummy argument into $0
-                             ;; while others use the shell's name as $0 and
-                             ;; use the "" as $1.  The if-statement
-                             ;; converts the latter case to the former.
-                             (format "if [ x\"$1\" = x ]; then shift; fi; \
+      ;; Save this buffer's default-directory
+      ;; and use save-excursion to make sure it is restored
+      ;; in the same buffer it was saved in.
+      (let ((default-directory default-directory))
+       (save-excursion
+         ;; Adjust the default-directory so that the check-out creates 
+         ;; the file in the right place.
+         (setq default-directory (file-name-directory filename))
+         (vc-backend-dispatch file
+           (progn  ;; SCCS
+             (and rev (string= rev "") (setq rev nil))
+             (if workfile  
+                 ;; Some SCCS implementations allow checking out directly to a
+                 ;; file using the -G option, but then some don't so use the
+                 ;; least common denominator approach and use the -p option
+                 ;; ala RCS.
+                 (let ((vc-modes (logior (file-modes (vc-name file))
+                                         (if writable 128 0)))
+                       (failed t))
+                   (unwind-protect
+                       (progn
+                         (apply 'vc-do-command
+                                nil 0 "/bin/sh" file 'MASTER "-c"
+                                ;; Some shells make the "" dummy argument into $0
+                                ;; while others use the shell's name as $0 and
+                                ;; use the "" as $1.  The if-statement
+                                ;; converts the latter case to the former.
+                                (format "if [ x\"$1\" = x ]; then shift; fi; \
                               umask %o; exec >\"$1\" || exit; \
                               shift; umask %o; exec get \"$@\""
-                                  (logand 511 (lognot vc-modes))
-                                  (logand 511 (lognot (default-file-modes))))
-                             ""                ; dummy argument for shell's $0
-                             filename 
-                             (if writable "-e")
-                             "-p" 
-                             (and rev
-                                  (concat "-r" (vc-lookup-triple file rev)))
-                             switches)
-                      (setq failed nil))
-                  (and failed (file-exists-p filename) 
-                       (delete-file filename))))
-            (apply 'vc-do-command nil 0 "get" file 'MASTER   ;; SCCS
-                   (if writable "-e")
-                   (and rev (concat "-r" (vc-lookup-triple file rev)))
-                   switches)
-            (vc-file-setprop file 'vc-workfile-version nil)))
-        (if workfile  ;; RCS
-           ;; RCS doesn't let us check out into arbitrary file names directly.
-           ;; Use `co -p' and make stdout point to the correct file.
-           (let ((vc-modes (logior (file-modes (vc-name file))
-                                   (if writable 128 0)))
-                 (failed t))
-             (unwind-protect
-                 (progn
-                   (apply 'vc-do-command
-                          nil 0 "/bin/sh" file 'MASTER "-c"
-                          ;; See the SCCS case, above, regarding the
-                          ;; if-statement.
-                          (format "if [ x\"$1\" = x ]; then shift; fi; \
+                                      (logand 511 (lognot vc-modes))
+                                      (logand 511 (lognot (default-file-modes))))
+                                ""             ; dummy argument for shell's $0
+                                filename 
+                                (if writable "-e")
+                                "-p" 
+                                (and rev
+                                     (concat "-r" (vc-lookup-triple file rev)))
+                                switches)
+                         (setq failed nil))
+                     (and failed (file-exists-p filename) 
+                          (delete-file filename))))
+               (apply 'vc-do-command nil 0 "get" file 'MASTER   ;; SCCS
+                      (if writable "-e")
+                      (and rev (concat "-r" (vc-lookup-triple file rev)))
+                      switches)
+               (vc-file-setprop file 'vc-workfile-version nil)))
+           (if workfile  ;; RCS
+               ;; RCS doesn't let us check out into arbitrary file names directly.
+               ;; Use `co -p' and make stdout point to the correct file.
+               (let ((vc-modes (logior (file-modes (vc-name file))
+                                       (if writable 128 0)))
+                     (failed t))
+                 (unwind-protect
+                     (progn
+                       (apply 'vc-do-command
+                              nil 0 "/bin/sh" file 'MASTER "-c"
+                              ;; See the SCCS case, above, regarding the
+                              ;; if-statement.
+                              (format "if [ x\"$1\" = x ]; then shift; fi; \
                               umask %o; exec >\"$1\" || exit; \
                               shift; umask %o; exec co \"$@\""
-                                  (logand 511 (lognot vc-modes))
-                                  (logand 511 (lognot (default-file-modes))))
-                          ""           ; dummy argument for shell's $0
-                          filename
-                          (if writable "-l")
-                          (concat "-p" rev)
-                          switches)
-                   (setq failed nil))
-               (and failed (file-exists-p filename) (delete-file filename))))
-         (let (new-version)
-           ;; if we should go to the head of the trunk, 
-           ;; clear the default branch first
-           (and rev (string= rev "") 
-                (vc-do-command nil 0 "rcs" file 'MASTER "-b"))
-           ;; now do the checkout
-           (apply 'vc-do-command
-                  nil 0 "co" file 'MASTER
-                  ;; If locking is not strict, force to overwrite
-                  ;; the writable workfile.
-                  (if (eq (vc-checkout-model file) 'implicit) "-f")
-                  (if writable "-l")
-                  (if rev (concat "-r" rev)
-                    ;; if no explicit revision was specified,
-                    ;; check out that of the working file
-                    (let ((workrev (vc-workfile-version file)))
-                      (if workrev (concat "-r" workrev)
-                        nil)))
-                  switches)
-           ;; determine the new workfile version
-           (save-excursion
-             (set-buffer "*vc*")
-             (goto-char (point-min))
-             (setq new-version 
-                   (if (re-search-forward "^revision \\([0-9.]+\\).*\n" nil t)
-                       (buffer-substring (match-beginning 1) (match-end 1)))))
-           (vc-file-setprop file 'vc-workfile-version new-version)
-           ;; if necessary, adjust the default branch
-           (and rev (not (string= rev ""))
-                (vc-do-command nil 0 "rcs" file 'MASTER 
-                   (concat "-b" (if (vc-latest-on-branch-p file)
-                                    (if (vc-trunk-p new-version) nil
-                                      (vc-branch-part new-version))
-                                  new-version))))))
-       (if workfile  ;; CVS
-           ;; CVS is much like RCS
-           (let ((failed t))
-             (unwind-protect
-                 (progn
-                   (apply 'vc-do-command
-                          nil 0 "/bin/sh" file 'WORKFILE "-c"
-                          "exec >\"$1\" || exit; shift; exec cvs update \"$@\""
-                          ""           ; dummy argument for shell's $0
-                          workfile
-                          (concat "-r" rev)
-                          "-p"
-                          switches)
-                   (setq failed nil))
-               (and failed (file-exists-p filename) (delete-file filename))))
-         ;; default for verbose checkout: clear the sticky tag
-         ;; so that the actual update will get the head of the trunk
-         (and rev (string= rev "")
-              (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A"))
-         ;; If a revision was specified, check that out.
-         (if rev
-             (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE 
-                    (and writable (eq (vc-checkout-model file) 'manual) "-w")
-                    "update"
-                    (and rev (not (string= rev ""))
-                         (concat "-r" rev))
-                    switches)
-           ;; If no revision was specified, simply make the file writable.
-           (and writable 
-                (or (eq (vc-checkout-model file) 'manual)
-                    (zerop (logand 128 (file-modes file))))
-                (set-file-modes file (logior 128 (file-modes file)))))
-         (if rev (vc-file-setprop file 'vc-workfile-version nil))))
-    (setq default-directory old-default-dir)
-    (cond 
-     ((not workfile)
-      (vc-file-clear-masterprops file)
-      (if writable 
-         (vc-file-setprop file 'vc-locking-user (user-login-name)))
-      (vc-file-setprop file
-                      'vc-checkout-time (nth 5 (file-attributes file)))))
-    (message "Checking out %s...done" filename))))
+                                      (logand 511 (lognot vc-modes))
+                                      (logand 511 (lognot (default-file-modes))))
+                              ""               ; dummy argument for shell's $0
+                              filename
+                              (if writable "-l")
+                              (concat "-p" rev)
+                              switches)
+                       (setq failed nil))
+                   (and failed (file-exists-p filename) (delete-file filename))))
+             (let (new-version)
+               ;; if we should go to the head of the trunk, 
+               ;; clear the default branch first
+               (and rev (string= rev "") 
+                    (vc-do-command nil 0 "rcs" file 'MASTER "-b"))
+               ;; now do the checkout
+               (apply 'vc-do-command
+                      nil 0 "co" file 'MASTER
+                      ;; If locking is not strict, force to overwrite
+                      ;; the writable workfile.
+                      (if (eq (vc-checkout-model file) 'implicit) "-f")
+                      (if writable "-l")
+                      (if rev (concat "-r" rev)
+                        ;; if no explicit revision was specified,
+                        ;; check out that of the working file
+                        (let ((workrev (vc-workfile-version file)))
+                          (if workrev (concat "-r" workrev)
+                            nil)))
+                      switches)
+               ;; determine the new workfile version
+               (save-excursion
+                 (set-buffer "*vc*")
+                 (goto-char (point-min))
+                 (setq new-version 
+                       (if (re-search-forward "^revision \\([0-9.]+\\).*\n" nil t)
+                           (buffer-substring (match-beginning 1) (match-end 1)))))
+               (vc-file-setprop file 'vc-workfile-version new-version)
+               ;; if necessary, adjust the default branch
+               (and rev (not (string= rev ""))
+                    (vc-do-command nil 0 "rcs" file 'MASTER 
+                       (concat "-b" (if (vc-latest-on-branch-p file)
+                                        (if (vc-trunk-p new-version) nil
+                                          (vc-branch-part new-version))
+                                      new-version))))))
+           (if workfile  ;; CVS
+               ;; CVS is much like RCS
+               (let ((failed t))
+                 (unwind-protect
+                     (progn
+                       (apply 'vc-do-command
+                              nil 0 "/bin/sh" file 'WORKFILE "-c"
+                              "exec >\"$1\" || exit; shift; exec cvs update \"$@\""
+                              ""               ; dummy argument for shell's $0
+                              workfile
+                              (concat "-r" rev)
+                              "-p"
+                              switches)
+                       (setq failed nil))
+                   (and failed (file-exists-p filename) (delete-file filename))))
+             ;; default for verbose checkout: clear the sticky tag
+             ;; so that the actual update will get the head of the trunk
+             (and rev (string= rev "")
+                  (vc-do-command nil 0 "cvs" file 'WORKFILE "update" "-A"))
+             ;; If a revision was specified, check that out.
+             (if rev
+                 (apply 'vc-do-command nil 0 "cvs" file 'WORKFILE 
+                        (and writable (eq (vc-checkout-model file) 'manual) "-w")
+                        "update"
+                        (and rev (not (string= rev ""))
+                             (concat "-r" rev))
+                        switches)
+               ;; If no revision was specified, simply make the file writable.
+               (and writable 
+                    (or (eq (vc-checkout-model file) 'manual)
+                        (zerop (logand 128 (file-modes file))))
+                    (set-file-modes file (logior 128 (file-modes file)))))
+             (if rev (vc-file-setprop file 'vc-workfile-version nil))))
+         (cond 
+          ((not workfile)
+           (vc-file-clear-masterprops file)
+           (if writable 
+               (vc-file-setprop file 'vc-locking-user (user-login-name)))
+           (vc-file-setprop file
+                            'vc-checkout-time (nth 5 (file-attributes file)))))
+         (message "Checking out %s...done" filename))))))
 
 (defun vc-backend-logentry-check (file)
   (vc-backend-dispatch file