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>
* vc.el, all backends: API simplification: Abolish dir-status.
It's replaced by dir-status-files.
* vc.el, all backends: API simplification: Remove 4th
'default-state' argument from vc-dir-status files and its backend
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
'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))
(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.
CALLBACK expects (ENTRIES &optional MORE-TO-COME); see
`vc-dir-refresh'."

View file

@ -967,9 +967,9 @@ stream. Standard error output is discarded."
(forward-line))
(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."
(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-bzr-after-dir-status update-function
;; "bzr status" results are relative to
@ -981,13 +981,6 @@ stream. Standard error output is discarded."
;; frob the results accordingly.
(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
(let ((map (make-sparse-keymap)))
;; Turn off vc-dir marking

View file

@ -1069,13 +1069,14 @@ state."
(if basedir result
(funcall update-function result))))
(defun vc-cvs-dir-status (dir update-function)
"Create a list of conses (file . state) for DIR."
;; FIXME check all files in DIR instead?
(defun vc-cvs-dir-status-files (dir files update-function)
"Create a list of conses (file . state) for FILES in DIR.
Query all files in DIR if files is nil."
(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-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
;; the "status" command.
;; (vc-cvs-command (current-buffer) 'async
@ -1084,12 +1085,6 @@ state."
(vc-run-delayed
(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)
"Read the content of FILE and return it as a string."
(condition-case nil

View file

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

View file

@ -50,8 +50,7 @@
;; STATE-QUERYING FUNCTIONS
;; * registered (file) OK
;; * state (file) OK
;; * dir-status (dir update-function) OK
;; - dir-status-files (dir files uf) NOT NEEDED
;; - dir-status-files (dir files uf) OK
;; * working-revision (file) OK
;; - latest-on-branch-p (file) NOT NEEDED
;; * checkout-model (files) OK
@ -474,15 +473,11 @@ or an empty string if none."
(vc-run-delayed
(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."
;; Further things that would have to be fixed later:
;; - how to handle unregistered directories
;; - 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))
(defvar vc-git-stash-map

View file

@ -43,7 +43,6 @@
;; STATE-QUERYING FUNCTIONS
;; * registered (file) OK
;; * state (file) OK
;; - dir-status (dir update-function) OK
;; - dir-status-files (dir files uf) OK
;; - dir-extra-headers (dir) OK
;; - dir-printer (fileinfo) OK
@ -613,11 +612,6 @@ REV is the revision to check out into WORKFILE."
;; Follows vc-exec-after.
(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)
(apply 'vc-hg-command (current-buffer) 'async dir "status" "-mardui" "-C" files)
(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))))
(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))
(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-run-delayed
(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")
(defun vc-rcs-dir-status (dir update-function)
;; Doing individual vc-state calls is painful but there
;; is no better way in RCS-land.
(let ((flist (vc-expand-dirs (list dir) 'RCS))
(result nil))
(dolist (file flist)
(defun vc-rcs-dir-status-files (dir files update-function)
(if (not files) (setq files (vc-expand-dirs (list dir) 'RCS)))
(let ((result nil))
(dolist (file files)
(let ((state (vc-state file))
(frel (file-relative-name file)))
(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")
(defun vc-sccs-dir-status (dir update-function)
;; 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) 'SCCS))
(result nil))
(dolist (file flist)
(defun vc-sccs-dir-status-files (dir files update-function)
(if (not files) (setq files (vc-expand-dirs (list dir) 'RCS)))
(let ((result nil))
(dolist (file files)
(let ((state (vc-state file))
(frel (file-relative-name file)))
(when (and (eq (vc-backend file) 'SCCS)

View file

@ -31,8 +31,7 @@
;; STATE-QUERYING FUNCTIONS
;; * registered (file) OK
;; * state (file) OK
;; * dir-status (dir update-function) OK
;; - dir-status-files (dir files uf) ??
;; - dir-status-files (dir files uf) OK
;; - dir-extra-headers (dir) NOT NEEDED
;; - dir-printer (fileinfo) ??
;; * working-revision (file) OK
@ -179,11 +178,11 @@ For a description of possible values, see `vc-check-master-templates'."
(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
(let ((flist (vc-expand-dirs (list dir) 'SRC))
(result nil))
(dolist (file flist)
(if (not files) (setq files (vc-expand-dirs (list dir) 'RCS)))
(let ((result nil))
(dolist (file files)
(let ((state (vc-state file))
(frel (file-relative-name file)))
(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)))))
(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))
(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.
CALLBACK is called as (CALLBACK RESULT BUFFER), where
RESULT is a list of conses (FILE . STATE) for directory DIR."
;; FIXME should this rather be all the files in dir?
(vc-svn-command (current-buffer) 'async nil "status" "-u")
(if (not files) (setq files (vc-expand-dirs (list dir) 'SVN)))
(vc-svn-command (current-buffer) 'async nil "status" "-u" files)
(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)
"Generate extra status headers for a Subversion working copy."
(let (process-file-side-effects)

View file

@ -130,31 +130,32 @@
;; reliable state computation; it is usually called immediately after
;; 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)
;; 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.
;; If a command needs to be run to compute this list, it should be
;; run asynchronously using (current-buffer) as the buffer for the
;; command. When RESULT is computed, it should be passed back by
;; doing: (funcall UPDATE-FUNCTION RESULT nil).
;; If the backend uses a process filter, hence it produces partial results,
;; they can be passed back by doing:
;; (funcall UPDATE-FUNCTION RESULT t)
;; and then do a (funcall UPDATE-FUNCTION RESULT nil)
;; when all the results have been computed.
;; command.
;;
;; When RESULT is computed, it should be passed back by doing:
;; (funcall UPDATE-FUNCTION RESULT nil). If the backend uses a
;; process filter, hence it produces partial results, they can be
;; passed back by doing: (funcall UPDATE-FUNCTION RESULT t) and then
;; do a (funcall UPDATE-FUNCTION RESULT nil) when all the results
;; have been computed.
;;
;; To provide more backend specific functionality for `vc-dir'
;; 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 is identical to dir-status except that it should
;; 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.
;; This function should report on all requested files, including
;; up-to-date or ignored files. If it is not provided, the default is to
;; consider that all files are in 'up-to-date state.
;;
;; - dir-extra-headers (dir)
;;
@ -389,7 +390,6 @@
;; the backend command. It should return a status of either 0 (no
;; differences found), or 1 (either non-empty diff or the diff is
;; run asynchronously).
;;
;; - revision-completion-table (files)
;;
@ -580,6 +580,9 @@
;; - 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 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
;; retains it as a private one).
;;
@ -632,12 +635,13 @@
;;
;;;; Internal cleanups:
;;
;; - 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
;; (like dir-status) and returns a buffer in which the process(es) are run
;; (or nil if it worked synchronously). Hopefully we can define the old
;; 4 operations in term of this one.
;; - Another important thing: merge all the status-like backend
;; operations. We should remove dir-status-files and state and
;; replace them with just `status' which takes a fileset and a
;; continuation (like dir-status-files) and returns a buffer in
;; which the process(es) are run (or nil if it worked
;; synchronously). Hopefully we can define the old operations in
;; term of this one.
;;
;;;; Unify two different versions of the amend capability
;;