From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Limitations of Emacs' vc when using modern backends Date: Thu, 15 Dec 2005 12:33:42 -0500 Message-ID: <87r78e1e4v.fsf-monnier+emacs@gnu.org> References: <7i8xunt9ub.fsf@lanthane.pps.jussieu.fr> <87wti73ue7.fsf-monnier+emacs@gnu.org> <7ihd9a76f3.fsf@lanthane.pps.jussieu.fr> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1134676249 27892 80.91.229.2 (15 Dec 2005 19:50:49 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 15 Dec 2005 19:50:49 +0000 (UTC) Cc: Andre Spiegel , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 15 20:50:45 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Emz3b-0008D1-Tu for ged-emacs-devel@m.gmane.org; Thu, 15 Dec 2005 20:46:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Emz4F-0001V8-Uu for ged-emacs-devel@m.gmane.org; Thu, 15 Dec 2005 14:47:07 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Emx14-0005yk-RZ for emacs-devel@gnu.org; Thu, 15 Dec 2005 12:35:43 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Emx12-0005y4-R4 for emacs-devel@gnu.org; Thu, 15 Dec 2005 12:35:42 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Emx12-0005xi-0c for emacs-devel@gnu.org; Thu, 15 Dec 2005 12:35:40 -0500 Original-Received: from [209.226.175.54] (helo=tomts10-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Emx3G-0002Bl-Ov; Thu, 15 Dec 2005 12:37:59 -0500 Original-Received: from alfajor ([65.92.242.250]) by tomts10-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20051215173343.CEP14963.tomts10-srv.bellnexxia.net@alfajor>; Thu, 15 Dec 2005 12:33:43 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id C9DBED7377; Thu, 15 Dec 2005 12:33:42 -0500 (EST) Original-To: Juliusz Chroboczek In-Reply-To: <7ihd9a76f3.fsf@lanthane.pps.jussieu.fr> (Juliusz Chroboczek's message of "Thu, 15 Dec 2005 15:59:12 +0100") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-Originating-IP: [0] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:47804 Archived-At: >> 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