]> code.delx.au - gnu-emacs/blobdiff - lisp/vc.el
*** empty log message ***
[gnu-emacs] / lisp / vc.el
index 78cfcf5e8ff0e0cadf131f47d1ff2535b892b6b8..1848a950d7209b61d1a6b9767e7402b0beaae22f 100644 (file)
@@ -5,7 +5,7 @@
 ;; Author:     Eric S. Raymond <esr@snark.thyrsus.com>
 ;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de>
 
-;; $Id: vc.el,v 1.241 1998/12/08 16:04:52 rost Exp rms $
+;; $Id: vc.el,v 1.256 1999/10/02 10:53:18 spiegel Exp $
 
 ;; This file is part of GNU Emacs.
 
@@ -107,6 +107,14 @@ If FORM3 is `RCS', use FORM2 for CVS as well as RCS.
   :type 'boolean
   :group 'vc)
 
+(defcustom vc-delete-logbuf-window t
+  "*If non-nil, delete the *VC-log* buffer and window after each logical action.
+If nil, bury that buffer instead.
+This is most useful if you have multiple windows on a frame and would like to
+preserve the setting."
+  :type 'boolean
+  :group 'vc)
+
 (defcustom vc-initial-comment nil
   "*If non-nil, prompt for initial comment when a file is registered."
   :type 'boolean
@@ -747,6 +755,8 @@ before the filename."
          (let ((new-mark (vc-find-position-by-context mark-context)))
            (if new-mark (set-mark new-mark))))))
 
+;; Maybe this "smart mark preservation" could be added directly
+;; to revert-buffer since it can be generally useful.  -sm
 (defun vc-revert-buffer1 (&optional arg no-confirm)
   ;; Revert buffer, try to keep point and mark where user expects them in spite
   ;; of changes because of expanded version-control key words.
@@ -1242,7 +1252,6 @@ May be useful as a `vc-checkin-hook' to update change logs automatically."
     (or (eobp) (looking-at "\n\n")
        (insert "\n"))))
 
-
 (defun vc-finish-logentry (&optional nocomment)
   "Complete the operation implied by the current log entry."
   (interactive)
@@ -1266,7 +1275,8 @@ May be useful as a `vc-checkin-hook' to update change logs automatically."
        (log-file vc-log-file)
        (log-version vc-log-version)
        (log-entry (buffer-string))
-       (after-hook vc-log-after-operation-hook))
+       (after-hook vc-log-after-operation-hook)
+       (tmp-vc-parent-buffer vc-parent-buffer))
     (pop-to-buffer vc-parent-buffer)
     ;; OK, do it to it
     (save-excursion
@@ -1277,10 +1287,13 @@ May be useful as a `vc-checkin-hook' to update change logs automatically."
     ;; Remove checkin window (after the checkin so that if that fails
     ;; we don't zap the *VC-log* buffer and the typing therein).
     (let ((logbuf (get-buffer "*VC-log*")))
-      (cond (logbuf
-             (delete-windows-on logbuf (selected-frame))
+      (cond ((and logbuf vc-delete-logbuf-window)
+            (delete-windows-on logbuf (selected-frame))
             ;; Kill buffer and delete any other dedicated windows/frames.
-             (kill-buffer logbuf))))
+            (kill-buffer logbuf))
+           (t (pop-to-buffer "*VC-log*")
+              (bury-buffer)
+              (pop-to-buffer tmp-vc-parent-buffer))))
     ;; Now make sure we see the expanded headers
     (if buffer-file-name
        (vc-resynch-window buffer-file-name vc-keep-workfiles t))
@@ -1689,7 +1702,7 @@ There is a special command, `*l', to mark all files currently locked."
            (dd "[ 0-3][0-9]")
            (HH:MM "[ 0-2][0-9]:[0-5][0-9]")
            (western (concat "\\(" month s dd "\\|" dd s month "\\)"
-                            s "\\(" HH:MM "\\|" s yyyy "\\)"))
+                            s "\\(" HH:MM "\\|" s yyyy"\\|" yyyy s "\\)"))
            (japanese (concat mm k s dd k s "\\(" s HH:MM "\\|" yyyy k "\\)")))
          (concat s "\\(" western "\\|" japanese "\\)" s)))
   (and (boundp 'vc-dired-switches)
@@ -1729,7 +1742,7 @@ There is a special command, `*l', to mark all files currently locked."
   (let ((default-directory dir))
     ;; Don't specify DIR in this command, the default-directory is
     ;; enough.  Otherwise it might fail with remote repositories.
-    (vc-do-command "*vc-info*" 0 "cvs" nil nil "status")
+    (vc-do-command "*vc-info*" 0 "cvs" nil nil "status" "-l")
     (save-excursion
       (set-buffer (get-buffer "*vc-info*"))
       (goto-char (point-min))
@@ -2250,8 +2263,10 @@ default directory."
   (let ((odefault default-directory)
        (changelog (find-change-log))
        ;; Presumably not portable to non-Unixy systems, along with rcs2log:
-       (tempfile (make-temp-name
-                  (expand-file-name "vc" temporary-file-directory)))
+       (tempfile (make-temp-file
+                  (expand-file-name "vc"
+                                    (or small-temporary-file-directory
+                                        temporary-file-directory))))
        (full-name (or add-log-full-name
                       (user-full-name)
                       (user-login-name)
@@ -2293,9 +2308,6 @@ default directory."
               (delete-file tempfile)))))
 \f
 ;; vc-annotate functionality (CVS only).
-(defvar vc-annotate-mode nil
-  "Variable indicating if VC-Annotate mode is active.")
-
 (defvar vc-annotate-mode-map nil
   "Local keymap used for VC-Annotate mode.")
 
@@ -2444,8 +2456,14 @@ THRESHOLD, nil otherwise"
            ("Sep" . 9) ("Oct" . 10) ("Nov" . 11) ("Dec" . 12))))
     (set-buffer buffer)
     (display-buffer buffer)
-    (if (not vc-annotate-mode)         ; Turn on vc-annotate-mode if not done
+    (or (eq major-mode 'vc-annotate-mode) ; Turn on vc-annotate-mode if not done
        (vc-annotate-mode))
+    ;; Delete old overlays
+    (mapcar
+     (lambda (overlay)
+       (if (overlay-get overlay 'vc-annotation)
+          (delete-overlay overlay)))
+     (overlays-in (point-min) (point-max)))
     (goto-char (point-min))            ; Position at the top of the buffer.
     (while (re-search-forward
            "^\\S-+\\s-+\\S-+\\s-+\\([0-9]+\\)-\\(\\sw+\\)-\\([0-9]+\\)): "
@@ -2458,7 +2476,12 @@ THRESHOLD, nil otherwise"
             (day (string-to-number (match-string 1)))
              (month (cdr (assoc (match-string 2) local-month-numbers)))
             (year-tmp (string-to-number (match-string 3)))
-            (year (+ (if (> 100 year-tmp) 1900 0) year-tmp)) ; Possible millenium problem
+            ;; Years 0..68 are 2000..2068.
+            ;; Years 69..99 are 1969..1999.
+            (year (+ (cond ((> 69 year-tmp) 2000)
+                           ((> 100 year-tmp) 1900)
+                           (t 0))
+                     year-tmp))
             (high (- (car (current-time))
                      (car (encode-time 0 0 0 day month year))))
             (color (cond ((vc-annotate-compcar high (cond (color-map)
@@ -2473,10 +2496,13 @@ THRESHOLD, nil otherwise"
                            (if vc-annotate-background
                                (set-face-background tmp-face vc-annotate-background))
                            tmp-face)))) ; Return the face
-            (point (point)))
+            (point (point))
+            overlay)
 
        (forward-line 1)
-       (overlay-put (make-overlay point (point) nil) 'face face)))))
+       (setq overlay (make-overlay point (point)))
+       (overlay-put overlay 'face face)
+       (overlay-put overlay 'vc-annotation t)))))
 
 \f
 ;; Collect back-end-dependent stuff here
@@ -2571,25 +2597,22 @@ THRESHOLD, nil otherwise"
                        (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))
+                          (let ((coding-system-for-read 'no-conversion)
+                                (coding-system-for-write 'no-conversion))
+                            (with-temp-file filename
+                              (apply 'vc-do-command
+                                     (current-buffer) 0 "get" file 'MASTER
+                                     "-s" ;; suppress diagnostic output
+                                     (if writable "-e")
+                                     "-p" 
+                                     (and rev
+                                          (concat "-r" 
+                                                  (vc-lookup-triple file rev)))
+                                     switches)))
+                          (set-file-modes filename
+                                          (logior (file-modes (vc-name file))
+                                                  (if writable 128 0)))
+                          (setq failed nil))
                      (and failed (file-exists-p filename) 
                           (delete-file filename))))
                (apply 'vc-do-command nil 0 "get" file 'MASTER   ;; SCCS
@@ -2605,21 +2628,19 @@ THRESHOLD, nil otherwise"
                      (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))
+                        (let ((coding-system-for-read 'no-conversion)
+                              (coding-system-for-write 'no-conversion))
+                          (with-temp-file filename
+                            (apply 'vc-do-command
+                                   (current-buffer) 0 "co" file 'MASTER
+                                   "-q" ;; suppress diagnostic output
+                                   (if writable "-l")
+                                   (concat "-p" rev)
+                                   switches)))
+                        (set-file-modes filename 
+                                        (logior (file-modes (vc-name file))
+                                                (if writable 128 0)))
+                        (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, 
@@ -2660,14 +2681,16 @@ THRESHOLD, nil otherwise"
                (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)
+                        (let ((coding-system-for-read 'no-conversion)
+                              (coding-system-for-write 'no-conversion))
+                          (with-temp-file filename
+                            (apply 'vc-do-command
+                                   (current-buffer) 0 "cvs" file 'WORKFILE 
+                                   "-Q" ;; suppress diagnostic output
+                                   "update"
+                                   (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
@@ -2839,9 +2862,14 @@ THRESHOLD, nil otherwise"
    (vc-do-command nil 0 "co" file 'MASTER
                  "-f" (concat "-u" (vc-workfile-version file)))
    ;; CVS
-   ;; Check out via standard output (caused by the final argument 
-   ;; FILE below), so that no sticky tag is set.
-   (vc-backend-checkout file nil (vc-workfile-version file) file))
+   (progn
+     ;; Check out via standard output (caused by the final argument 
+     ;; FILE below), so that no sticky tag is set.      
+     (vc-backend-checkout file nil (vc-workfile-version file) file)
+     ;; If "cvs edit" was used to make the file writeable,
+     ;; call "cvs unedit" now to undo that.
+     (if (eq (vc-checkout-model file) 'manual)
+         (vc-do-command nil 0 "cvs" file 'WORKFILE "unedit"))))
   (vc-file-setprop file 'vc-locking-user 'none)
   (vc-file-setprop file 'vc-checkout-time (nth 5 (file-attributes file)))
   (message "Reverting %s...done" file)
@@ -2973,7 +3001,7 @@ THRESHOLD, nil otherwise"
              (vc-file-setprop file 'vc-workfile-version (match-string 1)))
          ;; get file status
         (if (re-search-forward 
-              (concat "^\\(\\([CMU]\\) \\)?" 
+              (concat "^\\(\\([CMUP]\\) \\)?" 
                       (regexp-quote (file-name-nondirectory file))
                      "\\( already contains the differences between \\)?")
               nil t)