zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: [PATCH] vcs_info hg: Compute the branch name correctly when get-revision is set and check-for-changes is not
Date: Wed, 7 Apr 2021 21:48:48 +0000	[thread overview]
Message-ID: <20210407214848.GA21212@tarpaulin.shahaf.local2> (raw)

---

In the following, lines 10, 12, 14 state different branch names:

     1	% hg init
     2	% echo foo > foo
     3	% hg add foo
     4	% hg commit -m add
     5	%
     6	% autoload vcs_info
     7	% precmd() { vcs_info; print -ParC1 -- $vcs_info_msg_0_ }
     8	 (hg)-[default]-
     9	% hg branch newbranch > /dev/null
    10	 (hg)-[newbranch]-
    11	% zstyle \* get-revision yes
    12	 (hg)-[default:326db25708c0:0]-
    13	% zstyle \* check-for-changes yes
    14	 (hg)-[newbranch:326db25708c0:0]-

Seen with mercurial 4.8.2-1+deb10u1 and 5.6.1-2 (Debian stable and
unstable, respectively).

When get-revision is set, VCS_INFO_get_data_hg runs one of the following
commands, depending on whether check-for-changes is also set:

% hg id -inb
326db25708c0 0 newbranch
% hg id -inbr.
326db25708c0 0 default

The following patch seems to work.  The branch name is then retrieved
from .hg/branch (which in workers/46016 was implied to be safe to use).

Reviews would be welcome.

Cheers,

Daniel


diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index f7e9d6f45..c3ee409d3 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -49,7 +49,7 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
         # Settling for a short (but unique!) hash because getting the full
         # 40-char hash in addition to all the other info we want isn't
         # available in a single hg invocation
-        hgid_args=( id -i -n -b )
+        hgid_args=( id -i -n )
 
         # Looking for changes is a tad bit slower since the dirstate cache must
         # first be refreshed before being read
@@ -58,7 +58,7 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
 
         local HGPLAIN
         HGPLAIN=1 ${vcs_comm[cmd]} ${(z)hgid_args} 2> /dev/null \
-            | read -r r_csetid r_lrev r_branch
+            | read -r r_csetid r_lrev
     fi
 fi
 



             reply	other threads:[~2021-04-07 21:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 21:48 Daniel Shahaf [this message]
2021-04-07 22:02 ` Duke Normandin
2021-04-07 22:19   ` Daniel Shahaf
2021-04-07 22:32     ` Duke Normandin

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=20210407214848.GA21212@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.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 public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).