From 3702367bcef4d8987b1c6aa06ab29ec0390d6887 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 1 May 2008 19:13:16 +0000 Subject: [PATCH] Change 'needs-patch to 'needs-update. --- lisp/ChangeLog | 16 ++++++++++++++++ lisp/vc-arch.el | 2 +- lisp/vc-bzr.el | 2 +- lisp/vc-cvs.el | 6 +++--- lisp/vc-git.el | 14 ++++++++------ lisp/vc-hooks.el | 13 ++++--------- lisp/vc-mtn.el | 2 +- lisp/vc-rcs.el | 38 ++++++++++++++++++++------------------ lisp/vc-sccs.el | 28 +++++++++++++++------------- lisp/vc-svn.el | 2 +- lisp/vc.el | 27 ++++++++++++--------------- 11 files changed, 82 insertions(+), 68 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index cadc3d43105..275e6dbeb0b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,19 @@ +2008-05-01 Eric S. Raymond + + * vc-bzr.el (vc-bzr-state): Allow this to return 'ignored + when appropriate. + * vc-sccs.el (vc-sccs-state): Call vc-sccs-unregistered so + we report the 'unregistered state reliably. + * vc-rcs.el (vc-rcs-state): Call vc-rcs-unregistered so + we report the 'unregistered state reliably. + * vc-git.el (vc-git-state): Call vc-git-unregistered so + we report the 'unregistered state reliably. + * vc-hooks (vc-state): Document that vc-unregistered is + now expected to be returned reliably. + * vc.el (vc-default-dired-state): Change needs-patch state to + needs-update, since the name now shows up in dir-status listings + and was somewhat misleading. + 2008-05-01 Sam Steingold * vc.el (vc-delete-file): Check if the file has uncommitted changed. diff --git a/lisp/vc-arch.el b/lisp/vc-arch.el index 58a3bd0183d..77e36dd335e 100644 --- a/lisp/vc-arch.el +++ b/lisp/vc-arch.el @@ -329,7 +329,7 @@ Return non-nil if FILE is unchanged." (setq rev (replace-match (cdr rule) t nil rev)))) (format "Arch%c%s" (case (vc-state file) - ((up-to-date needs-patch) ?-) + ((up-to-date needs-update) ?-) (added ?@) (t ?:)) rev))) diff --git a/lisp/vc-bzr.el b/lisp/vc-bzr.el index aca00409fac..3d8990a6157 100644 --- a/lisp/vc-bzr.el +++ b/lisp/vc-bzr.el @@ -275,7 +275,7 @@ If any error occurred in running `bzr status', then return nil." (renamed . edited) (modified . edited) (removed . removed) - (ignored . unregistered) + (ignored . ignored) (unknown . unregistered) (unchanged . up-to-date))))))) diff --git a/lisp/vc-cvs.el b/lisp/vc-cvs.el index eec813859d2..ba80153a60c 100644 --- a/lisp/vc-cvs.el +++ b/lisp/vc-cvs.el @@ -838,7 +838,7 @@ state." ((string-match "Locally Modified" status) 'edited) ((string-match "Needs Merge" status) 'needs-merge) ((string-match "Needs \\(Checkout\\|Patch\\)" status) - (if missing 'missing 'needs-patch)) + (if missing 'missing 'needs-update)) ((string-match "Locally Added" status) 'added) ((string-match "Locally Removed" status) 'removed) ((string-match "File had conflicts " status) 'conflict) @@ -903,7 +903,7 @@ state." ((string-match "Locally Modified" status-str) 'edited) ((string-match "Needs Merge" status-str) 'needs-merge) ((string-match "Needs \\(Checkout\\|Patch\\)" status-str) - (if missing 'missing 'needs-patch)) + (if missing 'missing 'needs-update)) ((string-match "Locally Added" status-str) 'added) ((string-match "Locally Removed" status-str) 'removed) ((string-match "File had conflicts " status-str) 'conflict) @@ -922,7 +922,7 @@ state." ;; (?M . edited) ;; (?P . needs-merge) ;; (?R . removed) - ;; (?U . needs-patch)))) + ;; (?U . needs-update)))) ;; (goto-char (point-min)) ;; (while (not (eobp)) ;; (if (looking-at "^[ACMPRU?] \\(.*\\)$") diff --git a/lisp/vc-git.el b/lisp/vc-git.el index 757263fa11e..0c718cb8677 100644 --- a/lisp/vc-git.el +++ b/lisp/vc-git.el @@ -156,12 +156,14 @@ (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\\} \\([ADMUT]\\)\0[^\0]+\0" - diff)) - (vc-git--state-code (match-string 1 diff)) - (if (vc-git--empty-db-p) 'added 'up-to-date)))) + (if (not (vc-git-registered file)) + 'unregistered + (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\\} \\([ADMUT]\\)\0[^\0]+\0" + diff)) + (vc-git--state-code (match-string 1 diff)) + (if (vc-git--empty-db-p) 'added 'up-to-date))))) (defun vc-git--ls-files-state (state &rest args) "Set state to STATE on all files found with git-ls-files ARGS." diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el index e75f6ebce7b..3c17c816e58 100644 --- a/lisp/vc-hooks.el +++ b/lisp/vc-hooks.el @@ -491,7 +491,7 @@ For registered files, the value returned is one of: USER The current version of the working file is locked by some other USER (a string). - 'needs-patch The file has not been edited by the user, but there is + 'needs-update The file has not been edited by the user, but there is a more recent version on the current branch stored in the master file. @@ -528,12 +528,7 @@ For registered files, the value returned is one of: 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. + 'unregistered The file is not under version control. A return of nil from this function means we have no information on the status of this file. @@ -856,7 +851,7 @@ This function assumes that the file is registered." (rev (vc-working-revision file))) (propertize (cond ((or (eq state 'up-to-date) - (eq state 'needs-patch)) + (eq state 'needs-update)) (setq state-echo "Up to date file") (concat backend "-" rev)) ((stringp state) @@ -877,7 +872,7 @@ This function assumes that the file is registered." (t ;; Not just for the 'edited state, but also a fallback ;; for all other states. Think about different symbols - ;; for 'needs-patch and 'needs-merge. + ;; for 'needs-update and 'needs-merge. (setq state-echo "Locally modified file") (concat backend ":" rev))) 'help-echo (concat state-echo " under the " backend diff --git a/lisp/vc-mtn.el b/lisp/vc-mtn.el index faa28964be7..9f300a8f8eb 100644 --- a/lisp/vc-mtn.el +++ b/lisp/vc-mtn.el @@ -125,7 +125,7 @@ (setq branch (replace-match (cdr rule) t nil branch)))) (format "Mtn%c%s" (case (vc-state file) - ((up-to-date needs-patch) ?-) + ((up-to-date needs-update) ?-) (added ?@) (t ?:)) branch))) diff --git a/lisp/vc-rcs.el b/lisp/vc-rcs.el index a1b10aaa541..e87abef125f 100644 --- a/lisp/vc-rcs.el +++ b/lisp/vc-rcs.el @@ -118,23 +118,25 @@ For a description of possible values, see `vc-check-master-templates'." (defun vc-rcs-state (file) "Implementation of `vc-state' for RCS." - (or (boundp 'vc-rcs-headers-result) - (and vc-consult-headers - (vc-rcs-consult-headers file))) - (let ((state - ;; vc-working-revision might not be known; in that case the - ;; property is nil. vc-rcs-fetch-master-state knows how to - ;; handle that. - (vc-rcs-fetch-master-state file - (vc-file-getprop file - 'vc-working-revision)))) - (if (not (eq state 'up-to-date)) - state - (if (vc-workfile-unchanged-p file) - 'up-to-date - (if (eq (vc-rcs-checkout-model file) 'locking) - 'unlocked-changes - 'edited))))) + (if (not (vc-rc-registered f)) + 'unregistered + (or (boundp 'vc-rcs-headers-result) + (and vc-consult-headers + (vc-rcs-consult-headers file))) + (let ((state + ;; vc-working-revision might not be known; in that case the + ;; property is nil. vc-rcs-fetch-master-state knows how to + ;; handle that. + (vc-rcs-fetch-master-state file + (vc-file-getprop file + 'vc-working-revision)))) + (if (not (eq state 'up-to-date)) + state + (if (vc-workfile-unchanged-p file) + 'up-to-date + (if (eq (vc-rcs-checkout-model file) 'locking) + 'unlocked-changes + 'edited)))))) (defun vc-rcs-state-heuristic (file) "State heuristic for RCS." @@ -889,7 +891,7 @@ file." ;; workfile version is latest on branch 'up-to-date ;; workfile version is not latest on branch - 'needs-patch)) + 'needs-update)) ;; locked by the calling user ((and (stringp locking-user) (string= locking-user (vc-user-login-name file))) diff --git a/lisp/vc-sccs.el b/lisp/vc-sccs.el index 3bcc10416b8..dd9c464f8ef 100644 --- a/lisp/vc-sccs.el +++ b/lisp/vc-sccs.el @@ -117,19 +117,21 @@ For a description of possible values, see `vc-check-master-templates'." (defun vc-sccs-state (file) "SCCS-specific function to compute the version control state." - (with-temp-buffer - (if (vc-insert-file (vc-sccs-lock-file file)) - (let* ((locks (vc-sccs-parse-locks)) - (working-revision (vc-working-revision file)) - (locking-user (cdr (assoc working-revision locks)))) - (if (not locking-user) - (if (vc-workfile-unchanged-p file) - 'up-to-date - 'unlocked-changes) - (if (string= locking-user (vc-user-login-name file)) - 'edited - locking-user))) - 'up-to-date))) + (if (not (vc-sccs-registered file)) + 'unregistered + (with-temp-buffer + (if (vc-insert-file (vc-sccs-lock-file file)) + (let* ((locks (vc-sccs-parse-locks)) + (working-revision (vc-working-revision file)) + (locking-user (cdr (assoc working-revision locks)))) + (if (not locking-user) + (if (vc-workfile-unchanged-p file) + 'up-to-date + 'unlocked-changes) + (if (string= locking-user (vc-user-login-name file)) + 'edited + locking-user))) + 'up-to-date)))) (defun vc-sccs-state-heuristic (file) "SCCS-specific state heuristic." diff --git a/lisp/vc-svn.el b/lisp/vc-svn.el index 31d346ea87a..053c7fd1965 100644 --- a/lisp/vc-svn.el +++ b/lisp/vc-svn.el @@ -625,7 +625,7 @@ information about FILENAME and return its status." (cond ((eq status ?\ ) (if (eq (char-after (match-beginning 1)) ?*) - 'needs-patch + 'needs-update (vc-file-setprop file 'vc-checkout-time (nth 5 (file-attributes file))) 'up-to-date)) diff --git a/lisp/vc.el b/lisp/vc.el index d39aa0e8153..f31d741ca14 100644 --- a/lisp/vc.el +++ b/lisp/vc.el @@ -148,7 +148,8 @@ ;; possible values, see `vc-state'. This function should do a full and ;; reliable state computation; it is usually called immediately after ;; C-x v v. If you want to use a faster heuristic when visiting a -;; file, put that into `state-heuristic' below. +;; file, put that into `state-heuristic' below. Note that under most +;; VCSes this won't be called at all, dir-state or dir-stus is used instead. ;; ;; - state-heuristic (file) ;; @@ -618,12 +619,6 @@ ;; - make it easier to write logs. Maybe C-x 4 a should add to the log ;; buffer, if one is present, instead of adding to the ChangeLog. ;; -;; - make vc-state for all backends return 'unregistered instead of -;; nil for unregistered files, then update vc-next-action. -;; -;; - vc-default-registered should return 'unregistered not nil for -;; unregistered files. -;; ;; - vc-register should register a fileset at a time. The backends ;; already support this, only the front-end needs to be changed to ;; handle multiple files at a time. @@ -1661,12 +1656,11 @@ merge in the changes into your working copy." ;; Do the right thing (cond ;; Files aren't registered - ((or (not state) ;; RCS uses nil for unregistered files. - (eq state 'unregistered) + ((or (eq state 'unregistered) (eq state 'ignored)) (mapc 'vc-register files)) ;; Files are up-to-date, or need a merge and user specified a revision - ((or (eq state 'up-to-date) (and verbose (eq state 'needs-patch))) + ((or (eq state 'up-to-date) (and verbose (eq state 'needs-update))) (cond (verbose ;; go to a different revision @@ -1745,8 +1739,8 @@ merge in the changes into your working copy." ;; conflict ((eq state 'conflict) (vc-mark-resolved files)) - ;; needs-patch - ((eq state 'needs-patch) + ;; needs-update + ((eq state 'needs-update) (dolist (file files) (if (yes-or-no-p (format "%s is not up-to-date. Get latest revision? " @@ -1789,7 +1783,10 @@ merge in the changes into your working copy." "Revert to checked-in revision, instead? ")) (error "Checkout aborted") (vc-revert-buffer-internal t t) - (vc-checkout file t)))))))) + (vc-checkout file t))))) + ;; Unknown fileset state + (t + (error "Fileset is in an unknown state %s" state))))) (defun vc-create-repo (backend) "Create an empty repository in the current directory." @@ -1974,7 +1971,7 @@ After check-out, runs the normal hook `vc-checkout-hook'." (not writable)) (if (vc-call latest-on-branch-p file) 'up-to-date - 'needs-patch) + 'needs-update) 'edited)) (vc-checkout-time . ,(nth 5 (file-attributes file)))))) (vc-resynch-buffer file t t) @@ -4277,7 +4274,7 @@ to provide the `find-revision' operation instead." ((stringp state) (concat "(" state ")")) ((eq state 'edited) "(modified)") ((eq state 'needs-merge) "(merge)") - ((eq state 'needs-patch) "(patch)") + ((eq state 'needs-update) "(update)") ((eq state 'added) "(added)") ((eq state 'removed) "(removed)") ((eq state 'ignored) "(ignored)") ;; dired-hook filters this out -- 2.11.4.GIT