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

From: Glenn Morris <[email-masked]>
Date: Wed, 01 Oct 2008 12:05:02 -0400

Slight revision to distinguish needs-update and needs-merge.
Perhaps there are other states.

*** vc-svn.el	7 Sep 2008 20:24:29 -0000	1.96
--- vc-svn.el	1 Oct 2008 16:00:28 -0000
***************
*** 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,173 ----
                       (?? . unregistered)
                       ;; This is what vc-svn-parse-status does.
                       (?~ . edited)))
+ 	(re (if remote "^\\(.\\)..... \\([ *]\\) +[-0-9]+ +\\(.*\\)$"
+ 	      ;; Subexp 2 is a dummy in this case, so the numbers match.
+ 	      "^\\(.\\)....\\(.\\) \\(.*\\)$"))
         result)
      (goto-char (point-min))
!     (while (re-search-forward re nil t)
        (let ((state (cdr (assq (aref (match-string 1) 0) state-map)))
! 	    (filename (match-string 3)))
! 	(and remote (string-equal (match-string 2) "*")
! 	     (setq state (if (eq state 'edited)
! 			     'needs-merge
! 			   'needs-update)))
         (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."
--- 176,187 ----
    "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."