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
;; 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)
(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."
(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
"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"
"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
(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
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
(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))
(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)))