From 722f037fc8a4d7e22d700de4504b7db7a9927450 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 28 Dec 2007 18:16:55 +0000 Subject: [PATCH] * vc-hooks.el (vc-state): Document new 'ignored and 'unregistered states. and the new return-value convention. These are not actually used yet, just set. * vc-svn.el (vc-svn-parse-status): Set 'ignored and 'unregistered states when appropriate. * vc-hg.el (vc-hg-state,vc-hg-dir-state): Set 'ignored and 'unregistered' when appropriate. * vc-git.el: Document that we don't set the new states yet. * vc.el (vc-dired-state-info): Display 'unregistered and 'ignored states. * vc-cvs.el (vc-cvs-parse-status): Set the 'ignored state when appropriate. * vc-bzr.el (vc-bzr-dir-state): Set 'ignored and 'unregistered' when appropriate. --- lisp/ChangeLog | 25 ++++++++++++++++++++++++- lisp/vc-bzr.el | 7 +++++-- lisp/vc-cvs.el | 7 ++++++- lisp/vc-git.el | 3 +++ lisp/vc-hg.el | 10 ++++++---- lisp/vc-hooks.el | 22 +++++++++++++++++++++- lisp/vc-svn.el | 4 ++++ lisp/vc.el | 5 ++++- 8 files changed, 73 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index eefada19f60..b68e3dedd35 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -17,7 +17,30 @@ can get extremely large. * vc-cvs.el, vc-svn.el: Simplify backend dired-state-info - functions so they don't do work that the default one can do instead + functions so they don't do work that the default one can do + instead. Also, give the default useful behavior on 'added. + + * vc-hooks.el (vc-state): Document new 'ignored and 'unregistered + states. and the new return-value convention. These are not + actually used yet, just set. + + * vc-svn.el (vc-svn-parse-status): Set 'ignored and 'unregistered + states when appropriate. + + * vc-hg.el (vc-hg-state,vc-hg-dir-state): Set 'ignored and + 'unregistered' when appropriate. + + * vc-git.el: Document that we don't set the new states yet. + + * vc.el (vc-dired-state-info): Display 'unregistered and + 'ignored states. + + * vc-cvs.el (vc-cvs-parse-status): Set the 'ignored state when + appropriate. + + * vc-bzr.el (vc-bzr-dir-state): Set 'ignored and + 'unregistered' when appropriate. + 2007-12-28 Nick Roberts diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el index c87424fb8f6..01599c91dff 100644 --- a/lisp/vc-bzr.el +++ b/lisp/vc-bzr.el @@ -533,8 +533,11 @@ Optional argument LOCALP is always ignored." ((looking-at "^renamed") (setq current-vc-state 'edited) (setq current-bzr-state 'renamed)) - ((looking-at "^\\(unknown\\|ignored\\)") - (setq current-vc-state nil) + ((looking-at "^ignored") + (setq current-vc-state 'ignored) + (setq current-bzr-state 'not-versioned)) + ((looking-at "^unknown") + (setq current-vc-state 'unregistered) (setq current-bzr-state 'not-versioned)) ((looking-at " ") ;; file names are indented by two spaces diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el index 3728d725478..c3aff66588b 100644 --- a/lisp/vc-cvs.el +++ b/lisp/vc-cvs.el @@ -818,9 +818,14 @@ For an empty string, nil is returned (invalid CVS root)." (defun vc-cvs-parse-status (&optional full) "Parse output of \"cvs status\" command in the current buffer. Set file properties accordingly. Unless FULL is t, parse only -essential information." +essential information. Note that this can never set the 'ignored +state." (let (file status) (goto-char (point-min)) + (while (looking-at "? \\(.*\\)") + (setq file (expand-file-name (match-string 1))) + (vc-file-setprop file 'vc-state 'unregistered) + (forward-line 1)) (if (re-search-forward "^File: " nil t) (cond ((looking-at "no file") nil) diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 722e352f4f0..7895251be0e 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -143,6 +143,7 @@ (defun vc-git-state (file) "Git-specific version of `vc-state'." + ;; FIXME: This can't set 'ignored yet (vc-git--call nil "add" "--refresh" "--" (file-relative-name file)) (let ((diff (vc-git--run-command-string file "diff-index" "-z" "HEAD" "--"))) (if (and diff (string-match ":[0-7]\\{6\\} [0-7]\\{6\\} [0-9a-f]\\{40\\} [0-9a-f]\\{40\\} [ADMU]\0[^\0]+\0" @@ -151,6 +152,8 @@ 'up-to-date))) (defun vc-git-dir-state (dir) + "Git-specific version of `dir-state'." + ;; FIXME: This can't set 'ignored yet (with-temp-buffer (buffer-disable-undo) ;; Because these buffers can get huge (vc-git-command (current-buffer) nil nil "ls-files" "-t" "-c" "-m" "-o") diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el index 5c2cc35229d..592bccaf517 100644 --- a/lisp/vc-hg.el +++ b/lisp/vc-hg.el @@ -173,8 +173,9 @@ (cond ((eq state ?A) 'edited) ((eq state ?M) 'edited) - ((eq state ?R) nil) - ((eq state ??) nil) + ((eq state ?I) 'ignored) + ((eq state ?R) 'unregistered) + ((eq state ??) 'unregistered) (t 'up-to-date)))))))) (defun vc-hg-dir-state (dir) @@ -194,7 +195,6 @@ ;; The rest of the possible states in "hg status" output: ;; R = removed ;; ! = deleted, but still tracked - ;; ? = not tracked ;; should not show up in vc-dired, so don't deal with them ;; here. ((eq status-char ?A) @@ -202,9 +202,11 @@ (vc-file-setprop file 'vc-state 'edited)) ((eq status-char ?M) (vc-file-setprop file 'vc-state 'edited)) + ((eq status-char ?I) + (vc-file-setprop file 'vc-state 'ignored)) ((eq status-char ??) (vc-file-setprop file 'vc-backend 'none) - (vc-file-setprop file 'vc-state 'nil))) + (vc-file-setprop file 'vc-state 'unregistered))) (forward-line))))) (defun vc-hg-working-revision (file) diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index 3657878232e..3d589e117c8 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -501,7 +501,27 @@ For registered files, the value returned is one of: 'added Scheduled to go into the repository on the next commit. Often represented by vc-working-revision = \"0\" in VCSes - with monotonic IDs like Subversion and Mercxurial." + with monotonic IDs like Subversion and Mercurial. + + 'ignored The file showed up in a dir-state listing with a flag + indicating the version-control system is ignoring it, + Note: This property is not set reliably (some VCSes + don't have useful directory-status commands) so assume + that any file with vc-state nil might be ignorable + without VC knowing it. + + 'unregistered The file showed up in a dir-state listing with a flag + indicating that it is not under version control. + Note: This property is not set reliably (some VCSes + don't have useful directory-status commands) so assume + that any file with vc-state nil might be unregistered + without VC knowing it. + +A return of nil from this function means we have no information on the +status of this file. +" + ;; Note: in Emacs 22 and older, return of nil meant the file was unregistered. + ;; This is potentially a source of backward-compatibility bugs. ;; FIXME: New (sub)states needed (?): ;; - `conflict' (i.e. `edited' with conflict markers) diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el index 7ce1634d45c..ced4c941b55 100644 --- a/lisp/vc-svn.el +++ b/lisp/vc-svn.el @@ -578,6 +578,10 @@ information about FILENAME and return its status." (if (eq (char-after (match-beginning 1)) ?*) 'needs-merge 'edited)) + ((eq status ?I) + (vc-file-setprop file 'vc-state 'ignored)) + ((eq status ??) + (vc-file-setprop file 'vc-state 'unregistered)) (t 'edited))))) (if filename (vc-file-getprop filename 'vc-state)))) diff --git a/lisp/vc.el b/lisp/vc.el index 373d0f50124..5ec872523b5 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -3076,7 +3076,10 @@ to provide the `find-revision' operation instead." ((eq state 'needs-merge) "(merge)") ((eq state 'needs-patch) "(patch)") ((eq state 'added) "(added)") - ((eq state 'unlocked-changes) "(stale)"))) + ((eq state 'ignored) "(ignored)") ;; dired-hook filters this out + ((eq state 'unregistered) "?") + ((eq state 'unlocked-changes) "(stale)") + ((not state) "(unknown)"))) (buffer (get-file-buffer file)) (modflag -- 2.39.2