Subject: Re: bug#1046: 23.0.60; vc-dir with Subversion

From: Glenn Morris <[email-masked]>
Date: Wed, 01 Oct 2008 19:03:01 -0400

Glenn Morris wrote:

> Nick Roberts wrote:
>
>> In the past I've remarked that with CVS vc-dir ignores vc-stay-local (and
>> vc-cvs-stay-local) and consults the repository, in any case.
>
> Can you file a separate bug for that please, if it still applies?

Never mind. For a limited time only, your initial bug report entitles
you to one complimentary patch for a second issue.

*** vc-cvs.el	7 Sep 2008 20:24:27 -0000	1.148
--- vc-cvs.el	1 Oct 2008 23:02:15 -0000
***************
*** 905,912 ****
--- 905,943 ----
    ;;   (funcall update-function result)))
    )
  
+ ;; Based on vc-cvs-dir-state-heuristic.
+ (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 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."
+   ;; 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.
***************
*** 914,920 ****
    ;; 		  (file-relative-name dir)
    ;; 		  "-f" "-n" "update" "-d" "-P")
    (vc-exec-after
!    `(vc-cvs-after-dir-status (quote ,update-function))))
  
  (defun vc-cvs-file-to-string (file)
    "Read the content of FILE and return it as a string."
--- 945,951 ----
      ;; 		  (file-relative-name dir)
      ;; 		  "-f" "-n" "update" "-d" "-P")
      (vc-exec-after
!      `(vc-cvs-after-dir-status (quote ,update-function)))))
  
  (defun vc-cvs-file-to-string (file)
    "Read the content of FILE and return it as a string."