bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#21383: Static revisions in vc-working-revision


From: Dmitry Gutov
Subject: bug#21383: Static revisions in vc-working-revision
Date: Fri, 4 Sep 2015 01:32:14 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Thunderbird/40.0

On 09/03/2015 11:07 PM, Stefan Monnier wrote:

Also VC was designed when revisions were per-file, and the way we
extended it is to say that it's OK to have an out-of-date revision
number for a given file, if that file's content is the same in the
current revision.

This might be one of the more annoying discrepancies, and one that's not too hard to improve.

I wonder if I've missed any other good places to reset the root's properties.

diff --git a/lisp/vc/vc-dispatcher.el b/lisp/vc/vc-dispatcher.el
index ec55867..a27c873 100644
--- a/lisp/vc/vc-dispatcher.el
+++ b/lisp/vc/vc-dispatcher.el
@@ -567,7 +567,10 @@ editing!"
   (if (string= buffer-file-name file)
       (vc-resynch-window file keep noquery reset-vc-info)
     (if (file-directory-p file)
-       (vc-resynch-buffers-in-directory file keep noquery reset-vc-info)
+        (progn
+          (when reset-vc-info
+            (vc-file-clearprops file))
+ (vc-resynch-buffers-in-directory file keep noquery reset-vc-info))
       (let ((buffer (get-file-buffer file)))
        (when buffer
          (with-current-buffer buffer
diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el
index 8a0f554..33d742c 100644
--- a/lisp/vc/vc-git.el
+++ b/lisp/vc/vc-git.el
@@ -254,15 +254,16 @@ matching the resulting Git log output, and KEYWORDS is a list of
     (vc-git--rev-parse "HEAD")))

 (defun vc-git--symbolic-ref (file)
-  (or
-   (vc-file-getprop file 'vc-git-symbolic-ref)
-   (let* (process-file-side-effects
-          (str (vc-git--run-command-string nil "symbolic-ref" "HEAD")))
-     (vc-file-setprop file 'vc-git-symbolic-ref
-                      (if str
- (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
-                              (match-string 2 str)
-                            str))))))
+  (let ((root (vc-git-root file)))
+    (or
+     (vc-file-getprop root 'vc-git-symbolic-ref)
+     (let* (process-file-side-effects
+            (str (vc-git--run-command-string nil "symbolic-ref" "HEAD")))
+       (vc-file-setprop root 'vc-git-symbolic-ref
+                        (if str
+ (if (string-match "^\\(refs/heads/\\)?\\(.+\\)$" str)
+                                (match-string 2 str)
+                              str)))))))

 (defun vc-git-mode-line-string (file)
   "Return a string for `vc-mode-line' to put in the mode line for FILE."
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index e674f0e..4bee8ad 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -493,12 +493,15 @@ status of this file. Otherwise, the value returned is one of:
 (defun vc-working-revision (file &optional backend)
   "Return the repository version from which FILE was checked out.
 If FILE is not registered, this function always returns nil."
-  (or (vc-file-getprop file 'vc-working-revision)
-      (progn
-       (setq backend (or backend (vc-responsible-backend file)))
-       (when backend
-         (vc-file-setprop file 'vc-working-revision
-                          (vc-call-backend backend 'working-revision file))))))
+  (unless backend (setq backend (vc-responsible-backend file)))
+  (when backend
+    (let* ((granularity (vc-call-backend backend 'revision-granularity))
+           (prop-target (if (eq granularity 'repository)
+                            (vc-call-backend backend 'root file)
+                          file)))
+      (or (vc-file-getprop prop-target 'vc-working-revision)
+          (vc-file-setprop prop-target 'vc-working-revision
+ (vc-call-backend backend 'working-revision file))))))

 ;; Backward compatibility.
 (define-obsolete-function-alias






reply via email to

[Prev in Thread] Current Thread [Next in Thread]