changeset 94984:b8d24d4a4bdc

Eliminate exoensive (vc-expand-dirs) calls.
author Eric S. Raymond <esr@snark.thyrsus.com>
date Thu, 15 May 2008 01:11:23 +0000
parents fa401b47e382
children 78ec9a87d0e5
files lisp/ChangeLog lisp/vc-dispatcher.el lisp/vc.el
diffstat 3 files changed, 41 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu May 15 01:01:05 2008 +0000
+++ b/lisp/ChangeLog	Thu May 15 01:11:23 2008 +0000
@@ -1,3 +1,12 @@
+2008-05-14  Eric S. Raymond  <esr@snark.thyrsus.com>
+
+	* vc-dispatcher.el (vc-dispatcher-selection): Change the returned
+	list to a cons so the caller can get back both expanded and
+	unexpanded filesets.
+	* vc.el (vc-deduce-fileseset, vc-next-action, vc-diff-internal,
+	vc-merge, vc-version-diff, vc-print-log, vc-revert, vc-rollback):
+	Change handling of selection-set returns as required.
+
 2008-05-15  John Paul Wallington  <jpw@pobox.com>
 
 	* ibuffer.el (ibuffer-assert-ibuffer-mode): New defsubst.
--- a/lisp/vc-dispatcher.el	Thu May 15 01:01:05 2008 +0000
+++ b/lisp/vc-dispatcher.el	Thu May 15 01:11:23 2008 +0000
@@ -1352,19 +1352,30 @@
     member))
 
 (defun vc-dispatcher-selection-set (&optional observer)
-  "Deduce a set of files to which to apply an operation.  Return the fileset.
+  "Deduce a set of files to which to apply an operation.  Return a cons
+cell (SELECTION . FILESET), where SELECTION is what the user chose 
+and FILES is the flist with any directories replaced by the listed files
+within them.
+
 If we're in a directory display, the fileset is the list of marked files (if
 there is one) else the file on the curreent line.  If not in a directory
 display, but the current buffer visits a file, the fileset is a singleton
 containing that file.  Otherwise, throw an error."
-  (let ((files
+  (let ((selection
          (cond
           ;; Browsing with vc-dir
           ((vc-dispatcher-browsing)
-           (or (vc-dir-marked-files) (list (vc-dir-current-file))))
+	   ;; If no files are marked, temporatrily mark current file
+	   ;; and choose on that basis (so we get subordinate files)
+	   (if (not (vc-dir-marked-files))
+		 (prog2
+		   (vc-dir-mark-file)
+		   (cons (vc-dir-marked-files) (vc-dir-marked-only-files))
+		   (vc-dir-unmark-all-files t))
+	     (cons (vc-dir-marked-files) (vc-dir-marked-only-files))))
           ;; Visiting an eligible file
           ((buffer-file-name)
-           (list buffer-file-name))
+           (cons (list buffer-file-name) (list buffer-file-name)))
           ;; No eligible file -- if there's a parent buffer, deduce from there
           ((and vc-parent-buffer (or (buffer-file-name vc-parent-buffer)
                                      (with-current-buffer vc-parent-buffer
@@ -1378,8 +1389,8 @@
     ;; buffers visiting the fileset don't match the on-disk contents.
     (if (not observer)
 	(save-some-buffers
-	 nil (lambda () (vc-dispatcher-in-fileset-p files))))
-    files))
+	 nil (lambda () (vc-dispatcher-in-fileset-p (cdr selection)))))
+    selection))
 
 (provide 'vc-dispatcher)
 
--- a/lisp/vc.el	Thu May 15 01:01:05 2008 +0000
+++ b/lisp/vc.el	Thu May 15 01:11:23 2008 +0000
@@ -992,14 +992,16 @@
 (defun vc-deduce-fileset (&optional observer)
   "Deduce a set of files and a backend to which to apply an operation and
 the common state of the fileset.  Return (BACKEND . FILESET)."
-  (let* ((fileset (vc-dispatcher-selection-set observer))
+  (let* ((selection (vc-dispatcher-selection-set observer))
+	 (raw (car selection))		;; Selection as user made it
+	 (cooked (cdr selection))	;; Files only
          ;; FIXME: Store the backend in a buffer-local variable.
          (backend (if (vc-derived-from-dir-mode (current-buffer))
                       (vc-responsible-backend default-directory)
-                    (assert (and (= 1 (length fileset))
-                                 (not (file-directory-p (car fileset)))))
-                    (vc-backend (car fileset)))))
-	(cons backend fileset)))
+                    (assert (and (= 1 (length raw))
+                                 (not (file-directory-p (car raw)))))
+                    (vc-backend (car cooked)))))
+	(cons backend selection)))
 
 (defun vc-ensure-vc-buffer ()
   "Make sure that the current buffer visits a version-controlled file."
@@ -1071,8 +1073,8 @@
   (interactive "P")
   (let* ((vc-fileset (vc-deduce-fileset))
          (backend (car vc-fileset))
-	 (files (cdr vc-fileset))
-         (fileset-only-files (vc-expand-dirs files))
+	 (files (cadr vc-fileset))
+         (fileset-only-files (cddr vc-fileset))
          ;; FIXME: We used to call `vc-recompute-state' here.
          (state (vc-state (car fileset-only-files)))
          ;; The backend should check that the checkout-model is consistent
@@ -1484,7 +1486,7 @@
   "Report diffs between two revisions of a fileset.
 Diff output goes to the *vc-diff* buffer.  The function
 returns t if the buffer had changes, nil otherwise."
-  (let* ((files (cdr vc-fileset))
+  (let* ((files (cadr vc-fileset))
 	 (messages (cons (format "Finding changes in %s..."
                                  (vc-delistify files))
                          (format "No changes between %s and %s"
@@ -1550,7 +1552,7 @@
   "Report diffs between revisions of the fileset in the repository history."
   (interactive
    (let* ((vc-fileset (vc-deduce-fileset t))
-	  (files (cdr vc-fileset))
+	  (files (cadr vc-fileset))
           (backend (car vc-fileset))
 	  (first (car files))
 	  (completion-table
@@ -2113,7 +2115,7 @@
   (interactive)
   (let* ((vc-fileset (vc-deduce-fileset t))
 	 (backend (car vc-fileset))
-	 (files (cdr vc-fileset))
+	 (files (cadr vc-fileset))
 	 (working-revision (or working-revision (vc-working-revision (car files)))))
     ;; Don't switch to the output buffer before running the command,
     ;; so that any buffer-local settings in the vc-controlled
@@ -2143,7 +2145,7 @@
 to the working revision (except for keyword expansion)."
   (interactive)
   (let* ((vc-fileset (vc-deduce-fileset))
-	 (files (cdr vc-fileset)))
+	 (files (cadr vc-fileset)))
     ;; If any of the files is visited by the current buffer, make
     ;; sure buffer is saved.  If the user says `no', abort since
     ;; we cannot show the changes and ask for confirmation to
@@ -2175,7 +2177,7 @@
   (interactive)
   (let* ((vc-fileset (vc-deduce-fileset))
 	 (backend (car vc-fileset))
-	 (files (cdr vc-fileset))
+	 (files (cadr vc-fileset))
 	 (granularity (vc-call-backend backend 'revision-granularity)))
     (unless (vc-find-backend-function backend 'rollback)
       (error "Rollback is not supported in %s" backend))
@@ -2233,7 +2235,7 @@
   (interactive)
   (let* ((vc-fileset (vc-deduce-fileset))
 	 (backend (car vc-fileset))
-	 (files (cdr vc-fileset)))
+	 (files (cadr vc-fileset)))
     (dolist (file files)
       (when (let ((buf (get-file-buffer file)))
 	      (and buf (buffer-modified-p buf)))