GNU bug report logs - #4677
allow VC operations from dired

Previous Next

Package: emacs;

Reported by: Dan Nicolaescu <dann <at> ics.uci.edu>

Date: Thu, 8 Oct 2009 20:30:05 UTC

Severity: normal

Done: Dan Nicolaescu <dann <at> ics.uci.edu>

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 4677 in the body.
You can then email your comments to 4677 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#4677; Package emacs. (Thu, 08 Oct 2009 20:30:05 GMT) Full text and rfc822 format available.

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

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: bug-gnu-emacs <bug-gnu-emacs <at> gnu.org>
Subject: allow VC operations from dired
Date: Thu, 8 Oct 2009 13:19:59 -0700 (PDT)
This patch allows VC operations to be run from dired.
State changing VC operations are not supported. 
(only the various variations of log and diff)

OK to check in?

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.732
diff -u -3 -p -r1.732 vc.el
--- vc.el	3 Oct 2009 18:29:26 -0000	1.732
+++ vc.el	8 Oct 2009 20:17:08 -0000
@@ -634,7 +634,8 @@
 (require 'vc-dispatcher)
 
 (eval-when-compile
-  (require 'cl))
+  (require 'cl)
+  (require 'dired))
 
 (unless (assoc 'vc-parent-buffer minor-mode-alist)
   (setq minor-mode-alist
@@ -889,6 +903,10 @@ current buffer."
     (cond
      ((derived-mode-p 'vc-dir-mode)
       (vc-dir-deduce-fileset state-model-only-files))
+     ((derived-mode-p 'dired-mode)
+      (if observer
+	  (vc-dired-deduce-fileset)
+	(error "State changing VC operations not supported in `dired-mode'")))
      ((setq backend (vc-backend buffer-file-name))
       (if state-model-only-files
 	(list backend (list buffer-file-name)
@@ -921,4 +939,9 @@
 
+
+(defun vc-dired-deduce-fileset ()
+  (list (vc-responsible-backend default-directory)
+	(dired-map-over-marks (dired-get-filename nil t) nil)))
+
 (defun vc-ensure-vc-buffer ()
   "Make sure that the current buffer visits a version-controlled file."
   (cond
@@ -1590,6 +1613,7 @@ saving the buffer."
     (when buffer-file-name (vc-buffer-sync not-urgent))
     (let ((backend
 	   (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
+		 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
 		 (vc-mode (vc-backend buffer-file-name))))
 	  rootdir working-revision)
       (unless backend
@@ -1881,6 +1905,7 @@ If WORKING-REVISION is non-nil, leave th
   (interactive)
   (let ((backend
 	 (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
+	       ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
 	       (vc-mode (vc-backend buffer-file-name))))
 	rootdir working-revision)
     (unless backend




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Mon, 12 Oct 2009 00:05:13 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 12 Oct 2009 00:05:13 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> jurta.org>
To: Dan Nicolaescu <dann <at> ics.uci.edu>
Cc: 4677 <at> debbugs.gnu.org
Subject: Re: bug#4677: allow VC operations from dired
Date: Mon, 12 Oct 2009 02:55:36 +0300
> This patch allows VC operations to be run from dired.
> State changing VC operations are not supported.
> (only the various variations of log and diff)

Thanks, it works right except in one case: when called outside of
a repository controlled directory, it traverses all subdirectories
trying to find a repository (I think traversing subdirectories
makes no sense in this case) and later fails with:

  Wrong type argument: stringp, nil

-- 
Juri Linkov
http://www.jurta.org/emacs/



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Mon, 12 Oct 2009 02:55:06 GMT) Full text and rfc822 format available.

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

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Juri Linkov <juri <at> jurta.org>
Cc: 4677 <at> debbugs.gnu.org
Subject: Re: bug#4677: allow VC operations from dired
Date: Sun, 11 Oct 2009 19:46:24 -0700 (PDT)
Juri Linkov <juri <at> jurta.org> writes:

  > > This patch allows VC operations to be run from dired.
  > > State changing VC operations are not supported.
  > > (only the various variations of log and diff)
  > 
  > Thanks, it works right except in one case: when called outside of
  > a repository controlled directory, it traverses all subdirectories
  > trying to find a repository (I think traversing subdirectories
  > makes no sense in this case) and later fails with:
  > 
  >   Wrong type argument: stringp, nil

Thanks.  Here's an updated patch.

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.732
diff -u -3 -p -u -p -r1.732 vc.el
--- vc.el	3 Oct 2009 18:29:26 -0000	1.732
+++ vc.el	12 Oct 2009 02:41:06 -0000
@@ -634,7 +631,8 @@
 (require 'vc-dispatcher)
 
 (eval-when-compile
-  (require 'cl))
+  (require 'cl)
+  (require 'dired))
 
 (unless (assoc 'vc-parent-buffer minor-mode-alist)
   (setq minor-mode-alist
@@ -889,6 +906,10 @@ current buffer."
     (cond
      ((derived-mode-p 'vc-dir-mode)
       (vc-dir-deduce-fileset state-model-only-files))
+     ((derived-mode-p 'dired-mode)
+      (if observer
+	  (vc-dired-deduce-fileset)
+	(error "State changing VC operations not supported in `dired-mode'")))
      ((setq backend (vc-backend buffer-file-name))
       (if state-model-only-files
 	(list backend (list buffer-file-name)
@@ -921,4 +942,11 @@
 
+
+(defun vc-dired-deduce-fileset ()
+  (let ((backend (vc-backend default-directory)))
+    (unless backend (error "Directory not under VC"))
+    (list backend
+	(dired-map-over-marks (dired-get-filename nil t) nil))))
+
 (defun vc-ensure-vc-buffer ()
   "Make sure that the current buffer visits a version-controlled file."
   (cond
@@ -1590,6 +1618,7 @@ saving the buffer."
     (when buffer-file-name (vc-buffer-sync not-urgent))
     (let ((backend
 	   (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
+		 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
 		 (vc-mode (vc-backend buffer-file-name))))
 	  rootdir working-revision)
       (unless backend
@@ -1881,6 +1913,7 @@ If WORKING-REVISION is non-nil, leave th
   (interactive)
   (let ((backend
 	 (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
+	       ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
 	       (vc-mode (vc-backend buffer-file-name))))
 	rootdir working-revision)
     (unless backend



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Mon, 12 Oct 2009 20:45:15 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Mon, 12 Oct 2009 20:45:16 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> jurta.org>
To: Dan Nicolaescu <dann <at> ics.uci.edu>
Cc: 4677 <at> debbugs.gnu.org
Subject: Re: bug#4677: allow VC operations from dired
Date: Mon, 12 Oct 2009 23:27:09 +0300
>   > > This patch allows VC operations to be run from dired.
>   > > State changing VC operations are not supported.
>   > > (only the various variations of log and diff)
>   >
>   > Thanks, it works right except in one case: when called outside of
>   > a repository controlled directory, it traverses all subdirectories
>   > trying to find a repository (I think traversing subdirectories
>   > makes no sense in this case) and later fails with:
>   >
>   >   Wrong type argument: stringp, nil
>
> Thanks.  Here's an updated patch.

Hmm, now it fails with "Directory not under VC" in all directories
even under version control since (vc-backend default-directory)
always returns nil.

-- 
Juri Linkov
http://www.jurta.org/emacs/



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Mon, 12 Oct 2009 21:00:04 GMT) Full text and rfc822 format available.

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

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Juri Linkov <juri <at> jurta.org>
Cc: 4677 <at> debbugs.gnu.org
Subject: Re: bug#4677: allow VC operations from dired
Date: Mon, 12 Oct 2009 13:51:33 -0700 (PDT)
Juri Linkov <juri <at> jurta.org> writes:

  > >   > > This patch allows VC operations to be run from dired.
  > >   > > State changing VC operations are not supported.
  > >   > > (only the various variations of log and diff)
  > >   >
  > >   > Thanks, it works right except in one case: when called outside of
  > >   > a repository controlled directory, it traverses all subdirectories
  > >   > trying to find a repository (I think traversing subdirectories
  > >   > makes no sense in this case) and later fails with:
  > >   >
  > >   >   Wrong type argument: stringp, nil
  > >
  > > Thanks.  Here's an updated patch.
  > 
  > Hmm, now it fails with "Directory not under VC" in all directories
  > even under version control since (vc-backend default-directory)
  > always returns nil.

Hmm, I should  have said "not really tested".
I guess the first version will have to do then. 

If people want to apply VC operations on non VC controlled directories
it's too bad, they get an error.
Unless someone else wants to work on giving a nicer error in that
case...  I don't really plan to do any further work on this, so if you
want to adopt it and get it checked in, go right ahead.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Tue, 13 Oct 2009 23:10:07 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juri Linkov <juri <at> jurta.org>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Tue, 13 Oct 2009 23:10:07 GMT) Full text and rfc822 format available.

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

From: Juri Linkov <juri <at> jurta.org>
To: Dan Nicolaescu <dann <at> ics.uci.edu>
Cc: 4677 <at> debbugs.gnu.org
Subject: Re: bug#4677: allow VC operations from dired
Date: Wed, 14 Oct 2009 01:38:47 +0300
>   > >   > > This patch allows VC operations to be run from dired.
>   > >   > > State changing VC operations are not supported.
>   > >   > > (only the various variations of log and diff)
>   > >   >
>   > >   > Thanks, it works right except in one case: when called outside of
>   > >   > a repository controlled directory, it traverses all subdirectories
>   > >   > trying to find a repository (I think traversing subdirectories
>   > >   > makes no sense in this case) and later fails with:
>   > >   >
>   > >   >   Wrong type argument: stringp, nil
>   > >
>   > > Thanks.  Here's an updated patch.
>   >
>   > Hmm, now it fails with "Directory not under VC" in all directories
>   > even under version control since (vc-backend default-directory)
>   > always returns nil.
>
> Hmm, I should  have said "not really tested".
> I guess the first version will have to do then.

I see that (vc-backend default-directory) works for directories in CVS,
but always returns nil for git (is it because git is file-oriented?).

OTOH, (vc-call-backend 'git 'root default-directory) works for git,
but (vc-call-backend 'cvs 'root default-directory) fails with

  "Sorry, root is not implemented for cvs"

I can't find a generic function that would work for directories
in all backends.

-- 
Juri Linkov
http://www.jurta.org/emacs/



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Tue, 13 Oct 2009 23:30:06 GMT) Full text and rfc822 format available.

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

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Juri Linkov <juri <at> jurta.org>
Cc: 4677 <at> debbugs.gnu.org
Subject: Re: bug#4677: allow VC operations from dired
Date: Tue, 13 Oct 2009 16:22:25 -0700 (PDT)
Juri Linkov <juri <at> jurta.org> writes:

  > >   > >   > > This patch allows VC operations to be run from dired.
  > >   > >   > > State changing VC operations are not supported.
  > >   > >   > > (only the various variations of log and diff)
  > >   > >   >
  > >   > >   > Thanks, it works right except in one case: when called outside of
  > >   > >   > a repository controlled directory, it traverses all subdirectories
  > >   > >   > trying to find a repository (I think traversing subdirectories
  > >   > >   > makes no sense in this case) and later fails with:
  > >   > >   >
  > >   > >   >   Wrong type argument: stringp, nil
  > >   > >
  > >   > > Thanks.  Here's an updated patch.
  > >   >
  > >   > Hmm, now it fails with "Directory not under VC" in all directories
  > >   > even under version control since (vc-backend default-directory)
  > >   > always returns nil.
  > >
  > > Hmm, I should  have said "not really tested".
  > > I guess the first version will have to do then.
  > 
  > I see that (vc-backend default-directory) works for directories in CVS,
  > but always returns nil for git (is it because git is file-oriented?).

Nothing else uses (vc-backend DIRECTORY), so it's never been made
reliable.

  > OTOH, (vc-call-backend 'git 'root default-directory) works for git,
  > but (vc-call-backend 'cvs 'root default-directory) fails with
  > 
  >   "Sorry, root is not implemented for cvs"
  > 
  > I can't find a generic function that would work for directories
  > in all backends.

There isn't any at the moment. 



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Fri, 23 Oct 2009 18:25:12 GMT) Full text and rfc822 format available.

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

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Juri Linkov <juri <at> jurta.org>
Cc: 4677 <at> debbugs.gnu.org
Subject: Re: bug#4677: allow VC operations from dired
Date: Fri, 23 Oct 2009 11:21:07 -0700 (PDT)
Juri Linkov <juri <at> jurta.org> writes:

  > >   > > This patch allows VC operations to be run from dired.
  > >   > > State changing VC operations are not supported.
  > >   > > (only the various variations of log and diff)
  > >   >
  > >   > Thanks, it works right except in one case: when called outside of
  > >   > a repository controlled directory, it traverses all subdirectories
  > >   > trying to find a repository (I think traversing subdirectories
  > >   > makes no sense in this case) and later fails with:
  > >   >
  > >   >   Wrong type argument: stringp, nil
  > >
  > > Thanks.  Here's an updated patch.
  > 
  > Hmm, now it fails with "Directory not under VC" in all directories
  > even under version control since (vc-backend default-directory)
  > always returns nil.

The version that uses vc-responsible-backend should work correctly now
(i.e. it will throw an error) when used in a non VC controlled directory.



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Thu, 19 Nov 2009 17:00:05 GMT) Full text and rfc822 format available.

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

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 4677 <at> debbugs.gnu.org, Juri Linkov <juri <at> jurta.org>
Subject: Re: bug#4677: allow VC operations from dired
Date: Thu, 19 Nov 2009 08:50:55 -0800 (PST)
Dan Nicolaescu <dann <at> ics.uci.edu> writes:

  > Juri Linkov <juri <at> jurta.org> writes:
  > 
  >   > > This patch allows VC operations to be run from dired.
  >   > > State changing VC operations are not supported.
  >   > > (only the various variations of log and diff)
  >   > 
  >   > Thanks, it works right except in one case: when called outside of
  >   > a repository controlled directory, it traverses all subdirectories
  >   > trying to find a repository (I think traversing subdirectories
  >   > makes no sense in this case) and later fails with:
  >   > 
  >   >   Wrong type argument: stringp, nil
  > 
  > Thanks.  Here's an updated patch.

Stefan, any reason not to install this patch (the up to date version of it)?


  > Index: vc.el
  > ===================================================================
  > RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
  > retrieving revision 1.732
  > diff -u -3 -p -u -p -r1.732 vc.el
  > --- vc.el	3 Oct 2009 18:29:26 -0000	1.732
  > +++ vc.el	12 Oct 2009 02:41:06 -0000
  > @@ -634,7 +631,8 @@
  >  (require 'vc-dispatcher)
  >  
  >  (eval-when-compile
  > -  (require 'cl))
  > +  (require 'cl)
  > +  (require 'dired))
  >  
  >  (unless (assoc 'vc-parent-buffer minor-mode-alist)
  >    (setq minor-mode-alist
  > @@ -889,6 +906,10 @@ current buffer."
  >      (cond
  >       ((derived-mode-p 'vc-dir-mode)
  >        (vc-dir-deduce-fileset state-model-only-files))
  > +     ((derived-mode-p 'dired-mode)
  > +      (if observer
  > +	  (vc-dired-deduce-fileset)
  > +	(error "State changing VC operations not supported in `dired-mode'")))
  >       ((setq backend (vc-backend buffer-file-name))
  >        (if state-model-only-files
  >  	(list backend (list buffer-file-name)
  > @@ -921,4 +942,11 @@
  >  
  > +
  > +(defun vc-dired-deduce-fileset ()
  > +  (let ((backend (vc-backend default-directory)))
  > +    (unless backend (error "Directory not under VC"))
  > +    (list backend
  > +	(dired-map-over-marks (dired-get-filename nil t) nil))))
  > +
  >  (defun vc-ensure-vc-buffer ()
  >    "Make sure that the current buffer visits a version-controlled file."
  >    (cond
  > @@ -1590,6 +1618,7 @@ saving the buffer."
  >      (when buffer-file-name (vc-buffer-sync not-urgent))
  >      (let ((backend
  >  	   (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
  > +		 ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
  >  		 (vc-mode (vc-backend buffer-file-name))))
  >  	  rootdir working-revision)
  >        (unless backend
  > @@ -1881,6 +1913,7 @@ If WORKING-REVISION is non-nil, leave th
  >    (interactive)
  >    (let ((backend
  >  	 (cond ((derived-mode-p 'vc-dir-mode)  vc-dir-backend)
  > +	       ((derived-mode-p 'dired-mode) (vc-responsible-backend default-directory))
  >  	       (vc-mode (vc-backend buffer-file-name))))
  >  	rootdir working-revision)
  >      (unless backend



Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#4677; Package emacs. (Thu, 19 Nov 2009 21:15:06 GMT) 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>. (Thu, 19 Nov 2009 21:15:06 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Dan Nicolaescu <dann <at> ics.uci.edu>
Cc: 4677 <at> debbugs.gnu.org, Juri Linkov <juri <at> jurta.org>
Subject: Re: bug#4677: allow VC operations from dired
Date: Thu, 19 Nov 2009 16:08:13 -0500
> Stefan, any reason not to install this patch (the up to date version of it)?

Not that I know,


        Stefan



Reply sent to Dan Nicolaescu <dann <at> ics.uci.edu>:
You have taken responsibility. (Fri, 20 Nov 2009 16:45:08 GMT) Full text and rfc822 format available.

Notification sent to Dan Nicolaescu <dann <at> ics.uci.edu>:
bug acknowledged by developer. (Fri, 20 Nov 2009 16:45:08 GMT) Full text and rfc822 format available.

Message #43 received at 4677-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Dan Nicolaescu <dann <at> ics.uci.edu>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 4677-done <at> debbugs.gnu.org
Subject: Re: bug#4677: allow VC operations from dired
Date: Fri, 20 Nov 2009 08:37:09 -0800 (PST)
Stefan Monnier <monnier <at> IRO.UMontreal.CA> writes:

  > > Stefan, any reason not to install this patch (the up to date version of it)?
  > 
  > Not that I know,

Done. Thanks.



bug archived. Request was from Debbugs Internal Request <bug-gnu-emacs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 19 Dec 2009 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 15 years and 185 days ago.

Previous Next


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