* [PATCH 1/2] Removed --debug flag from the hg vcs_info backend
@ 2012-09-28 21:44 Frank Terbeck
2012-09-28 21:44 ` [PATCH 2/2] Added an hg hook example to restore the 40-char hash Frank Terbeck
0 siblings, 1 reply; 2+ messages in thread
From: Frank Terbeck @ 2012-09-28 21:44 UTC (permalink / raw)
To: zsh-workers
From: Seth House <seth@eseth.com>
The --debug hg flag produces inconsistent output between hg versions and
should not be relied upon. Removing this flag precludes obtaining the
full 40-character global revision id and so documentation and
workarounds should be relied upon instead.
---
Doc/Zsh/contrib.yo | 7 +++++--
Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 9 ++++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 24aafc3..8dbc095 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -768,7 +768,10 @@ item(tt(hgrevformat))(
tt(hg) uses both a hash and a revision number to reference a specific
changeset in a repository. With this style you can format the revision
string (see tt(branchformat)) to include either or both. It's only
-useful when tt(get-revision) is true.
+useful when tt(get-revision) is true. Note, the full 40-character revision id
+is not available (except when using the tt(use-simple) option) because
+executing hg more than once per prompt is too slow; you may customize this
+behavior using hooks.
)
kindex(max-exports)
item(tt(max-exports))(
@@ -993,7 +996,7 @@ In tt(hgrevformat) these replacements are done:
startsitem()
sitem(tt(%r))(The current local revision number.)
-sitem(tt(%h))(The current 40-character changeset ID hash identifier.)
+sitem(tt(%h))(The current global revision identifier.)
endsitem()
In tt(patch-format) and tt(nopatch-format) these replacements are done:
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 48e385c..cedaf56 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -37,12 +37,15 @@ VCS_INFO_adjust
# Calling the 'hg' program is quite a bit too slow for prompts.
# Disabled by default anyway, so no harm done.
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
- # Calling hexdump is (much) faster than hg but doesn't get the local rev
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" use-simple \
&& ( VCS_INFO_check_com hexdump ) && [[ -r ${dirstatefile} ]] ; then
+ # Calling hexdump is (much) faster than hg but doesn't get the local rev
r_csetid=$(hexdump -n 20 -e '1/1 "%02x"' ${dirstatefile})
else
- hgid_args=( --debug id -i -n -b )
+ # 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 )
# Looking for changes is a tad bit slower since the dirstate cache must
# first be refreshed before being read
@@ -119,7 +122,7 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-bookmarks \
&& [[ -r "${bmfile}" ]] && [[ -n "$r_csetid" ]] ; then
while read -r i_bmhash i_bmname ; do
# Compare hash in bookmarks file with changeset id
- [[ $r_csetid == $i_bmhash ]] && hgbmarks+=( $i_bmname )
+ [[ $i_bmhash == $r_csetid* ]] && hgbmarks+=( $i_bmname )
done < ${bmfile}
if VCS_INFO_hook 'gen-hg-bookmark-string' "${hgbmarks[@]}"; then
--
1.7.12.1.382.gb0576a6
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 2/2] Added an hg hook example to restore the 40-char hash
2012-09-28 21:44 [PATCH 1/2] Removed --debug flag from the hg vcs_info backend Frank Terbeck
@ 2012-09-28 21:44 ` Frank Terbeck
0 siblings, 0 replies; 2+ messages in thread
From: Frank Terbeck @ 2012-09-28 21:44 UTC (permalink / raw)
To: zsh-workers
From: Seth House <seth@eseth.com>
In addition this removes the hg example to truncate the 40-char hash
since that is now the default behavior.
---
Misc/vcs_info-examples | 33 +++++++++++++++------------------
1 file changed, 15 insertions(+), 18 deletions(-)
diff --git a/Misc/vcs_info-examples b/Misc/vcs_info-examples
index 0afb790..b07bfc6 100644
--- a/Misc/vcs_info-examples
+++ b/Misc/vcs_info-examples
@@ -129,32 +129,29 @@ zstyle ':vcs_info:*+*:*' debug false
### Truncate Long Hashes
### Truncate a long hash to 12 characters (which is usually unique enough)
-# NOTE: On Mercurial this will hide the second parent hash during a merge
-# (see an example below on how to retain both parents)
# Use zformat syntax (remember %i is the hash): %12.12i
# git:
zstyle ':vcs_info:git*' formats "(%s)-[%12.12i %b]-" # hash & branch
-# hg:
-# First, remove the hash from the default 'branchformat':
-zstyle ':vcs_info:hg:*' branchformat '%b'
-# Then add the hash to 'formats' as %i and truncate it to 12 chars:
-zstyle ':vcs_info:hg:*' formats ' (%s)-[%12.12i %b]-'
-### hg: Truncate long hash to 12-chars but also allow for multiple parents
-# Hashes are joined with a + to mirror the output of `hg id`.
-zstyle ':vcs_info:hg+set-hgrev-format:*' hooks hg-shorthash
-function +vi-hg-shorthash() {
- local -a parents
-
- parents=( ${(s:+:)hook_com[hash]} )
- parents=( ${(@r:12:)parents} )
- hook_com[rev-replace]=${(j:+:)parents}
-
- ret=1
+### Fetch the full 40-character Mercurial revision id
+# There is no great way to obtain branch, local rev, and untracked changes in
+# addition to the full 40-character global rev id with a single invocation of
+# Mercurial. This hook obtains the full global rev id using hexdump (in the
+# same way the use-simple flag does) while retaining all the other vcs_info
+# default functionality and information.
+zstyle ':vcs_info:hg*+set-message:*' hooks hg-fullglobalrev
+
+# Output the full 40-char global rev id
+function +vi-hg-fullglobalrev() {
+ local dirstatefile="${hook_com[base]}/.hg/dirstate"
+ local grevid="$(hexdump -n 20 -e '1/1 "%02x"' ${dirstatefile})"
+ # Omit %h from your hgrevformat since it will be included below
+ hook_com[revision]="${hook_com[revision]} ${grevid}"
}
+
### Display the existence of files not yet known to VCS
### git: Show marker (T) if there are untracked files in repository
--
1.7.12.1.382.gb0576a6
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-28 21:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-28 21:44 [PATCH 1/2] Removed --debug flag from the hg vcs_info backend Frank Terbeck
2012-09-28 21:44 ` [PATCH 2/2] Added an hg hook example to restore the 40-char hash Frank Terbeck
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).