*** empty log message ***
[bpt/emacs.git] / lisp / vc.el
index 7b14111..2500844 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.244 1999/03/13 05:04:24 kwzh Exp spiegel $
+;; $Id: vc.el,v 1.259 2000/01/26 10:31:13 gerd Exp $
 
 ;; This file is part of GNU Emacs.
 
@@ -755,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.
@@ -1404,10 +1406,11 @@ and two version designators specifying which versions to compare."
 If FILE is a directory, generate diffs between versions for all registered
 files in or below it."
   (interactive 
-   (let ((file (read-file-name (if buffer-file-name
-                                  "File or dir to diff: (default visited file) "
-                                "File or dir to diff: ")
-                                default-directory buffer-file-name t))
+   (let ((file (expand-file-name
+                (read-file-name (if buffer-file-name
+                                    "File or dir to diff: (default visited file) "
+                                  "File or dir to diff: ")
+                                default-directory buffer-file-name t)))
          (rel1-default nil) (rel2-default nil))
      ;; compute default versions based on the file state
      (cond
@@ -1700,7 +1703,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)
@@ -1740,7 +1743,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))
@@ -2261,8 +2264,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)
@@ -2280,21 +2285,23 @@ default directory."
             (unwind-protect
                 (progn
                   (cd odefault)
-                  (if (eq 0 (apply 'call-process "rcs2log" nil
-                                      (list t tempfile) nil
-                                      "-c" changelog
-                                      "-u" (concat (vc-user-login-name)
-                                                   "\t" full-name
-                                                   "\t" mailing-address)
-                                      (mapcar
-                                       (function
-                                        (lambda (f)
-                                          (file-relative-name
-                                           (if (file-name-absolute-p f)
-                                               f
-                                             (concat odefault f)))))
-                                       args)))
-                         "done"
+                  (if (eq 0 (apply 'call-process
+                                   (expand-file-name "rcs2log" exec-directory)
+                                   nil
+                                   (list t tempfile) nil
+                                   "-c" changelog
+                                   "-u" (concat (vc-user-login-name)
+                                                "\t" full-name
+                                                "\t" mailing-address)
+                                   (mapcar
+                                    (function
+                                     (lambda (f)
+                                       (file-relative-name
+                                        (if (file-name-absolute-p f)
+                                            f
+                                          (concat odefault f)))))
+                                    args)))
+                      "done"
                     (pop-to-buffer
                      (set-buffer (get-buffer-create "*vc*")))
                     (erase-buffer)
@@ -2472,7 +2479,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)
@@ -2588,25 +2600,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
@@ -2622,21 +2631,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, 
@@ -2677,14 +2684,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
@@ -2942,10 +2951,11 @@ THRESHOLD, nil otherwise"
       ;; If --brief didn't work, do a double-take and remember it 
       ;; for the future.
       (if (eq status 2)
-          (prog1
-              (apply 'vc-do-command "*vc-diff*" 1 "rcsdiff" file 'WORKFILE
-                     (if cmp (cdr options) options))
-            (if cmp (setq vc-rcsdiff-knows-brief 'no)))
+         (setq status
+               (prog1
+                   (apply 'vc-do-command "*vc-diff*" 1 "rcsdiff" file 'WORKFILE
+                          (if cmp (cdr options) options))
+                 (if cmp (setq vc-rcsdiff-knows-brief 'no))))
         ;; If --brief DID work, remember that, too.
         (and cmp (not vc-rcsdiff-knows-brief)
              (setq vc-rcsdiff-knows-brief 'yes))
@@ -2995,7 +3005,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)