Bug fix for vc-dispatcher split.
[bpt/emacs.git] / lisp / vc-rcs.el
index 35eba60..84cd589 100644 (file)
@@ -1,7 +1,7 @@
 ;;; vc-rcs.el --- support for RCS version-control
 
 ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-;;   2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+;;   2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author:     FSF (see vc.el for full credits)
 ;; Maintainer: Andre Spiegel <spiegel@gnu.org>
@@ -102,40 +102,52 @@ For a description of possible values, see `vc-check-master-templates'."
 \f
 ;;; Properties of the backend
 
-(defun vc-rcs-revision-granularity ()
-     'file)
+(defun vc-rcs-revision-granularity () 'file)
+
+(defun vc-rcs-checkout-model (files)
+  "RCS-specific version of `vc-checkout-model'."
+  (let ((file (if (consp files) (car files) files))
+        result)
+    (when vc-consult-headers
+      (vc-file-setprop file 'vc-checkout-model nil)
+      (vc-rcs-consult-headers file)
+      (setq result (vc-file-getprop file 'vc-checkout-model)))
+    (or result
+        (progn (vc-rcs-fetch-master-state file)
+               (vc-file-getprop file 'vc-checkout-model)))))
 
 ;;;
 ;;; State-querying functions
 ;;;
 
-;;; The autoload cookie below places vc-rcs-registered directly into
-;;; loaddefs.el, so that vc-rcs.el does not need to be loaded for
-;;; every file that is visited.  The definition is repeated below
-;;; so that Help and etags can find it.
-
-;;;###autoload (defun vc-rcs-registered (f) (vc-default-registered 'RCS f))
-(defun vc-rcs-registered (f) (vc-default-registered 'RCS f))
+;; The autoload cookie below places vc-rcs-registered directly into
+;; loaddefs.el, so that vc-rcs.el does not need to be loaded for
+;; every file that is visited.
+;;;###autoload
+(progn
+(defun vc-rcs-registered (f) (vc-default-registered 'RCS f)))
 
 (defun vc-rcs-state (file)
   "Implementation of `vc-state' for RCS."
-  (or (boundp 'vc-rcs-headers-result)
-      (and vc-consult-headers
-           (vc-rcs-consult-headers file)))
-  (let ((state
-         ;; vc-working-revision might not be known; in that case the
-         ;; property is nil.  vc-rcs-fetch-master-state knows how to
-         ;; handle that.
-         (vc-rcs-fetch-master-state file
-                                    (vc-file-getprop file
-                                                     'vc-working-revision))))
-    (if (not (eq state 'up-to-date))
-        state
-      (if (vc-workfile-unchanged-p file)
-          'up-to-date
-        (if (eq (vc-checkout-model file) 'locking)
-            'unlocked-changes
-          'edited)))))
+  (if (not (vc-rcs-registered file))
+      'unregistered
+    (or (boundp 'vc-rcs-headers-result)
+       (and vc-consult-headers
+            (vc-rcs-consult-headers file)))
+    (let ((state
+          ;; vc-working-revision might not be known; in that case the
+          ;; property is nil.  vc-rcs-fetch-master-state knows how to
+          ;; handle that.
+          (vc-rcs-fetch-master-state file
+                                     (vc-file-getprop file
+                                                      'vc-working-revision))))
+      (if (not (eq state 'up-to-date))
+         state
+       (if (vc-workfile-unchanged-p file)
+           'up-to-date
+         (if (eq (vc-rcs-checkout-model (list file)) 'locking)
+             'unlocked-changes
+           'edited))))))
 
 (defun vc-rcs-state-heuristic (file)
   "State heuristic for RCS."
@@ -168,7 +180,7 @@ For a description of possible values, see `vc-check-master-templates'."
                    (vc-file-setprop file 'vc-checkout-model 'locking)
                    'up-to-date)
                   ((string-match ".rw..-..-." permissions)
-                  (if (eq (vc-checkout-model file) 'locking)
+                  (if (eq (vc-rcs-checkout-model file) 'locking)
                       (if (file-ownership-preserved-p file)
                           'edited
                         owner-name)
@@ -181,6 +193,17 @@ For a description of possible values, see `vc-check-master-templates'."
                    (vc-rcs-state file))))
         (vc-rcs-state file)))))
 
+(defun vc-rcs-dir-status (dir update-function)
+  ;; Doing individual vc-state calls is painful but tgere
+  ;; is no better way in RCS-land. 
+  (let ((flist (vc-expand-dirs (list dir)))
+       (result nil))
+    (dolist (file flist)
+      (let ((state (vc-state file))
+           (frel (file-relative-name file)))
+       (push (list frel state) result)))
+    (funcall update-function result)))
+
 (defun vc-rcs-working-revision (file)
   "RCS-specific version of `vc-working-revision'."
   (or (and vc-consult-headers
@@ -206,17 +229,6 @@ When VERSION is given, perform check for that version."
               (vc-insert-file (vc-name file) "^desc")
               (vc-rcs-find-most-recent-rev (vc-branch-part version))))))
 
-(defun vc-rcs-checkout-model (file)
-  "RCS-specific version of `vc-checkout-model'."
-  (let (result)
-    (when vc-consult-headers
-      (vc-file-setprop file 'vc-checkout-model nil)
-      (vc-rcs-consult-headers file)
-      (setq result (vc-file-getprop file 'vc-checkout-model)))
-    (or result
-        (progn (vc-rcs-fetch-master-state file)
-               (vc-file-getprop file 'vc-checkout-model)))))
-
 (defun vc-rcs-workfile-unchanged-p (file)
   "RCS-specific implementation of `vc-workfile-unchanged-p'."
   ;; Try to use rcsdiff --brief.  If rcsdiff does not understand that,
@@ -262,9 +274,11 @@ the RCS command (in that order).
 
 Automatically retrieve a read-only version of the file with keywords
 expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
-  (let ((subdir (expand-file-name "RCS" (file-name-directory file))))
+  (let (subdir name)
     (dolist (file files)
-      (and (not (file-exists-p subdir))
+      (and (not (file-exists-p
+                (setq subdir (expand-file-name "RCS"
+                                               (file-name-directory file)))))
           (not (directory-files (file-name-directory file)
                                 nil ".*,v$" t))
           (yes-or-no-p "Create RCS subdirectory? ")
@@ -277,26 +291,26 @@ expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
             (vc-switches 'RCS 'register))
       ;; parse output to find master file name and workfile version
       (with-current-buffer "*vc*"
-        (goto-char (point-min))
-        (let ((name (if (looking-at (concat "^\\(.*\\)  <--  "
-                                            (file-name-nondirectory file)))
-                        (match-string 1))))
-          (if (not name)
-              ;; if we couldn't find the master name,
-              ;; run vc-rcs-registered to get it
-              ;; (will be stored into the vc-name property)
-              (vc-rcs-registered file)
-            (vc-file-setprop file 'vc-name
-                             (if (file-name-absolute-p name)
-                                 name
-                               (expand-file-name
-                                name
-                                (file-name-directory file))))))
-        (vc-file-setprop file 'vc-working-revision
-                         (if (re-search-forward
-                              "^initial revision: \\([0-9.]+\\).*\n"
-                              nil t)
-                             (match-string 1)))))))
+       (goto-char (point-min))
+       (if (not (setq name
+                      (if (looking-at (concat "^\\(.*\\)  <--  "
+                                              (file-name-nondirectory file)))
+                          (match-string 1))))
+           ;; if we couldn't find the master name,
+           ;; run vc-rcs-registered to get it
+           ;; (will be stored into the vc-name property)
+           (vc-rcs-registered file)
+         (vc-file-setprop file 'vc-name
+                          (if (file-name-absolute-p name)
+                              name
+                            (expand-file-name
+                             name
+                             (file-name-directory file))))))
+      (vc-file-setprop file 'vc-working-revision
+                      (if (re-search-forward
+                           "^initial revision: \\([0-9.]+\\).*\n"
+                           nil t)
+                          (match-string 1))))))
 
 (defun vc-rcs-responsible-p (file)
   "Return non-nil if RCS thinks it would be responsible for registering FILE."
@@ -305,7 +319,7 @@ expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile."
 
 (defun vc-rcs-receive-file (file rev)
   "Implementation of receive-file for RCS."
-  (let ((checkout-model (vc-checkout-model file)))
+  (let ((checkout-model (vc-rcs-checkout-model (list file))))
     (vc-rcs-register file rev "")
     (when (eq checkout-model 'implicit)
       (vc-rcs-set-non-strict-locking file))
@@ -416,7 +430,7 @@ whether to remove it."
                   nil 0 "co" (vc-name file)
                   ;; If locking is not strict, force to overwrite
                   ;; the writable workfile.
-                  (if (eq (vc-checkout-model file) 'implicit) "-f")
+                  (if (eq (vc-rcs-checkout-model (list file)) 'implicit) "-f")
                   (if editable "-l")
                    (if (stringp rev)
                        ;; a literal revision was specified
@@ -461,7 +475,7 @@ whether to remove it."
                 (previous (if (vc-trunk-p discard) "" (vc-branch-part discard)))
                 (config (current-window-configuration))
                 (done nil))
-           (if (null (yes-or-no-p (format "Remove version %s from %s history? " 
+           (if (null (yes-or-no-p (format "Remove version %s from %s history? "
                                           discard file)))
                (error "Aborted"))
            (message "Removing revision %s from %s." discard file)
@@ -510,6 +524,11 @@ Needs RCS 5.6.2 or later for -M."
   ;; expanded headers.
   (vc-do-command nil 0 "co" (vc-name file) "-f" (concat "-l" rev)))
 
+(defun vc-rcs-modify-change-comment (files rev comment)
+  "Modify the change comments change on FILES on a specified REV."
+  (dolist (file files)
+    (vc-do-command nil 0 "rcs" (vc-name file)
+                  (concat "-m" rev ":" comment))))
 
 \f
 ;;;
@@ -522,7 +541,7 @@ Needs RCS 5.6.2 or later for -M."
 
 (defun vc-rcs-diff (files &optional oldvers newvers buffer)
   "Get a difference report using RCS between two sets of files."
-  (apply 'vc-do-command (or buffer "*vc-diff*") 
+  (apply 'vc-do-command (or buffer "*vc-diff*")
         1              ;; Always go synchronous, the repo is local
         "rcsdiff" (vc-expand-dirs files)
          (append (list "-q"
@@ -787,6 +806,9 @@ systime, or nil if there is none.  Also, reposition point."
 ;;; Internal functions
 ;;;
 
+(defun vc-rcs-root (dir)
+  (vc-find-root dir "RCS" t))
+
 (defun vc-rcs-workfile-is-newer (file)
   "Return non-nil if FILE is newer than its RCS master.
 This likely means that FILE has been changed with respect
@@ -867,11 +889,11 @@ file."
               ;; workfile version is latest on branch
               'up-to-date
             ;; workfile version is not latest on branch
-            'needs-patch))
+            'needs-update))
         ;; locked by the calling user
         ((and (stringp locking-user)
               (string= locking-user (vc-user-login-name file)))
-         (if (or (eq (vc-checkout-model file) 'locking)
+         (if (or (eq (vc-rcs-checkout-model (list file)) 'locking)
                  workfile-is-latest
                  (vc-rcs-latest-on-branch-p file working-revision))
              'edited