Hello, These patches add support for Mercurial Queues in VCS_Info in quite the same way it already supports git's equivalent "stgit". With these patches applied, the %m modifier in the branchformat is replaced by the current applied patch if there's one, "no patch applied" otherwise. It also adds a "hgrevformat" style since hg can reference a changeset either by its hash or its local revision number. The default is "%r:%h" and is how Hg usually formats the revision (e.g.: 1929:c562d287254). The first patch is the code, the second the documentation. Cheers, -- Lionel Flandrin
Support for Mercurial Queues in VCS_INFO
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -3,7 +3,21 @@
## Distributed under the same BSD-ish license as zsh itself.
setopt localoptions NO_shwordsplit
-local file hgbranch hgbranch_name hgbase hghash hglrev r_branch r_info
+local file hgbranch hgbranch_name hgbase hghash hglrev hgmisc r_branch r_info revformat
+
+VCS_INFO_hg_get_mq_top_patch () {
+ local patchdir=$1
+
+ if [[ -e "${patchdir}/status" ]]; then
+ local -a patches
+ patches=(${(f)"$(< "${patchdir}/status")"})
+ printf "%s" "${patches[-1]/[^:]*:/}"
+ return 0
+ fi
+
+ return 1
+}
+
hgbase=${vcs_comm[basedir]}
rrn=${hgbase:t}
@@ -34,6 +48,8 @@
done
if [[ -n ${hglrev} ]] ; then
+ zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" hgrevformat revformat || revformat="%r:%h"
+ zformat -f hglrev "${revformat}" "r:${hglrev}" "h:${hghash}"
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat hgbranch || hgbranch="%b:%r"
zformat -f hgbranch "${hgbranch}" "b:${hgbranch_name}" "r:${hglrev}"
fi
@@ -41,5 +57,15 @@
hgbranch="${hgbranch_name}"
fi
-VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' "${hglrev}" "${hghash}"
+local patchdir=${hgbase}/.hg/patches/
+
+if [[ -d $patchdir ]] ; then
+ hgmisc=$(VCS_INFO_hg_get_mq_top_patch "${patchdir}")
+
+ hgmisc=${hgmisc:-"no patch applied"}
+else
+ hgmisc=''
+fi
+
+VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' "${hglrev}" "${hgmisc}"
return 0
Updated contrib.yo regarding Mercurial Queues support in VCS_INFO
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -493,6 +493,13 @@
tt(stgit)-initialized branches. This style let's you modify how that string
should look like.
)
+kindex(hgrevformat)
+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 var(branchformat)) to include either of both. It's only
+useful when var(get-revision) is true.
+)
kindex(max-exports)
item(tt(max-exports))(
Defines the maximum number if
@@ -610,9 +617,10 @@
startsitem()
sitem(tt(formats))(" (%s)-[%b|%a]-")
sitem(tt(actionformats))(" (%s)-[%b]-")
-sitem(tt(branchformat))("%b:%r" (for bzr, svn and svk))
+sitem(tt(branchformat))("%b:%r" (for bzr, svn, svk and hg))
sitem(tt(nvcsformats))("")
sitem(tt(stgitformat))(" %p (%c)")
+sitem(tt(hgrevformat))("%r:%h")
sitem(tt(max-exports))(2)
sitem(tt(enable))(ALL)
sitem(tt(disable))((empty list))
@@ -635,7 +643,8 @@
sitem(tt(%b))(Information about the current branch.)
sitem(tt(%a))(An identifier, that describes the action. Only makes sense in
actionformats.)
-sitem(tt(%i))(The current revision number or identifier.)
+sitem(tt(%i))(The current revision number or identifier. For tt(hg)
+the var(hgrevformat) style may be used to customize the output.)
sitem(tt(%c))(The string from the var(stagedstr) style if there are staged
changes in the repository.)
sitem(tt(%u))(The string from the var(unstagedstr) style if there are unstaged
@@ -648,7 +657,7 @@
sitem(tt(%m))(A "misc" replacement. It is at the discretion of the backend
to decide what this replacement expands to. It is currently used by
the tt(hg) and tt(git) backends. The tt(hg) backend replaces tt(%m) with the
-global hash value of the current revision and the tt(git) backend replaces it
+topmost Mq patch applied (qtop) and the tt(git) backend replaces it
with the string from the var(stgitformat) style.)
endsitem()
@@ -656,7 +665,7 @@
startsitem()
sitem(tt(%b))(the branch name)
-sitem(tt(%r))(the current revision number)
+sitem(tt(%r))(the current revision number or the var(hgrevformat) style for tt(hg))
endsitem()
In tt(stgitformat) these replacements are done:
@@ -666,6 +675,13 @@
sitem(tt(%c))(the number of unapplied patches)
endsitem()
+In tt(hgrevformat) these replacements are done:
+
+startsitem()
+sitem(tt(%r))(the current revision number)
+sitem(tt(%h))(the hash identifier for the current resivion in short form)
+endsitem()
+
Not all vcs backends have to support all replacements. For tt(nvcsformats)
no replacements are performed at all. It is just a string.
Attachment:
pgpbVc9lJMcvP.pgp
Description: PGP signature