GNU bug report logs - #1046
23.0.60; vc-dir with Subversion

Previous Next

Package: emacs;

Reported by: Nick Roberts <nickrob <at> snap.net.nz>

Date: Sun, 28 Sep 2008 07:40:03 UTC

Severity: normal

Tags: patch

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 1046 in the body.
You can then email your comments to 1046 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1046; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Nick Roberts <nickrob <at> snap.net.nz>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Nick Roberts <nickrob <at> snap.net.nz>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.60; vc-dir with Subversion
Date: Sun, 28 Sep 2008 19:33:03 +1200
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.

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"

-- 
Nick                                           http://www.inet.net.nz/~nickrob




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1046; Package emacs. Full text and rfc822 format available.

Message #8 received at 1046 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Nick Roberts <nickrob <at> snap.net.nz>
Cc: 1046 <at> debbugs.gnu.org
Subject: Re: bug#1046: 23.0.60; vc-dir with Subversion
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."




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1046; Package emacs. Full text and rfc822 format available.

Message #11 received at 1046 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 1046 <at> debbugs.gnu.org
Cc: Nick Roberts <nickrob <at> gnu.org>
Subject: Re: bug#1046: 23.0.60; vc-dir with Subversion
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."




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1046; Package emacs. Full text and rfc822 format available.

Message #14 received at 1046 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 1046 <at> debbugs.gnu.org
Cc: Nick Roberts <nickrob <at> gnu.org>
Subject: Re: bug#1046: 23.0.60; vc-dir with Subversion
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."




Tags added: patch Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Thu, 02 Oct 2008 21:25:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1046; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Nick Roberts <nickrob <at> snap.net.nz>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #21 received at 1046 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Nick Roberts <nickrob <at> snap.net.nz>
To: Glenn Morris <rgm <at> gnu.org>, 1046 <at> debbugs.gnu.org
Subject: Re: bug#1046: 23.0.60; vc-dir with Subversion
Date: Sat, 4 Oct 2008 20:53:57 +1200
 > >> 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.

I've glanced over it and tried it out and it looks good to me.

Thanks,
Nick

 > 
 > *** 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.

Perhaps mention that this function is only in pre Emacs 23.  I'm not sure that
I understand the current naming convention.  Some functions now use 'status':
vc-cvs-dir-status, while others still use 'state': vc-cvs-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)

(let (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)))

(let ((basename (match-string 1))
      (file (expand-file-name basename dir))
      (status (or (vc-file-getprop file 'vc-state)
                  (vc-cvs-parse-entry file t))))

No big deal.  Perhaps a bit clearer.

...

-- 
Nick                                           http://www.inet.net.nz/~nickrob




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1046; Package emacs. Full text and rfc822 format available.

Message #24 received at 1046 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Nick Roberts <nickrob <at> snap.net.nz>
Cc: 1046 <at> debbugs.gnu.org
Subject: Re: bug#1046: 23.0.60; vc-dir with Subversion
Date: Sat, 04 Oct 2008 15:54:00 -0400
Nick Roberts wrote:

> Perhaps mention that this function is only in pre Emacs 23.

OK.

> I'm not sure that I understand the current naming convention. 

Me neither.

> (let (result dirlist)
[...]
> (let ((basename (match-string 1))
>       (file (expand-file-name basename dir))
>       (status (or (vc-file-getprop file 'vc-state)
>                   (vc-cvs-parse-entry file t))))

My personal preference is to use as few lets as possible (in case we
start running out...).




bug closed, send any further explanations to Nick Roberts <nickrob <at> snap.net.nz> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Sat, 04 Oct 2008 20:35:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#1046; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #31 received at 1046 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 1046 <at> debbugs.gnu.org, Nick Roberts <nickrob <at> snap.net.nz>
Subject: Re: bug#1046: 23.0.60; vc-dir with Subversion
Date: Mon, 06 Oct 2008 10:18:45 -0400
>> (let (result dirlist)
> [...]
>> (let ((basename (match-string 1))
>> (file (expand-file-name basename dir))
>> (status (or (vc-file-getprop file 'vc-state)
>> (vc-cvs-parse-entry file t))))

> My personal preference is to use as few lets as possible (in case we
> start running out...).

We still have a large supply of `let's, so you can use them liberally.
Especially if they can eliminate a few pesky `setq's.  They only problem
with `let's as of now is that they eat up indentation space, but it's
rarely a serious problem.


        Stefan




bug archived. Request was from Debbugs Internal Request <don <at> donarmstrong.com> to internal_control <at> emacsbugs.donarmstrong.com. (Mon, 03 Nov 2008 15:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 16 years and 288 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.