all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Santiago Payà i Miralta" <santiagopim@gmail.com>
To: 17570@debbugs.gnu.org
Subject: bug#17570: * 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	[thread overview]
Message-ID: <CABmqNJVhcDxeDpCuSBtOTb2XOirSVX814euZ_KMQjUDW=YCPNg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3264 bytes --]

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@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@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

[-- Attachment #2: Type: text/html, Size: 10557 bytes --]

             reply	other threads:[~2014-05-23 22:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-23 22:57 Santiago Payà i Miralta [this message]
2014-06-06 16:29 ` bug#17570: * lisp/vc/vc-hg.el (vc-hg-working-revision): Fix returning working revision instead of last revision Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABmqNJVhcDxeDpCuSBtOTb2XOirSVX814euZ_KMQjUDW=YCPNg@mail.gmail.com' \
    --to=santiagopim@gmail.com \
    --cc=17570@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.