changeset 106159:f5e8e91b23bf

(vc-deduce-fileset): Allow non-state changing operations from a dired buffer. (vc-dired-deduce-fileset): New function. (vc-root-diff, vc-print-root-log): Use it.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 20 Nov 2009 06:56:16 +0000
parents 734dbd0c890e
children b27aeda9c1fd
files etc/NEWS lisp/ChangeLog lisp/vc.el
diffstat 3 files changed, 21 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/etc/NEWS	Fri Nov 20 06:05:10 2009 +0000
+++ b/etc/NEWS	Fri Nov 20 06:56:16 2009 +0000
@@ -230,6 +230,8 @@
 
 *** When a file is not found, VC will not try to check it out of RCS anymore.
 
+*** Diff and log operations can be used from dired buffers.
+
 *** vc-git changes
 
 **** The new variable vc-git-add-signoff can be used to add a
--- a/lisp/ChangeLog	Fri Nov 20 06:05:10 2009 +0000
+++ b/lisp/ChangeLog	Fri Nov 20 06:56:16 2009 +0000
@@ -1,5 +1,10 @@
 2009-11-20  Dan Nicolaescu  <dann@ics.uci.edu>
 
+	* vc.el (vc-deduce-fileset): Allow non-state changing operations
+	from a dired buffer.
+	(vc-dired-deduce-fileset): New function.
+	(vc-root-diff, vc-print-root-log): Use it.
+
 	* vc-annotate.el (vc-annotate-show-log-revision-at-line): Pass a
 	nil LIMIT argument to vc-print-log-internal.
 
--- a/lisp/vc.el	Fri Nov 20 06:05:10 2009 +0000
+++ b/lisp/vc.el	Fri Nov 20 06:56:16 2009 +0000
@@ -617,7 +617,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
@@ -902,6 +903,10 @@
     (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)
@@ -930,6 +935,12 @@
 	      (list buffer-file-name))))
      (t (error "No fileset is available here")))))
 
+(defun vc-dired-deduce-fileset ()
+  (let ((backend (vc-responsible-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
@@ -1601,6 +1612,7 @@
     (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
@@ -1937,6 +1949,7 @@
      (list nil))))
   (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