master 11a1cb7445d: Remove up-to-date items from FILES part of VC-Dir deduced fileset
Sean Whitton <[email protected]>
| Newsgroups | gmane.emacs.diffs |
|---|---|
| Message-ID | <[email protected]> |
branch: master commit 11a1cb7445ddd0796a41e751aeeb145d289cb24c Author: Sean Whitton <[email protected]> Commit: Sean Whitton <[email protected]> Remove up-to-date items from FILES part of VC-Dir deduced fileset * lisp/vc/vc-dir.el (vc-dir--only-files-state-and-model): Rename to ... (vc-dir--fileset): ... this. Return a five-element list. Remove up-to-date items appearing literally in FILES. (vc-dir-root-next-action, vc-dir-deduce-fileset): Update usage. --- lisp/vc/vc-dir.el | 57 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/lisp/vc/vc-dir.el b/lisp/vc/vc-dir.el index 814e9a6335b..9ac29746e22 100644 --- a/lisp/vc/vc-dir.el +++ b/lisp/vc/vc-dir.el @@ -1132,18 +1132,16 @@ This command ignores VC-Dir marks and the position of point. When the VC-Dir's root directory is the repository root (as it usually is), this command is useful to check in all local changes at once." (interactive) - (let* ((only-files-list - (cl-loop for crt = (ewoc-nth vc-ewoc 0) - then (ewoc-next vc-ewoc crt) - while crt - for data = (ewoc-data crt) - unless (vc-dir-fileinfo->directory data) collect - (cons (expand-file-name (vc-dir-fileinfo->name data)) - (vc-dir-fileinfo->state data)))) - (vc-buffer-overriding-fileset - `(,vc-dir-backend - (,default-directory) - . ,(vc-dir--only-files-state-and-model only-files-list)))) + (let ((vc-buffer-overriding-fileset + (vc-dir--fileset (list default-directory) + (cl-loop + for crt = (ewoc-nth vc-ewoc 0) + then (ewoc-next vc-ewoc crt) + while crt + for data = (ewoc-data crt) + unless (vc-dir-fileinfo->directory data) collect + (cons (expand-file-name (vc-dir-fileinfo->name data)) + (vc-dir-fileinfo->state data)))))) (vc-next-action nil))) (defun vc-dir-clean-files () @@ -1934,11 +1932,14 @@ state of item at point, if any." (declare-function vc-only-files-state-and-model "vc") -(defun vc-dir--only-files-state-and-model (only-files-list) +(defun vc-dir--fileset (files only-files-list) "Call `vc-only-files-state-and-model' as appropriate for VC-Dir buffers. Offer to call `vc-dir-hide-up-to-date' if that might be useful. -If we did, remove up-to-date items from ONLY-FILES-LIST before passing -to `vc-only-files-state-and-model'. +If we did, remove up-to-date items from FILES and ONLY-FILES-LIST before +passing the latter to `vc-only-files-state-and-model'. From FILES, only +remove items appearing literally: a directory named in FILES containing +up-to-date items won't be removed. +Return a list of the form returned by `vc-deduce-fileset'. There's usually no action to be taken on `up-to-date' or `ignored' files, but a new user may include these in their VC-Dir fileset without @@ -1949,17 +1950,26 @@ for them, and also filter ONLY-FILES-LIST so as not to include entries in those states. Only do this if there are both up-to-date and non-up-to-date files in ONLY-FILES-LIST (in case we add a VC next action for `up-to-date' and/or `ignored' files at some point)." + ;; We want to remove items explicitly named in FILES because some VCS + ;; commands override files being ignored if they are named explicitly. + ;; For example, 'hg commit -A foo' will commit foo even if foo is + ;; ignored! By contrast, 'hg commit -A dir-containing-foo' won't, so + ;; we don't need to worry about somehow removing dir-containing-foo + ;; from FILES without otherwise changing the meaning of FILES. (let (up-to-date other) (dolist (entry only-files-list) (push entry (if (memq (cdr entry) vc-dir--up-to-date-states) up-to-date other))) - (vc-only-files-state-and-model - (if (or (null up-to-date) (null other) - (not (y-or-n-p "Clear up-to-date items before proceeding?"))) - only-files-list - (vc-dir-hide-up-to-date) - other) - vc-dir-backend))) + (cons vc-dir-backend + (if (or (null up-to-date) (null other) + (not (y-or-n-p "Clear up-to-date items before proceeding?"))) + (cons files + (vc-only-files-state-and-model only-files-list + vc-dir-backend)) + (vc-dir-hide-up-to-date) + (cons (cl-set-difference files (mapcar #'car up-to-date) + :test #'equal) + (vc-only-files-state-and-model other vc-dir-backend)))))) (defun vc-dir-deduce-fileset (&optional state-model-only-files) (let (files only-files-list) @@ -1972,8 +1982,7 @@ for `up-to-date' and/or `ignored' files at some point)." (when state-model-only-files (setq only-files-list (vc-dir-child-files-and-states)))) (if state-model-only-files - (cl-list* vc-dir-backend files - (vc-dir--only-files-state-and-model only-files-list)) + (vc-dir--fileset files only-files-list) (list vc-dir-backend files)))) ;;;###autoload