mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-02 22:11:54 +02:00
vcs_info hg: Support inactive bookmarks
(Similar to git detached heads)
This commit is contained in:
parent
0833518980
commit
9d25fd7255
3 changed files with 30 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
2015-01-25 Daniel Shahaf <d.s@daniel.shahaf.name>
|
||||
|
||||
* Doc/Zsh/contrib.yo,
|
||||
Functions/VCS_Info/Backends/VCS_INFO_get_data_hg: vcs_info hg:
|
||||
Support inactive bookmarks
|
||||
|
||||
2015-01-23 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
|
||||
|
||||
* 34335: _yum: fix bugs in _yum_all_pkgs
|
||||
|
|
|
@ -927,6 +927,10 @@ kindex(get-bookmarks)
|
|||
item(tt(get-bookmarks))(
|
||||
If set to true, the tt(hg) backend will try to get a list of current
|
||||
bookmarks. They will be available via the `tt(%m)' replacement.
|
||||
|
||||
The default is to generate a comma-separated list of all bookmark names
|
||||
that refer to the currently checked out revision. If a bookmark is active,
|
||||
its name is suffixed an asterisk and placed first in the list.
|
||||
)
|
||||
kindex(use-prompt-escapes)
|
||||
item(tt(use-prompt-escapes))(
|
||||
|
@ -1290,6 +1294,9 @@ tt(get-revision) and tt(get-bookmarks) styles must be true.
|
|||
This hook gets the names of the Mercurial bookmarks that
|
||||
tt(vcs_info) collected from `hg'.
|
||||
|
||||
If a bookmark is active, the key tt(${hook_com[hg-active-bookmark]}) is
|
||||
set to its name. The key is otherwise unset.
|
||||
|
||||
When setting tt(ret) to non-zero, the string in
|
||||
tt(${hook_com[hg-bookmark-string]}) will be used in the tt(%m) escape in
|
||||
tt(formats) and tt(actionformats) and will be available in the global
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
setopt localoptions extendedglob NO_shwordsplit
|
||||
|
||||
local hgbase bmfile branchfile rebasefile dirstatefile mqseriesfile \
|
||||
curbmfile curbm \
|
||||
mqstatusfile mqguardsfile patchdir mergedir \
|
||||
r_csetid r_lrev r_branch i_bmhash i_bmname \
|
||||
revformat branchformat hgactionstring hgchanges \
|
||||
|
@ -24,6 +25,7 @@ r_lrev='' # local revision
|
|||
patchdir="${hgbase}/.hg/patches"
|
||||
mergedir="${hgbase}/.hg/merge/"
|
||||
bmfile="${hgbase}/.hg/bookmarks"
|
||||
curbmfile="${hgbase}/.hg/bookmarks.current"
|
||||
branchfile="${hgbase}/.hg/branch"
|
||||
rebasefile="${hgbase}/.hg/rebasestate"
|
||||
dirstatefile="${hgbase}/.hg/dirstate"
|
||||
|
@ -125,8 +127,23 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-bookmarks \
|
|||
[[ $i_bmhash == $r_csetid* ]] && hgbmarks+=( $i_bmname )
|
||||
done < ${bmfile}
|
||||
|
||||
if [[ -r "$curbmfile" ]] ; then
|
||||
curbm=$(<"${curbmfile}")
|
||||
hook_com[hg-active-bookmark]=$curbm
|
||||
else
|
||||
# leave curbm empty and [hg-active-bookmark] undefined.
|
||||
fi
|
||||
|
||||
if VCS_INFO_hook 'gen-hg-bookmark-string' "${hgbmarks[@]}"; then
|
||||
# If there is an active bookmark, annotate it and put it first.
|
||||
if [[ -n $curbm ]] ; then
|
||||
hgbmarks[(i)$curbm]=()
|
||||
hgbmarks[1,0]="${curbm}*"
|
||||
fi
|
||||
hgbmstring=${(j:, :)hgbmarks}
|
||||
# Deannotate the array, in case later code expects it to be valid.
|
||||
# (The order is not restored.)
|
||||
[[ -n $curbm ]] && hgbmarks[1]=${${hgbmarks[1]}[1,-2]}
|
||||
else
|
||||
hgbmstring=${hook_com[hg-bookmark-string]}
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue