In vc, abolish the dir-status method.

This commit is contained in:
Eric S. Raymond 2014-12-02 10:10:55 -05:00
parent dd601050e7
commit b1a765b3a8
13 changed files with 68 additions and 89 deletions

View file

@ -1,5 +1,8 @@
2014-12-02 Eric S. Raymond <esr@snark.thyrsus.com> 2014-12-02 Eric S. Raymond <esr@snark.thyrsus.com>
* vc.el, all backends: API simplification: Abolish dir-status.
It's replaced by dir-status-files.
* vc.el, all backends: API simplification: Remove 4th * vc.el, all backends: API simplification: Remove 4th
'default-state' argument from vc-dir-status files and its backend 'default-state' argument from vc-dir-status files and its backend
methods - no backend method ever set it. It was used only in the methods - no backend method ever set it. It was used only in the

View file

@ -310,10 +310,11 @@ Only the value `maybe' can be trusted :-(."
'up-to-date 'up-to-date
'edited))))))))) 'edited)))))))))
;; -dir-status called from vc-dir, which loads vc, which loads vc-dispatcher. ;; dir-status-files called from vc-dir, which loads vc,
;; which loads vc-dispatcher.
(declare-function vc-exec-after "vc-dispatcher" (code)) (declare-function vc-exec-after "vc-dispatcher" (code))
(defun vc-arch-dir-status (dir callback) (defun vc-arch-dir-status-files (dir _files callback)
"Run 'tla inventory' for DIR and pass results to CALLBACK. "Run 'tla inventory' for DIR and pass results to CALLBACK.
CALLBACK expects (ENTRIES &optional MORE-TO-COME); see CALLBACK expects (ENTRIES &optional MORE-TO-COME); see
`vc-dir-refresh'." `vc-dir-refresh'."

View file

@ -967,9 +967,9 @@ stream. Standard error output is discarded."
(forward-line)) (forward-line))
(funcall update-function result))) (funcall update-function result)))
(defun vc-bzr-dir-status (dir update-function) (defun vc-bzr-dir-status-files (dir files update-function)
"Return a list of conses (file . state) for DIR." "Return a list of conses (file . state) for DIR."
(vc-bzr-command "status" (current-buffer) 'async dir "-v" "-S") (apply 'vc-bzr-command "status" (current-buffer) 'async dir "-v" "-S" files)
(vc-run-delayed (vc-run-delayed
(vc-bzr-after-dir-status update-function (vc-bzr-after-dir-status update-function
;; "bzr status" results are relative to ;; "bzr status" results are relative to
@ -981,13 +981,6 @@ stream. Standard error output is discarded."
;; frob the results accordingly. ;; frob the results accordingly.
(file-relative-name dir (vc-bzr-root dir))))) (file-relative-name dir (vc-bzr-root dir)))))
(defun vc-bzr-dir-status-files (dir files update-function)
"Return a list of conses (file . state) for DIR."
(apply 'vc-bzr-command "status" (current-buffer) 'async dir "-v" "-S" files)
(vc-run-delayed
(vc-bzr-after-dir-status update-function
(file-relative-name dir (vc-bzr-root dir)))))
(defvar vc-bzr-shelve-map (defvar vc-bzr-shelve-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))
;; Turn off vc-dir marking ;; Turn off vc-dir marking

View file

@ -1069,13 +1069,14 @@ state."
(if basedir result (if basedir result
(funcall update-function result)))) (funcall update-function result))))
(defun vc-cvs-dir-status (dir update-function) (defun vc-cvs-dir-status-files (dir files update-function)
"Create a list of conses (file . state) for DIR." "Create a list of conses (file . state) for FILES in DIR.
;; FIXME check all files in DIR instead? Query all files in DIR if files is nil."
(let ((local (vc-cvs-stay-local-p dir))) (let ((local (vc-cvs-stay-local-p dir)))
(if (and local (not (eq local 'only-file))) (if (and (not files) local (not (eq local 'only-file)))
(vc-cvs-dir-status-heuristic dir update-function) (vc-cvs-dir-status-heuristic dir update-function)
(vc-cvs-command (current-buffer) 'async dir "-f" "status") (if (not files) (setq files (vc-expand-dirs (list dir) 'CVS)))
(vc-cvs-command (current-buffer) 'async dir "-f" "status" files)
;; Alternative implementation: use the "update" command instead of ;; Alternative implementation: use the "update" command instead of
;; the "status" command. ;; the "status" command.
;; (vc-cvs-command (current-buffer) 'async ;; (vc-cvs-command (current-buffer) 'async
@ -1084,12 +1085,6 @@ state."
(vc-run-delayed (vc-run-delayed
(vc-cvs-after-dir-status update-function))))) (vc-cvs-after-dir-status update-function)))))
(defun vc-cvs-dir-status-files (dir files update-function)
"Create a list of conses (file . state) for DIR."
(apply 'vc-cvs-command (current-buffer) 'async dir "-f" "status" files)
(vc-run-delayed
(vc-cvs-after-dir-status update-function)))
(defun vc-cvs-file-to-string (file) (defun vc-cvs-file-to-string (file)
"Read the content of FILE and return it as a string." "Read the content of FILE and return it as a string."
(condition-case nil (condition-case nil

View file

@ -1097,7 +1097,7 @@ Throw an error if another update process is in progress."
(setq default-directory def-dir) (setq default-directory def-dir)
(erase-buffer) (erase-buffer)
(vc-call-backend (vc-call-backend
backend 'dir-status def-dir backend 'dir-status-files def-dir nil
(lambda (entries &optional more-to-come) (lambda (entries &optional more-to-come)
;; ENTRIES is a list of (FILE VC_STATE EXTRA) items. ;; ENTRIES is a list of (FILE VC_STATE EXTRA) items.
;; If MORE-TO-COME is true, then more updates will come from ;; If MORE-TO-COME is true, then more updates will come from

View file

@ -50,8 +50,7 @@
;; STATE-QUERYING FUNCTIONS ;; STATE-QUERYING FUNCTIONS
;; * registered (file) OK ;; * registered (file) OK
;; * state (file) OK ;; * state (file) OK
;; * dir-status (dir update-function) OK ;; - dir-status-files (dir files uf) OK
;; - dir-status-files (dir files uf) NOT NEEDED
;; * working-revision (file) OK ;; * working-revision (file) OK
;; - latest-on-branch-p (file) NOT NEEDED ;; - latest-on-branch-p (file) NOT NEEDED
;; * checkout-model (files) OK ;; * checkout-model (files) OK
@ -474,15 +473,11 @@ or an empty string if none."
(vc-run-delayed (vc-run-delayed
(vc-git-after-dir-status-stage stage files update-function))) (vc-git-after-dir-status-stage stage files update-function)))
(defun vc-git-dir-status (_dir update-function) (defun vc-git-dir-status-files (_dir files update-function)
"Return a list of (FILE STATE EXTRA) entries for DIR." "Return a list of (FILE STATE EXTRA) entries for DIR."
;; Further things that would have to be fixed later: ;; Further things that would have to be fixed later:
;; - how to handle unregistered directories ;; - how to handle unregistered directories
;; - how to support vc-dir on a subdir of the project tree ;; - how to support vc-dir on a subdir of the project tree
(vc-git-dir-status-goto-stage 'update-index nil update-function))
(defun vc-git-dir-status-files (_dir files update-function)
"Return a list of (FILE STATE EXTRA) entries for FILES in DIR."
(vc-git-dir-status-goto-stage 'update-index files update-function)) (vc-git-dir-status-goto-stage 'update-index files update-function))
(defvar vc-git-stash-map (defvar vc-git-stash-map

View file

@ -43,7 +43,6 @@
;; STATE-QUERYING FUNCTIONS ;; STATE-QUERYING FUNCTIONS
;; * registered (file) OK ;; * registered (file) OK
;; * state (file) OK ;; * state (file) OK
;; - dir-status (dir update-function) OK
;; - dir-status-files (dir files uf) OK ;; - dir-status-files (dir files uf) OK
;; - dir-extra-headers (dir) OK ;; - dir-extra-headers (dir) OK
;; - dir-printer (fileinfo) OK ;; - dir-printer (fileinfo) OK
@ -613,11 +612,6 @@ REV is the revision to check out into WORKFILE."
;; Follows vc-exec-after. ;; Follows vc-exec-after.
(declare-function vc-set-async-update "vc-dispatcher" (process-buffer)) (declare-function vc-set-async-update "vc-dispatcher" (process-buffer))
(defun vc-hg-dir-status (dir update-function)
(vc-hg-command (current-buffer) 'async dir "status" "-C")
(vc-run-delayed
(vc-hg-after-dir-status update-function)))
(defun vc-hg-dir-status-files (dir files update-function) (defun vc-hg-dir-status-files (dir files update-function)
(apply 'vc-hg-command (current-buffer) 'async dir "status" "-mardui" "-C" files) (apply 'vc-hg-command (current-buffer) 'async dir "status" "-mardui" "-C" files)
(vc-run-delayed (vc-run-delayed

View file

@ -126,10 +126,11 @@ If nil, use the value of `vc-diff-switches'. If t, use no switches."
((match-end 2) (push (list (match-string 3) 'added) result)))) ((match-end 2) (push (list (match-string 3) 'added) result))))
(funcall update-function result))) (funcall update-function result)))
;; -dir-status called from vc-dir, which loads vc, which loads vc-dispatcher. ;; dir-status-files called from vc-dir, which loads vc,
;; which loads vc-dispatcher.
(declare-function vc-exec-after "vc-dispatcher" (code)) (declare-function vc-exec-after "vc-dispatcher" (code))
(defun vc-mtn-dir-status (dir update-function) (defun vc-mtn-dir-status-files (dir _files update-function)
(vc-mtn-command (current-buffer) 'async dir "status") (vc-mtn-command (current-buffer) 'async dir "status")
(vc-run-delayed (vc-run-delayed
(vc-mtn-after-dir-status update-function))) (vc-mtn-after-dir-status update-function)))

View file

@ -157,12 +157,10 @@ For a description of possible values, see `vc-check-master-templates'."
(autoload 'vc-expand-dirs "vc") (autoload 'vc-expand-dirs "vc")
(defun vc-rcs-dir-status (dir update-function) (defun vc-rcs-dir-status-files (dir files update-function)
;; Doing individual vc-state calls is painful but there (if (not files) (setq files (vc-expand-dirs (list dir) 'RCS)))
;; is no better way in RCS-land. (let ((result nil))
(let ((flist (vc-expand-dirs (list dir) 'RCS)) (dolist (file files)
(result nil))
(dolist (file flist)
(let ((state (vc-state file)) (let ((state (vc-state file))
(frel (file-relative-name file))) (frel (file-relative-name file)))
(when (and (eq (vc-backend file) 'RCS) (when (and (eq (vc-backend file) 'RCS)

View file

@ -134,12 +134,10 @@ For a description of possible values, see `vc-check-master-templates'."
(autoload 'vc-expand-dirs "vc") (autoload 'vc-expand-dirs "vc")
(defun vc-sccs-dir-status (dir update-function) (defun vc-sccs-dir-status-files (dir files update-function)
;; Doing lots of individual VC-state calls is painful, but (if (not files) (setq files (vc-expand-dirs (list dir) 'RCS)))
;; there is no better option in SCCS-land. (let ((result nil))
(let ((flist (vc-expand-dirs (list dir) 'SCCS)) (dolist (file files)
(result nil))
(dolist (file flist)
(let ((state (vc-state file)) (let ((state (vc-state file))
(frel (file-relative-name file))) (frel (file-relative-name file)))
(when (and (eq (vc-backend file) 'SCCS) (when (and (eq (vc-backend file) 'SCCS)

View file

@ -31,8 +31,7 @@
;; STATE-QUERYING FUNCTIONS ;; STATE-QUERYING FUNCTIONS
;; * registered (file) OK ;; * registered (file) OK
;; * state (file) OK ;; * state (file) OK
;; * dir-status (dir update-function) OK ;; - dir-status-files (dir files uf) OK
;; - dir-status-files (dir files uf) ??
;; - dir-extra-headers (dir) NOT NEEDED ;; - dir-extra-headers (dir) NOT NEEDED
;; - dir-printer (fileinfo) ?? ;; - dir-printer (fileinfo) ??
;; * working-revision (file) OK ;; * working-revision (file) OK
@ -179,11 +178,11 @@ For a description of possible values, see `vc-check-master-templates'."
(autoload 'vc-expand-dirs "vc") (autoload 'vc-expand-dirs "vc")
(defun vc-src-dir-status (dir update-function) (defun vc-src-dir-status-files (dir files update-function)
;; FIXME: Use one src status -a call for this ;; FIXME: Use one src status -a call for this
(let ((flist (vc-expand-dirs (list dir) 'SRC)) (if (not files) (setq files (vc-expand-dirs (list dir) 'RCS)))
(result nil)) (let ((result nil))
(dolist (file flist) (dolist (file files)
(let ((state (vc-state file)) (let ((state (vc-state file))
(frel (file-relative-name file))) (frel (file-relative-name file)))
(when (and (eq (vc-backend file) 'SRC) (when (and (eq (vc-backend file) 'SRC)

View file

@ -195,22 +195,20 @@ If you want to force an empty list of arguments, use t."
(setq result (cons (list filename state) result))))) (setq result (cons (list filename state) result)))))
(funcall callback result))) (funcall callback result)))
;; -dir-status called from vc-dir, which loads vc, which loads vc-dispatcher. ;; dir-status-files called from vc-dir, which loads vc,
;; which loads vc-dispatcher.
(declare-function vc-exec-after "vc-dispatcher" (code)) (declare-function vc-exec-after "vc-dispatcher" (code))
(defun vc-svn-dir-status (_dir callback) (autoload 'vc-expand-dirs "vc")
(defun vc-svn-dir-status-files (dir files callback)
"Run 'svn status' for DIR and update BUFFER via CALLBACK. "Run 'svn status' for DIR and update BUFFER via CALLBACK.
CALLBACK is called as (CALLBACK RESULT BUFFER), where CALLBACK is called as (CALLBACK RESULT BUFFER), where
RESULT is a list of conses (FILE . STATE) for directory DIR." RESULT is a list of conses (FILE . STATE) for directory DIR."
;; FIXME should this rather be all the files in dir? (if (not files) (setq files (vc-expand-dirs (list dir) 'SVN)))
(vc-svn-command (current-buffer) 'async nil "status" "-u") (vc-svn-command (current-buffer) 'async nil "status" "-u" files)
(vc-run-delayed (vc-svn-after-dir-status callback))) (vc-run-delayed (vc-svn-after-dir-status callback)))
(defun vc-svn-dir-status-files (_dir files callback)
(apply 'vc-svn-command (current-buffer) 'async nil "status" files)
(vc-run-delayed
(vc-svn-after-dir-status callback)))
(defun vc-svn-dir-extra-headers (_dir) (defun vc-svn-dir-extra-headers (_dir)
"Generate extra status headers for a Subversion working copy." "Generate extra status headers for a Subversion working copy."
(let (process-file-side-effects) (let (process-file-side-effects)

View file

@ -130,31 +130,32 @@
;; reliable state computation; it is usually called immediately after ;; reliable state computation; it is usually called immediately after
;; C-x v v. ;; C-x v v.
;; ;;
;; - dir-status (dir update-function) ;; - dir-status-files (dir files update-function)
;; ;;
;; Produce RESULT: a list of lists of the form (FILE VC-STATE EXTRA) ;; Produce RESULT: a list of lists of the form (FILE VC-STATE EXTRA)
;; for the files in DIR. ;; for FILES in DIR. If FILES is nil. report on all files in DIR.
;; (It is OK, though possibly inefficient, to ignore the FILES argument
;; and always report on all files in DIR.)
;;
;; EXTRA can be used for backend specific information about FILE. ;; EXTRA can be used for backend specific information about FILE.
;; If a command needs to be run to compute this list, it should be ;; If a command needs to be run to compute this list, it should be
;; run asynchronously using (current-buffer) as the buffer for the ;; run asynchronously using (current-buffer) as the buffer for the
;; command. When RESULT is computed, it should be passed back by ;; command.
;; doing: (funcall UPDATE-FUNCTION RESULT nil). ;;
;; If the backend uses a process filter, hence it produces partial results, ;; When RESULT is computed, it should be passed back by doing:
;; they can be passed back by doing: ;; (funcall UPDATE-FUNCTION RESULT nil). If the backend uses a
;; (funcall UPDATE-FUNCTION RESULT t) ;; process filter, hence it produces partial results, they can be
;; and then do a (funcall UPDATE-FUNCTION RESULT nil) ;; passed back by doing: (funcall UPDATE-FUNCTION RESULT t) and then
;; when all the results have been computed. ;; do a (funcall UPDATE-FUNCTION RESULT nil) when all the results
;; have been computed.
;;
;; To provide more backend specific functionality for `vc-dir' ;; To provide more backend specific functionality for `vc-dir'
;; the following functions might be needed: `dir-extra-headers', ;; the following functions might be needed: `dir-extra-headers',
;; `dir-printer', `extra-dir-menu' and `dir-status-files'. ;; `dir-printer', and `extra-dir-menu'.
;; ;;
;; - dir-status-files (dir files update-function) ;; This function should report on all requested files, including
;; ;; up-to-date or ignored files. If it is not provided, the default is to
;; This function is identical to dir-status except that it should ;; consider that all files are in 'up-to-date state.
;; only report status for the specified FILES. Also it needs to
;; report on all requested files, including up-to-date or ignored
;; files. If not provided, the default is to consider that the files
;; are in 'up-to-date state.
;; ;;
;; - dir-extra-headers (dir) ;; - dir-extra-headers (dir)
;; ;;
@ -389,7 +390,6 @@
;; the backend command. It should return a status of either 0 (no ;; the backend command. It should return a status of either 0 (no
;; differences found), or 1 (either non-empty diff or the diff is ;; differences found), or 1 (either non-empty diff or the diff is
;; run asynchronously). ;; run asynchronously).
;; ;;
;; - revision-completion-table (files) ;; - revision-completion-table (files)
;; ;;
@ -580,6 +580,9 @@
;; - INCOMPATIBLE CHANGE: The old fourth 'default-state' argument of ;; - INCOMPATIBLE CHANGE: The old fourth 'default-state' argument of
;; vc-dir-status-files is gone; none of the back ends actually used it. ;; vc-dir-status-files is gone; none of the back ends actually used it.
;; ;;
;; - vc-dir-status is no longer a public method; it has been replaced
;; by vc-dir-status-files.
;;
;; - vc-state-heuristic is no longer a public method (the CVS backend ;; - vc-state-heuristic is no longer a public method (the CVS backend
;; retains it as a private one). ;; retains it as a private one).
;; ;;
@ -632,12 +635,13 @@
;; ;;
;;;; Internal cleanups: ;;;; Internal cleanups:
;; ;;
;; - Another important thing: merge all the status-like backend operations. ;; - Another important thing: merge all the status-like backend
;; We should remove dir-status, state, and dir-status-files, and ;; operations. We should remove dir-status-files and state and
;; replace them with just `status' which takes a fileset and a continuation ;; replace them with just `status' which takes a fileset and a
;; (like dir-status) and returns a buffer in which the process(es) are run ;; continuation (like dir-status-files) and returns a buffer in
;; (or nil if it worked synchronously). Hopefully we can define the old ;; which the process(es) are run (or nil if it worked
;; 4 operations in term of this one. ;; synchronously). Hopefully we can define the old operations in
;; term of this one.
;; ;;
;;;; Unify two different versions of the amend capability ;;;; Unify two different versions of the amend capability
;; ;;