unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1046: 23.0.60; vc-dir with Subversion
@ 2008-09-28  7:33 Nick Roberts
  2008-10-01  7:28 ` Glenn Morris
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Roberts @ 2008-09-28  7:33 UTC (permalink / raw)
  To: emacs-pretest-bug


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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#1046: 23.0.60; vc-dir with Subversion
  2008-09-28  7:33 bug#1046: 23.0.60; vc-dir with Subversion Nick Roberts
@ 2008-10-01  7:28 ` Glenn Morris
  2008-10-01 16:05   ` Glenn Morris
  2008-10-01 23:03   ` Glenn Morris
  0 siblings, 2 replies; 7+ messages in thread
From: Glenn Morris @ 2008-10-01  7:28 UTC (permalink / raw)
  To: Nick Roberts; +Cc: 1046

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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#1046: 23.0.60; vc-dir with Subversion
  2008-10-01  7:28 ` Glenn Morris
@ 2008-10-01 16:05   ` Glenn Morris
  2008-10-01 23:03   ` Glenn Morris
  1 sibling, 0 replies; 7+ messages in thread
From: Glenn Morris @ 2008-10-01 16:05 UTC (permalink / raw)
  To: 1046; +Cc: Nick Roberts


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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#1046: 23.0.60; vc-dir with Subversion
  2008-10-01  7:28 ` Glenn Morris
  2008-10-01 16:05   ` Glenn Morris
@ 2008-10-01 23:03   ` Glenn Morris
  2008-10-04  8:53     ` Nick Roberts
  1 sibling, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2008-10-01 23:03 UTC (permalink / raw)
  To: 1046; +Cc: Nick Roberts

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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#1046: 23.0.60; vc-dir with Subversion
  2008-10-01 23:03   ` Glenn Morris
@ 2008-10-04  8:53     ` Nick Roberts
  2008-10-04 19:54       ` Glenn Morris
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Roberts @ 2008-10-04  8:53 UTC (permalink / raw)
  To: Glenn Morris, 1046

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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#1046: 23.0.60; vc-dir with Subversion
  2008-10-04  8:53     ` Nick Roberts
@ 2008-10-04 19:54       ` Glenn Morris
  2008-10-06 14:18         ` Stefan Monnier
  0 siblings, 1 reply; 7+ messages in thread
From: Glenn Morris @ 2008-10-04 19:54 UTC (permalink / raw)
  To: Nick Roberts; +Cc: 1046

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






^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#1046: 23.0.60; vc-dir with Subversion
  2008-10-04 19:54       ` Glenn Morris
@ 2008-10-06 14:18         ` Stefan Monnier
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Monnier @ 2008-10-06 14:18 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 1046

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






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2008-10-06 14:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-28  7:33 bug#1046: 23.0.60; vc-dir with Subversion Nick Roberts
2008-10-01  7:28 ` Glenn Morris
2008-10-01 16:05   ` Glenn Morris
2008-10-01 23:03   ` Glenn Morris
2008-10-04  8:53     ` Nick Roberts
2008-10-04 19:54       ` Glenn Morris
2008-10-06 14:18         ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).