GNU bug report logs - #17570
* lisp/vc/vc-hg.el (vc-hg-working-revision): Fix returning working revision instead of last revision.

Previous Next

Package: emacs;

Reported by: Santiago Payà i Miralta <santiagopim <at> gmail.com>

Date: Fri, 23 May 2014 22:58:01 UTC

Severity: normal

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17570 in the body.
You can then email your comments to 17570 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#17570; Package emacs. (Fri, 23 May 2014 22:58:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Santiago Payà i Miralta <santiagopim <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 23 May 2014 22:58:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Santiago Payà i Miralta <santiagopim <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: * lisp/vc/vc-hg.el (vc-hg-working-revision): Fix returning working
 revision instead of last revision.
Date: Sat, 24 May 2014 00:57:19 +0200
[Message part 1 (text/plain, inline)]
Hi emacs,

I wish to fix the lisp/vc/vc-hg.el (vc-hg-working-revision) function with
the `hg parent' command.

Actually this function uses the `hg log -l 1' command that returns the last
commited revision, not the last checked out revision. When checking out a
specified revision with `hg update REV' the actual revision of FILE is
returned by `hg parent'.

vc.el:
;; * working-revision (file)
;;
;;   Return the working revision of FILE.  This is the revision fetched
;;   by the last checkout or update, not necessarily the same thing as the
;;   head or tip revision.  Should return "0" for a file added but not yet
;;   committed.

On success `hg parent' command returns 0 and prints the parent of FILE. For
not registered, as added but not commited files, throws error code and
prints a message, so could check the returning value to substitute the
printed message with "0" as vc.el requires. Here it is proposed the
catch/throw mechanism.

2014-05-24 Santiago Payà i Miralta <santiagopim <at> gmail.com>

        * lisp/vc/vc-hg.el (vc-hg-working-revision): Fix
        returning working revision instead of last revision.

From 426ae4ae2f4ed6f26fc65bb5023fe79ba79686ae Mon Sep 17 00:00:00 2001
From: Santiago Payà i Miralta <santiagopim <at> gmail.com>
Date: Sat, 24 May 2014 00:20:19 +0200
Subject: [PATCH] * lisp/vc/vc-hg.el (vc-hg-working-revision): Fix returning
 working revision instead of last revision.

Actually this function uses the `hg log -l 1' command that returns the last
commited revision, not the last checked out revision. When checking out a
specified revision with `hg update REV' the actual revision of FILE is
returned by `hg parent'.

vc.el:
;; * working-revision (file)
;;
;;   Return the working revision of FILE.  This is the revision fetched
;;   by the last checkout or update, not necessarily the same thing as the
;;   head or tip revision.  Should return "0" for a file added but not yet
;;   committed.

On success `hg parent' command returns 0 and prints the parent of FILE. For
not registered, as added but not commited files, throws error code and
prints a message, so could check the returning value to substitute the
printed message with "0" as vc.el requires. Here it is proposed the
catch/throw mechanism.
---
 lisp/vc/vc-hg.el |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 05b53a3..0326456 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -230,11 +230,14 @@ highlighting the Log View buffer."
   (let ((default-directory (if (file-directory-p file)
                                (file-name-as-directory file)
                              (file-name-directory file))))
-    (ignore-errors
-      (with-output-to-string
-        (process-file vc-hg-program nil standard-output nil
-                      "log" "-l" "1" "--template" "{rev}"
-                      (file-relative-name file))))))
+    (catch 'wrap
+      (ignore-errors
+ (with-output-to-string
+  (if (/= 0
+  (process-file vc-hg-program nil standard-output nil
+ "parent" "--template" "{rev}"
+ (file-relative-name file))
+  )(throw 'wrap "0")))))))

 ;;; History functions

-- 
1.7.9.5
[Message part 2 (text/html, inline)]

Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Fri, 06 Jun 2014 16:30:04 GMT) Full text and rfc822 format available.

Notification sent to Santiago Payà i Miralta <santiagopim <at> gmail.com>:
bug acknowledged by developer. (Fri, 06 Jun 2014 16:30:06 GMT) Full text and rfc822 format available.

Message #10 received at 17570-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Santiago Payà i Miralta <santiagopim <at> gmail.com>
Cc: 17570-done <at> debbugs.gnu.org
Subject: Re: bug#17570: * lisp/vc/vc-hg.el (vc-hg-working-revision): Fix
 returning working revision instead of last revision.
Date: Fri, 06 Jun 2014 12:29:47 -0400
> I wish to fix the lisp/vc/vc-hg.el (vc-hg-working-revision) function with
> the `hg parent' command.

Good idea, thanks.  But your patch's indentation was completely messed
up (as well as placement of line breaks).
I installed a cleaned up version into `emacs-24' (contrary to the
previous patch which I installed into `trunk' since it was a new
feature rather than a bug-fix).


        Stefan


=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog	2014-06-06 14:25:39 +0000
+++ lisp/ChangeLog	2014-06-06 16:27:21 +0000
@@ -1,3 +1,8 @@
+2014-06-06  Santiago Payà i Miralta  <santiagopim <at> gmail.com>
+
+	* vc/vc-hg.el (vc-hg-working-revision): Use "hg parent" and
+	vc-hg-command (bug#17570).
+
 2014-06-06  Stefan Monnier  <monnier <at> iro.umontreal.ca>
 
 	* international/mule-cmds.el (ucs-names): Add special entry for BEL

=== modified file 'lisp/vc/vc-hg.el'
--- lisp/vc/vc-hg.el	2014-05-11 02:01:08 +0000
+++ lisp/vc/vc-hg.el	2014-06-06 16:26:37 +0000
@@ -227,14 +227,11 @@
 
 (defun vc-hg-working-revision (file)
   "Hg-specific version of `vc-working-revision'."
-  (let ((default-directory (if (file-directory-p file)
-                               (file-name-as-directory file)
-                             (file-name-directory file))))
-    (ignore-errors
+  (or (ignore-errors
       (with-output-to-string
-        (process-file vc-hg-program nil standard-output nil
-                      "log" "-l" "1" "--template" "{rev}"
-                      (file-relative-name file))))))
+          (vc-hg-command standard-output 0 file
+                         "parent" "--template" "{rev}")))
+      "0"))
 
 ;;; History functions
 





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 05 Jul 2014 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 11 years and 48 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.