(vc-cvs-dir-status-heuristic): New function.
authorGlenn Morris <rgm@gnu.org>
Sat, 4 Oct 2008 19:55:00 +0000 (19:55 +0000)
committerGlenn Morris <rgm@gnu.org>
Sat, 4 Oct 2008 19:55:00 +0000 (19:55 +0000)
(vc-cvs-dir-status): Respect vc-stay-local-p.  (Bug#1046)

lisp/ChangeLog
lisp/vc-cvs.el

index f566575..0a0c2df 100644 (file)
@@ -1,3 +1,8 @@
+2008-10-04  Glenn Morris  <rgm@gnu.org>
+
+       * vc-cvs.el (vc-cvs-dir-status-heuristic): New function.
+       (vc-cvs-dir-status): Respect vc-stay-local-p.  (Bug#1046)
+
 2008-10-04  David J. Biesack  <David.Biesack@sas.com>  (tiny change)
 
        * progmodes/antlr-mode.el (antlr-font-lock-additional-keywords):
index 5d2b560..303e6d6 100644 (file)
@@ -6,8 +6,6 @@
 ;; Author:      FSF (see vc.el for full credits)
 ;; Maintainer:  Andre Spiegel <spiegel@gnu.org>
 
-;; $Id$
-
 ;; This file is part of GNU Emacs.
 
 ;; GNU Emacs is free software: you can redistribute it and/or modify
@@ -905,16 +903,48 @@ state."
   ;;   (funcall update-function result)))
   )
 
+;; Based on vc-cvs-dir-state-heuristic from Emacs 22.
+(defun vc-cvs-dir-status-heuristic (dir update-function &optional basedir)
+  "Find the CVS state of all files in DIR, using only local information."
+  (let (file basename status result dirlist)
+    (with-temp-buffer
+      (vc-cvs-get-entries dir)
+      (goto-char (point-min))
+      (while (not (eobp))
+        (if (looking-at "D/\\([^/]*\\)////")
+            (push (expand-file-name (match-string 1) dir) dirlist)
+          ;; CVS-removed files are not taken under VC control.
+          (when (looking-at "/\\([^/]*\\)/[^/-]")
+            (setq basename (match-string 1)
+                  file (expand-file-name basename dir)
+                  status (or (vc-file-getprop file 'vc-state)
+                             (vc-cvs-parse-entry file t)))
+            (unless (eq status 'up-to-date)
+              (push (list (if basedir
+                              (file-relative-name file basedir)
+                            basename)
+                          status) result))))
+        (forward-line 1)))
+    (dolist (subdir dirlist)
+      (setq result (append result
+                           (vc-cvs-dir-status-heuristic subdir nil
+                                                        (or basedir dir)))))
+    (if basedir result
+      (funcall update-function result))))
+
 (defun vc-cvs-dir-status (dir update-function)
   "Create a list of conses (file . state) for DIR."
-  (vc-cvs-command (current-buffer) 'async dir "-f" "status")
-  ;; Alternative implementation: use the "update" command instead of
-  ;; the "status" command.
-  ;; (vc-cvs-command (current-buffer) 'async
-  ;;             (file-relative-name dir)
-  ;;             "-f" "-n" "update" "-d" "-P")
-  (vc-exec-after
-   `(vc-cvs-after-dir-status (quote ,update-function))))
+  ;; FIXME check all files in DIR instead?
+  (if (vc-stay-local-p dir)
+      (vc-cvs-dir-status-heuristic dir update-function)
+    (vc-cvs-command (current-buffer) 'async dir "-f" "status")
+    ;; Alternative implementation: use the "update" command instead of
+    ;; the "status" command.
+    ;; (vc-cvs-command (current-buffer) 'async
+    ;;                   (file-relative-name dir)
+    ;;                   "-f" "-n" "update" "-d" "-P")
+    (vc-exec-after
+     `(vc-cvs-after-dir-status (quote ,update-function)))))
 
 (defun vc-cvs-dir-status-files (dir files default-state update-function)
   "Create a list of conses (file . state) for DIR."