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

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

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?

> I now see that with SVN, vc-dir also ignores vc-stay-local but this time
> never consults the repository.
>
> I'm not sure if it worked with vc-directory, but for this function, the
> command "svn log -u" was used when vc-stay-local was nil.  In Emacs 23.0.60
> it always just sends "svn log"

You meant "svn status", not "log". Anyway, here is an attempt at a
simple-minded patch.

*** vc-svn.el.~1.96.~	2008-09-09 19:28:20.000000000 -0700
--- vc-svn.el	2008-10-01 00:26:48.000000000 -0700
***************
*** 146,152 ****
    "SVN-specific state heuristic."
    (vc-svn-state file 'local))
  
! (defun vc-svn-after-dir-status (callback)
    (let ((state-map '((?A . added)
                       (?C . conflict)
                       (?D . removed)
--- 146,152 ----
    "SVN-specific state heuristic."
    (vc-svn-state file 'local))
  
! (defun vc-svn-after-dir-status (callback &optional remote)
    (let ((state-map '((?A . added)
                       (?C . conflict)
                       (?D . removed)
***************
*** 156,166 ****
                       (?? . unregistered)
                       ;; This is what vc-svn-parse-status does.
                       (?~ . edited)))
         result)
      (goto-char (point-min))
!     (while (re-search-forward "^\\(.\\)..... \\(.*\\)$" nil t)
!       (let ((state (cdr (assq (aref (match-string 1) 0) state-map)))
!            (filename (match-string 2)))
         (when state
           (setq result (cons (list filename state) result)))))
      (funcall callback result)))
--- 156,170 ----
                       (?? . unregistered)
                       ;; This is what vc-svn-parse-status does.
                       (?~ . edited)))
+ 	(re (if remote "^\\(.\\)..... \\([ *]\\) +[-0-9]+ +\\(.*\\)$"
+ 	      "^\\(.\\)....\\(.\\) \\(.*\\)$"))
         result)
      (goto-char (point-min))
!     (while (re-search-forward re nil t)
!       (let ((state (or (cdr (assq (aref (match-string 1) 0) state-map))
! 		       (and remote (string-equal (match-string 2) "*")
! 			    'needs-merge)))
! 	    (filename (match-string 3)))
         (when state
           (setq result (cons (list filename state) result)))))
      (funcall callback result)))
***************
*** 169,177 ****
    "Run 'svn status' for DIR and update BUFFER via CALLBACK.
  CALLBACK is called as (CALLBACK RESULT BUFFER), where
  RESULT is a list of conses (FILE . STATE) for directory DIR."
!   (vc-svn-command (current-buffer) 'async nil "status")
    (vc-exec-after
!    `(vc-svn-after-dir-status (quote ,callback))))
  
  (defun vc-svn-status-extra-headers (dir)
    "Generate extra status headers for a Subversion working copy."
--- 173,184 ----
    "Run 'svn status' for DIR and update BUFFER via CALLBACK.
  CALLBACK is called as (CALLBACK RESULT BUFFER), where
  RESULT is a list of conses (FILE . STATE) for directory DIR."
!   ;; FIXME should this rather be all the files in dir?
!   (let ((remote (not (vc-stay-local-p dir))))
!     (vc-svn-command (current-buffer) 'async nil "status"
! 		    (if remote "-u"))
      (vc-exec-after
!      `(vc-svn-after-dir-status (quote ,callback) ,remote))))
  
  (defun vc-svn-status-extra-headers (dir)
    "Generate extra status headers for a Subversion working copy."