]> code.delx.au - gnu-emacs/blobdiff - lisp/vc.el
(texinfo-make-menu): Make region-end a marker.
[gnu-emacs] / lisp / vc.el
index 5b4309ad26efb83b6175a662254608cd10e70548..f22e2544aed8a66d6037bb854494c97586320664 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.236 1998/08/04 13:14:41 spiegel Exp fx $
+;; $Id: vc.el,v 1.242 1999/01/02 21:54:32 rms Exp spiegel $
 
 ;; This file is part of GNU Emacs.
 
@@ -291,21 +291,24 @@ and that its contents match what the master file says."
   "*The release number of your RCS installation, as a string.
 If nil, VC itself computes this value when it is first needed."
   :type '(choice (const :tag "Auto" nil)
-                string)
+                string 
+                (const :tag "Unknown" unknown))
   :group 'vc)
 
 (defcustom vc-sccs-release nil
   "*The release number of your SCCS installation, as a string.
 If nil, VC itself computes this value when it is first needed."
   :type '(choice (const :tag "Auto" nil)
-                string)
+                string 
+                (const :tag "Unknown" unknown))
   :group 'vc)
 
 (defcustom vc-cvs-release nil
   "*The release number of your CVS installation, as a string.
 If nil, VC itself computes this value when it is first needed."
   :type '(choice (const :tag "Auto" nil)
-                string)
+                string 
+                (const :tag "Unknown" unknown))
   :group 'vc)
 
 ;; Variables the user doesn't need to know about.
@@ -494,6 +497,39 @@ If nil, VC itself computes this value when it is first needed."
      ;; CVS
      t))
 
+;;; Two macros for elisp programming
+;;;###autoload
+(defmacro with-vc-file (file comment &rest body)
+  "Execute BODY, checking out a writable copy of FILE first if necessary.
+After BODY has been executed, check-in FILE with COMMENT (a string).  
+FILE is passed through `expand-file-name'; BODY executed within 
+`save-excursion'.  If FILE is not under version control, or locked by 
+somebody else, signal error."
+  `(let ((file (expand-file-name ,file)))
+     (or (vc-registered file)
+        (error (format "File not under version control: `%s'" file)))
+     (let ((locking-user (vc-locking-user file)))
+       (cond ((and (not locking-user)
+                   (eq (vc-checkout-model file) 'manual))
+              (vc-checkout file t))
+             ((and (stringp locking-user)
+                   (not (string= locking-user (vc-user-login-name))))
+              (error (format "`%s' is locking `%s'" locking-user file)))))
+     (save-excursion
+       ,@body)
+     (vc-checkin file nil ,comment)))
+
+;;;###autoload
+(defmacro edit-vc-file (file comment &rest body)
+  "Edit FILE under version control, executing BODY.  Checkin with COMMENT.
+This macro uses `with-vc-file', passing args to it.
+However, before executing BODY, find FILE, and after BODY, save buffer."
+  `(with-vc-file
+    ,file ,comment
+    (find-file ,file)
+    ,@body
+    (save-buffer)))
+
 (defun vc-ensure-vc-buffer ()
   ;; Make sure that the current buffer visits a version-controlled file.
   (if vc-dired-mode
@@ -895,6 +931,8 @@ before the filename."
            (vc-checkin file version comment)
            )))))
 
+(defvar vc-dired-window-configuration)
+
 (defun vc-next-action-dired (file rev comment)
   ;; Do a vc-next-action-on-file on all the marked files, possibly 
   ;; passing on the log comment we've just entered.
@@ -1526,6 +1564,9 @@ the variable `vc-header-alist'."
              (message "File contains conflict markers"))
          (message "Merge successful"))))))
 
+(defvar vc-ediff-windows)
+(defvar vc-ediff-result)
+
 ;;;###autoload
 (defun vc-resolve-conflicts (&optional name-A name-B)
   "Invoke ediff to resolve conflicts in the current buffer.
@@ -1613,6 +1654,9 @@ The conflicts must be marked with rcsmerge conflict markers."
 ;; The VC directory major mode.  Coopt Dired for this.
 ;; All VC commands get mapped into logical equivalents.
 
+(defvar vc-dired-switches)
+(defvar vc-dired-terse-mode)
+
 (define-derived-mode vc-dired-mode dired-mode "Dired under VC"
   "The major mode used in VC directory buffers.  It works like Dired,
 but lists only files under version control, with the current VC state of 
@@ -2249,9 +2293,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.")
 
@@ -2400,8 +2441,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]+\\)): "
@@ -2429,10 +2476,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
@@ -2895,17 +2945,13 @@ THRESHOLD, nil otherwise"
              ;; diff it against /dev/null.
              (apply 'vc-do-command
                     "*vc-diff*" 1 "diff" file 'WORKFILE
-                    (append (if (listp diff-switches) 
-                                diff-switches
-                              (list diff-switches)) '("/dev/null")))))
+                     (append diff-switches-list '("/dev/null")))))
        ;; cmp is not yet implemented -- we always do a full diff.
        (apply 'vc-do-command
               "*vc-diff*" 1 "cvs" file 'WORKFILE "diff"
               (and oldvers (concat "-r" oldvers))
               (and newvers (concat "-r" newvers))
-              (if (listp diff-switches)
-                  diff-switches
-                (list diff-switches))))))))
+               diff-switches-list))))))
 
 (defun vc-backend-merge-news (file)
   ;; Merge in any new changes made to FILE.
@@ -2940,6 +2986,7 @@ THRESHOLD, nil otherwise"
              (cond 
               ;; Merge successful, we are in sync with repository now
               ((or (string= (match-string 2) "U")
+                  (string= (match-string 2) "P")
                   ;; Special case: file contents in sync with
                   ;; repository anyhow:
                   (match-string 3))