From: Eric S. Raymond Date: Tue, 2 Dec 2014 09:38:08 +0000 (-0500) Subject: Clean up a longstanding to-do item. X-Git-Tag: emacs-25.0.90~2635^2~227 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=92411a0d2e8a78e2eb05fa26e8a9bd978d5e01fe;p=emacs.git Clean up a longstanding to-do item. * vc.el (vc-expand-dirs): Now takes a second BACKEND argument, improving behavior on directories using multiple file-oriented VCSEs. --- diff --git a/lisp/vc/vc-rcs.el b/lisp/vc/vc-rcs.el index 40a102789b9..5b375868a80 100644 --- a/lisp/vc/vc-rcs.el +++ b/lisp/vc/vc-rcs.el @@ -158,14 +158,9 @@ For a description of possible values, see `vc-check-master-templates'." (autoload 'vc-expand-dirs "vc") (defun vc-rcs-dir-status (dir update-function) - ;; FIXME: this function should be rewritten or `vc-expand-dirs' - ;; should be changed to take a backend parameter. Using - ;; `vc-expand-dirs' is not TRTD because it returns files from - ;; multiple backends. It should also return 'unregistered files. - ;; Doing individual vc-state calls is painful but there ;; is no better way in RCS-land. - (let ((flist (vc-expand-dirs (list dir))) + (let ((flist (vc-expand-dirs (list dir) 'RCS)) (result nil)) (dolist (file flist) (let ((state (vc-state file)) @@ -319,7 +314,7 @@ whether to remove it." "RCS-specific version of `vc-backend-checkin'." (let (rev (switches (vc-switches 'RCS 'checkin))) ;; Now operate on the files - (dolist (file (vc-expand-dirs files)) + (dolist (file (vc-expand-dirs files 'RCS)) (let ((old-version (vc-working-revision file)) new-version (default-branch (vc-file-getprop file 'vc-rcs-default-branch))) ;; Force branch creation if an appropriate @@ -378,7 +373,7 @@ whether to remove it." "Retrieve a copy of a saved version of FILE. If FILE is a directory, attempt the checkout for all registered files beneath it." (if (file-directory-p file) - (mapc 'vc-rcs-checkout (vc-expand-dirs (list file))) + (mapc 'vc-rcs-checkout (vc-expand-dirs (list file) 'RCS)) (let ((file-buffer (get-file-buffer file)) switches) (message "Checking out %s..." file) @@ -445,7 +440,7 @@ attempt the checkout for all registered files beneath it." expanded to all registered subfiles in them." (if (not files) (error "RCS backend doesn't support directory-level rollback")) - (dolist (file (vc-expand-dirs files)) + (dolist (file (vc-expand-dirs files 'RCS)) (let* ((discard (vc-working-revision file)) (previous (if (vc-rcs-trunk-p discard) "" (vc-branch-part discard))) (config (current-window-configuration)) @@ -481,7 +476,7 @@ expanded to all registered subfiles in them." "Revert FILE to the version it was based on. If FILE is a directory, revert all registered files beneath it." (if (file-directory-p file) - (mapc 'vc-rcs-revert (vc-expand-dirs (list file))) + (mapc 'vc-rcs-revert (vc-expand-dirs (list file) 'RCS)) (vc-do-command "*vc*" 0 "co" (vc-master-name file) "-f" (concat (if (eq (vc-state file) 'edited) "-u" "-r") (vc-working-revision file))))) @@ -524,7 +519,7 @@ The changes are between FIRST-VERSION and SECOND-VERSION." If FILE is a directory, steal the lock on all registered files beneath it. Needs RCS 5.6.2 or later for -M." (if (file-directory-p file) - (mapc 'vc-rcs-steal-lock (vc-expand-dirs (list file))) + (mapc 'vc-rcs-steal-lock (vc-expand-dirs (list file) 'RCS)) (vc-do-command "*vc*" 0 "rcs" (vc-master-name file) "-M" (concat "-u" rev)) ;; Do a real checkout after stealing the lock, so that we see ;; expanded headers. @@ -548,7 +543,7 @@ Needs RCS 5.6.2 or later for -M." (defun vc-rcs-modify-change-comment (files rev comment) "Modify the change comments change on FILES on a specified REV. If FILE is a directory the operation is applied to all registered files beneath it." - (dolist (file (vc-expand-dirs files)) + (dolist (file (vc-expand-dirs files 'RCS)) (vc-do-command "*vc*" 0 "rcs" (vc-master-name file) (concat "-m" rev ":" comment)))) @@ -575,7 +570,7 @@ Remaining arguments are ignored. If FILE is a directory the operation is applied to all registered files beneath it." (vc-do-command (or buffer "*vc*") 0 "rlog" - (mapcar 'vc-master-name (vc-expand-dirs files))) + (mapcar 'vc-master-name (vc-expand-dirs files 'RCS))) (with-current-buffer (or buffer "*vc*") (vc-rcs-print-log-cleanup)) (when limit 'limit-unsupported)) @@ -584,7 +579,7 @@ files beneath it." "Get a difference report using RCS between two sets of files." (apply #'vc-do-command (or buffer "*vc-diff*") (if async 'async 1) - "rcsdiff" (vc-expand-dirs files) + "rcsdiff" (vc-expand-dirs files 'RCS) (append (list "-q" (and oldvers (concat "-r" oldvers)) (and newvers (concat "-r" newvers))) diff --git a/lisp/vc/vc-sccs.el b/lisp/vc/vc-sccs.el index 8a9e0b11289..514748e8283 100644 --- a/lisp/vc/vc-sccs.el +++ b/lisp/vc/vc-sccs.el @@ -135,13 +135,9 @@ For a description of possible values, see `vc-check-master-templates'." (autoload 'vc-expand-dirs "vc") (defun vc-sccs-dir-status (dir update-function) - ;; FIXME: this function should be rewritten, using `vc-expand-dirs' - ;; is not TRTD because it returns files from multiple backends. - ;; It should also return 'unregistered files. - ;; Doing lots of individual VC-state calls is painful, but ;; there is no better option in SCCS-land. - (let ((flist (vc-expand-dirs (list dir))) + (let ((flist (vc-expand-dirs (list dir) 'SCCS)) (result nil)) (dolist (file flist) (let ((state (vc-state file)) @@ -232,7 +228,7 @@ expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile." (defun vc-sccs-checkin (files comment) "SCCS-specific version of `vc-backend-checkin'." - (dolist (file (vc-expand-dirs files)) + (dolist (file (vc-expand-dirs files 'SCCS)) (apply 'vc-sccs-do-command nil 0 "delta" (vc-master-name file) (concat "-y" comment) (vc-switches 'SCCS 'checkin)) @@ -255,7 +251,7 @@ If FILE is a directory, all version-controlled files beneath are checked out. EDITABLE non-nil means that the file should be writable and locked. REV is the revision to check out." (if (file-directory-p file) - (mapc 'vc-sccs-checkout (vc-expand-dirs (list file))) + (mapc 'vc-sccs-checkout (vc-expand-dirs (list file) 'SCCS)) (let ((file-buffer (get-file-buffer file)) switches) (message "Checking out %s..." file) @@ -284,7 +280,7 @@ locked. REV is the revision to check out." (defun vc-sccs-rollback (files) "Roll back, undoing the most recent checkins of FILES. Directories are expanded to all version-controlled subfiles." - (setq files (vc-expand-dirs files)) + (setq files (vc-expand-dirs files 'SCCS)) (if (not files) (error "SCCS backend doesn't support directory-level rollback")) (dolist (file files) @@ -301,7 +297,7 @@ are expanded to all version-controlled subfiles." "Revert FILE to the version it was based on. If FILE is a directory, revert all subfiles." (if (file-directory-p file) - (mapc 'vc-sccs-revert (vc-expand-dirs (list file))) + (mapc 'vc-sccs-revert (vc-expand-dirs (list file) 'SCCS)) (vc-sccs-do-command nil 0 "unget" (vc-master-name file)) (vc-sccs-do-command nil 0 "get" (vc-master-name file)) ;; Checking out explicit revisions is not supported under SCCS, yet. @@ -312,7 +308,7 @@ revert all subfiles." (defun vc-sccs-steal-lock (file &optional rev) "Steal the lock on the current workfile for FILE and revision REV." (if (file-directory-p file) - (mapc 'vc-sccs-steal-lock (vc-expand-dirs (list file))) + (mapc 'vc-sccs-steal-lock (vc-expand-dirs (list file) 'SCCS)) (vc-sccs-do-command nil 0 "unget" (vc-master-name file) "-n" (if rev (concat "-r" rev))) (vc-sccs-do-command nil 0 "get" @@ -320,7 +316,7 @@ revert all subfiles." (defun vc-sccs-modify-change-comment (files rev comment) "Modify (actually, append to) the change comments for FILES on a specified REV." - (dolist (file (vc-expand-dirs files)) + (dolist (file (vc-expand-dirs files 'SCCS)) (vc-sccs-do-command nil 0 "cdc" (vc-master-name file) (concat "-y" comment) (concat "-r" rev)))) @@ -332,7 +328,7 @@ revert all subfiles." (defun vc-sccs-print-log (files buffer &optional _shortlog _start-revision-ignored limit) "Print commit log associated with FILES into specified BUFFER. Remaining arguments are ignored." - (setq files (vc-expand-dirs files)) + (setq files (vc-expand-dirs files 'SCCS)) (vc-sccs-do-command buffer 0 "prs" (mapcar 'vc-master-name files)) (when limit 'limit-unsupported)) @@ -344,7 +340,7 @@ Remaining arguments are ignored." ;; FIXME use sccsdiff if present? (defun vc-sccs-diff (files &optional _async oldvers newvers buffer) "Get a difference report using SCCS between two filesets." - (setq files (vc-expand-dirs files)) + (setq files (vc-expand-dirs files 'SCCS)) (setq oldvers (vc-sccs-lookup-triple (car files) oldvers)) (setq newvers (vc-sccs-lookup-triple (car files) newvers)) (or buffer (setq buffer "*vc-diff*")) diff --git a/lisp/vc/vc-src.el b/lisp/vc/vc-src.el index f3d0585b30c..9e17d058a91 100644 --- a/lisp/vc/vc-src.el +++ b/lisp/vc/vc-src.el @@ -180,13 +180,8 @@ For a description of possible values, see `vc-check-master-templates'." (autoload 'vc-expand-dirs "vc") (defun vc-src-dir-status (dir update-function) - ;; FIXME: this function should be rewritten or `vc-expand-dirs' - ;; should be changed to take a backend parameter. Using - ;; `vc-expand-dirs' is not TRTD because it returns files from - ;; multiple backends. It should also return 'unregistered files. - ;; FIXME: Use one src status -a call for this - (let ((flist (vc-expand-dirs (list dir))) + (let ((flist (vc-expand-dirs (list dir) 'SRC)) (result nil)) (dolist (file flist) (let ((state (vc-state file)) @@ -253,13 +248,13 @@ REV is the revision to check out into WORKFILE." "Revert FILE to the version it was based on. If FILE is a directory, revert all registered files beneath it." (if (file-directory-p file) - (mapc 'vc-src-revert (vc-expand-dirs (list file))) + (mapc 'vc-src-revert (vc-expand-dirs (list file) 'SRC)) (vc-src-command nil file "co"))) (defun vc-src-modify-change-comment (files rev comment) "Modify the change comments change on FILES on a specified REV. If FILE is a directory the operation is applied to all registered files beneath it." - (dolist (file (vc-expand-dirs files)) + (dolist (file (vc-expand-dirs files 'SRC)) (vc-src-command nil file "amend" "-m" comment rev))) ;; History functions @@ -271,7 +266,7 @@ directory the operation is applied to all registered files beneath it." (repeat :tag "Argument List" :value ("") string)) :group 'vc-src) -(defun vc-src-print-log (files buffer &optional shortlog start-revision limit) +(defun vc-src-print-log (files buffer &optional shortlog _start-revision limit) "Print commit log associated with FILES into specified BUFFER. If SHORTLOG is non-nil, use the list method. If START-REVISION is non-nil, it is the newest revision to show. diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index 52deb13e4dd..ad3a2c49735 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -631,9 +631,6 @@ ;; ;;;; Internal cleanups: ;; -;; - vc-expand-dirs should take a backend parameter and only look for -;; files managed by that backend. -;; ;; - Another important thing: merge all the status-like backend operations. ;; We should remove dir-status, state, and dir-status-files, and ;; replace them with just `status' which takes a fileset and a continuation @@ -955,14 +952,14 @@ responsible for FILE is returned." (throw 'found backend)))) (error "No VC backend is responsible for %s" file))) -(defun vc-expand-dirs (file-or-dir-list) +(defun vc-expand-dirs (file-or-dir-list backend) "Expands directories in a file list specification. Within directories, only files already under version control are noticed." (let ((flattened '())) (dolist (node file-or-dir-list) (when (file-directory-p node) (vc-file-tree-walk - node (lambda (f) (when (vc-backend f) (push f flattened))))) + node (lambda (f) (when (eq (vc-backend f) backend) (push f flattened))))) (unless (file-directory-p node) (push node flattened))) (nreverse flattened))) @@ -1000,8 +997,8 @@ Otherwise, throw an error. STATE-MODEL-ONLY-FILES if non-nil, means that the caller needs the FILESET-ONLY-FILES STATE and MODEL info. Otherwise, that part may be skipped. -BEWARE: this function may change the -current buffer." + +BEWARE: this function may change the current buffer." ;; FIXME: OBSERVER is unused. The name is not intuitive and is not ;; documented. It's set to t when called from diff and print-log. (let (backend)