Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] vcs_info hg: Compute the branch name correctly when get-revision is set and check-for-changes is not
- X-seq: zsh-users 26635
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- 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
- Archived-at: <https://zsh.org/users/26635>
- List-id: <zsh-users.zsh.org>
---
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author