summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric S. Raymond <esr@snark.thyrsus.com>2008-05-15 01:11:23 +0000
committerEric S. Raymond <esr@snark.thyrsus.com>2008-05-15 01:11:23 +0000
commit6986e5c9788dc2051301c2ac8cbf62c4a5038a5c (patch)
tree14d57f7c27159761e42977cde63d17c374f6a760
parentc45fdeecef78893f3cf22f5954c4656e9484177d (diff)
downloademacs-6986e5c9788dc2051301c2ac8cbf62c4a5038a5c.tar.gz
Eliminate exoensive (vc-expand-dirs) calls.
-rw-r--r--lisp/ChangeLog9
-rw-r--r--lisp/vc-dispatcher.el23
-rw-r--r--lisp/vc.el28
3 files changed, 41 insertions, 19 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f4e26605ff9..57ef230910e 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -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.
diff --git a/lisp/vc-dispatcher.el b/lisp/vc-dispatcher.el
index 4082d474150..1bda08c4cff 100644
--- a/lisp/vc-dispatcher.el
+++ b/lisp/vc-dispatcher.el
@@ -1352,19 +1352,30 @@ U - if the cursor is on a file: unmark all the files with the same VC state
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 @@ containing that file. Otherwise, throw an error."
;; 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)
diff --git a/lisp/vc.el b/lisp/vc.el
index d2791587fc3..b332f0e8446 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -992,14 +992,16 @@ Within directories, only files already under version control are noticed."
(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 @@ merge in the changes into your working copy."
(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 @@ Runs the normal hooks `vc-before-checkin-hook' and `vc-checkin-hook'."
"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 @@ returns t if the buffer had changes, nil otherwise."
"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 @@ If WORKING-REVISION is non-nil, leave the point at that revision."
(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 @@ This asks for confirmation if the buffer contents are not identical
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 @@ depending on the underlying version-control system."
(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 @@ changes from the current branch are merged into the working file."
(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)))