zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Subject: [PATCH 2/2] Added an hg hook example to restore the 40-char hash
Date: Fri, 28 Sep 2012 23:44:06 +0200	[thread overview]
Message-ID: <1348868646-24756-2-git-send-email-ft@bewatermyfriend.org> (raw)
In-Reply-To: <1348868646-24756-1-git-send-email-ft@bewatermyfriend.org>

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


      reply	other threads:[~2012-09-28 21:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

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=1348868646-24756-2-git-send-email-ft@bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --cc=zsh-workers@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).