emacs-devel
[Top][All Lists]
Advanced

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

Re: Limitations of Emacs' vc when using modern backends


From: Stefan Monnier
Subject: Re: Limitations of Emacs' vc when using modern backends
Date: Thu, 15 Dec 2005 12:33:42 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>> Is this specific to vc-darcs or to darcs?  Could you show what it
>> does concretely?

> Right now, the penultimate revision of vc-darcs.el happens to be

>   20051116215244-4cc09-4d8edc6c60cacc62a56bb4480ee9cd80be414c18

> Obviously, we don't require the user to remember this; what we do is
> that we allow the user to type:

>  - any prefix of the revision hash;
>  - any prefix of the log message.

> If multiple revisions match, the latest one is chosen.

I see.
And this is a feature of vc-darcs rather than of darcs itself, right?

> So I'd usually type ``Update version number to 1.6'', or ``Update
> version'' or even just ``Update''.  With the current version of
> vc-darcs, I end up with multiple buffers called

>   vc-darcs.el~Update
>   vc-darcs.el~Update version
>   etc.

Yes, there's a similar problem with VC where you can end up with
foo.el~emacs-unicode-2~.  The problem is not just that you have several
files for the same thing (which is just an inconvenience), but that
the `emacs-unicode-2' revision of foo.el is not fixed (it's not a revision,
it's a branch and implicitly refers to the branch), so if some newer version
is committed and you ask to see it, you get the old one because VC doesn't
realize that the file foo.el~emacs-unicode-2~ is out of date.  The same
thing proably happens for you: "Update" may stand for "Update
version number to 1.3" at some point and to "Update
version number to 1.6" at the other, so the "vc-darcs.el~Update" can become
out of date as well.

> What I'm asking is the means to have vc-darcs.el normalise such
> non-canonical revision identifiers to the canonical hash.

Yes, that makes total sense.
The problem mentioned above for CVS has been known for a while but nobody
has provided a fix for it yet.  `canonical-revision' wouldn't solve the
problem, but would provide a clean place where we could then put the fix.

The only problem I see with `canonical-revision' is that for some backends
it may be very costly (for CVS it requires a round trip to the repository),
and it may suffer from race conditions.

In the case of `vc-version-other-window' for CVS, there would be a better
way to do it: when fetching the file, we can get CVS to tell us which
revision it's returning, so we'd basically get the info for free.

Now `canonical-revision' is more general, but I'm wondering: where would it
be used other than in `vc-version-other-window'?  If not, maybe it'd be
better to change `find-version' so as to return the canonical revision that
it has fetched.


        Stefan


PS: Regarding completion, Arch revision names are also longish (tho
    they're not hashes), so I'm using the patch below, along with a new
    function vc-arch-revision-completion-table.


@@ -1700,6 +1813,8 @@
       (if (vc-workfile-unchanged-p buffer-file-name)
          (message "No changes to %s since latest version" file)
        (vc-version-diff file nil nil)))))
+
+(defun vc-default-revision-completion-table (backend file) nil)
 
 (defun vc-version-diff (file rev1 rev2)
   "List the differences between FILE's versions REV1 and REV2.
@@ -1708,12 +1823,13 @@
 a directory, in that case, generate diffs between the correponding
 versions of all registered files in or below it."
   (interactive
-   (let ((file (expand-file-name
+   (let* ((file (expand-file-name
                 (read-file-name (if buffer-file-name
                                     "File or dir to diff (default visited 
file): "
                                   "File or dir to diff: ")
                                 default-directory buffer-file-name t)))
-         (rev1-default nil) (rev2-default nil))
+         (rev1-default nil) (rev2-default nil)
+         (completion-table (vc-call revision-completion-table file)))
      ;; compute default versions based on the file state
      (cond
       ;; if it's a directory, don't supply any version default
@@ -1722,21 +1838,23 @@
       ;; if the file is not locked, use last and previous version as default
       (t
        (setq rev1-default (vc-call previous-version file
-                                   (vc-workfile-version file)))
+                                  (vc-workfile-version file)))
        (if (string= rev1-default "") (setq rev1-default nil))
        (setq rev2-default (vc-workfile-version file))))
      ;; construct argument list
-     (list file
-           (read-string (if rev1-default
-                           (concat "Older version (default "
-                                   rev1-default "): ")
-                         "Older version: ")
-                       nil nil rev1-default)
-           (read-string (if rev2-default
-                           (concat "Newer version (default "
-                                   rev2-default "): ")
-                         "Newer version (default current source): ")
-                       nil nil rev2-default))))
+     (let* ((rev1-prompt (if rev1-default
+                            (concat "Older version (default "
+                                    rev1-default "): ")
+                          "Older version: "))
+           (rev2-prompt (concat "Newer version (default "
+                                (or rev2-default "current source") "): "))
+           (rev1 (if completion-table
+                     (completing-read rev1-prompt completion-table nil nil nil 
nil rev1-default)
+                   (read-string rev1-prompt nil nil rev1-default)))
+           (rev2 (if completion-table
+                     (completing-read rev2-prompt completion-table nil nil nil 
nil rev2-default)
+                   (read-string rev2-prompt nil nil rev2-default))))
+       (list file rev1 rev2))))
   (if (file-directory-p file)
       ;; recursive directory diff
       (progn




reply via email to

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