From: Lionel Flandrin <simias.n@gmail.com>
To: Zsh workers <zsh-workers@sunsite.dk>
Cc: Frank Terbeck <ft@bewatermyfriend.org>
Subject: [PATCH] Add Mercurial Queues support to VCS_Info
Date: Sun, 4 Oct 2009 18:16:56 +0200 [thread overview]
Message-ID: <20091004161656.GA3584@shame> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 611 bytes --]
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
[-- Attachment #1.2: vcs_info-mq-support --]
[-- Type: text/plain, Size: 1770 bytes --]
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
[-- Attachment #1.3: vcs_info-mq-doc --]
[-- Type: text/plain, Size: 2835 bytes --]
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 #2: Type: application/pgp-signature, Size: 198 bytes --]
next reply other threads:[~2009-10-04 16:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-04 16:16 Lionel Flandrin [this message]
2009-10-04 16:46 ` Frank Terbeck
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=20091004161656.GA3584@shame \
--to=simias.n@gmail.com \
--cc=ft@bewatermyfriend.org \
--cc=zsh-workers@sunsite.dk \
/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).