1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-01 05:16:05 +01:00

Seth House: 30701: Misc/vcs_info-examples: Added an hg hook example to restore the 40-char hash

This commit is contained in:
Frank Terbeck 2012-09-28 22:09:37 +00:00
parent feb6169bcd
commit 966bd9bd82
2 changed files with 18 additions and 18 deletions

View file

@ -4,6 +4,9 @@
Functions/VCS_Info/Backends/VCS_INFO_get_data_hg: Removed --debug Functions/VCS_Info/Backends/VCS_INFO_get_data_hg: Removed --debug
flag from the hg vcs_info backend flag from the hg vcs_info backend
* Seth House: 30701: Misc/vcs_info-examples: Added an hg hook
example to restore the 40-char hash
2012-09-28 Oliver Kiddle <opk@zsh.org> 2012-09-28 Oliver Kiddle <opk@zsh.org>
* 30697: Completion/Unix/Command/_dbus: new completion definition * 30697: Completion/Unix/Command/_dbus: new completion definition
@ -185,5 +188,5 @@
***************************************************** *****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL * This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.5725 $ * $Revision: 1.5726 $
***************************************************** *****************************************************

View file

@ -129,32 +129,29 @@ zstyle ':vcs_info:*+*:*' debug false
### Truncate Long Hashes ### Truncate Long Hashes
### Truncate a long hash to 12 characters (which is usually unique enough) ### 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 # Use zformat syntax (remember %i is the hash): %12.12i
# git: # git:
zstyle ':vcs_info:git*' formats "(%s)-[%12.12i %b]-" # hash & branch 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 ### Fetch the full 40-character Mercurial revision id
# Hashes are joined with a + to mirror the output of `hg id`. # There is no great way to obtain branch, local rev, and untracked changes in
zstyle ':vcs_info:hg+set-hgrev-format:*' hooks hg-shorthash # addition to the full 40-character global rev id with a single invocation of
function +vi-hg-shorthash() { # Mercurial. This hook obtains the full global rev id using hexdump (in the
local -a parents # 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
parents=( ${(s:+:)hook_com[hash]} ) # Output the full 40-char global rev id
parents=( ${(@r:12:)parents} ) function +vi-hg-fullglobalrev() {
hook_com[rev-replace]=${(j:+:)parents} local dirstatefile="${hook_com[base]}/.hg/dirstate"
local grevid="$(hexdump -n 20 -e '1/1 "%02x"' ${dirstatefile})"
ret=1 # 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 ### Display the existence of files not yet known to VCS
### git: Show marker (T) if there are untracked files in repository ### git: Show marker (T) if there are untracked files in repository