From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14980 invoked from network); 4 Oct 2009 16:17:28 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 4 Oct 2009 16:17:28 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 67814 invoked from network); 4 Oct 2009 16:17:23 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Oct 2009 16:17:23 -0000 Received: (qmail 13127 invoked by alias); 4 Oct 2009 16:17:18 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27306 Received: (qmail 13116 invoked from network); 4 Oct 2009 16:17:18 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 4 Oct 2009 16:17:18 -0000 Received: from mail-ew0-f222.google.com (mail-ew0-f222.google.com [209.85.219.222]) by bifrost.dotsrc.org (Postfix) with ESMTP id 3AF16805D0A6 for ; Sun, 4 Oct 2009 18:16:59 +0200 (CEST) Received: by ewy22 with SMTP id 22so2122871ewy.38 for ; Sun, 04 Oct 2009 09:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=oWeqmud0SdFZHbmsgCWsgFmmjUdCHXQk8HjWjbLw76Y=; b=Xl6g7jmTJ7MyH9JAuofXVY5xseSyW+9ZGhHJKR7nuOVsbsn9+8tWAOI90MnamEUF+E xt+0OcgtRbNR2slMUdFtZeEEbC0sK3wz4Zf1lIUa1G20SrWmAl0ED24y4APqbnV19qi+ +53xiWLBxb+o9lZ5VJEqTi3LwsUvUHKwyJGOI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=CAK+tWHPbLkLS791TPcGnOwmchgnD7bxEiVpA/NcK3qqCEu4K4pyhvlrUU5RmQgRxi ySujTnpvCIFbTx8defzwtkhvzDnj6cmuJtpGxCsLeSFi2Al0lcHCFRkTI6uGdE9wT2VI J7gDx/MIV9uuh43wE0NhUlwD7eOG6cx4VbZ80= Received: by 10.216.11.67 with SMTP id 45mr852516wew.44.1254673019337; Sun, 04 Oct 2009 09:16:59 -0700 (PDT) Received: from localhost (home.svkt.org [82.243.51.8]) by mx.google.com with ESMTPS id u14sm4848680gvf.14.2009.10.04.09.16.57 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 04 Oct 2009 09:16:58 -0700 (PDT) Date: Sun, 4 Oct 2009 18:16:56 +0200 From: Lionel Flandrin To: Zsh workers Cc: Frank Terbeck Subject: [PATCH] Add Mercurial Queues support to VCS_Info Message-ID: <20091004161656.GA3584@shame> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="f+W+jCU1fRNres8c" Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Virus-Scanned: ClamAV 0.94.2/9866/Sat Oct 3 16:49:15 2009 on bifrost X-Virus-Status: Clean --f+W+jCU1fRNres8c Content-Type: multipart/mixed; boundary="H+4ONPRPur6+Ovig" Content-Disposition: inline --H+4ONPRPur6+Ovig Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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, --=20 Lionel Flandrin --H+4ONPRPur6+Ovig Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=vcs_info-mq-support Content-Transfer-Encoding: quoted-printable Support for Mercurial Queues in VCS_INFO diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/V= CS_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. =20 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_i= nfo revformat + +VCS_INFO_hg_get_mq_top_patch () { + local patchdir=3D$1 + + if [[ -e "${patchdir}/status" ]]; then + local -a patches + patches=3D(${(f)"$(< "${patchdir}/status")"}) + printf "%s" "${patches[-1]/[^:]*:/}" + return 0 + fi + + return 1 +} + =20 hgbase=3D${vcs_comm[basedir]} rrn=3D${hgbase:t} @@ -34,6 +48,8 @@ done =20 if [[ -n ${hglrev} ]] ; then + zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" hgrevformat rev= format || revformat=3D"%r:%h" + zformat -f hglrev "${revformat}" "r:${hglrev}" "h:${hghash}" zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat hg= branch || hgbranch=3D"%b:%r" zformat -f hgbranch "${hgbranch}" "b:${hgbranch_name}" "r:${hglrev= }" fi @@ -41,5 +57,15 @@ hgbranch=3D"${hgbranch_name}" fi =20 -VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' "${hglrev}" "${hghash}" +local patchdir=3D${hgbase}/.hg/patches/ + +if [[ -d $patchdir ]] ; then + hgmisc=3D$(VCS_INFO_hg_get_mq_top_patch "${patchdir}") + + hgmisc=3D${hgmisc:-"no patch applied"} +else + hgmisc=3D'' +fi + +VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' "${hglrev}" "${hgmisc}" return 0 --H+4ONPRPur6+Ovig Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=vcs_info-mq-doc Content-Transfer-Encoding: quoted-printable 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 unst= aged @@ -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 t= he -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() =20 @@ -656,7 +665,7 @@ =20 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 fo= r tt(hg)) endsitem() =20 In tt(stgitformat) these replacements are done: @@ -666,6 +675,13 @@ sitem(tt(%c))(the number of unapplied patches) endsitem() =20 +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. =20 --H+4ONPRPur6+Ovig-- --f+W+jCU1fRNres8c Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.13 (GNU/Linux) iEYEAREKAAYFAkrIyngACgkQlfFEoIrYgB2V2wCdEr7eOWQkgG637HdsHvcP6+B0 PNwAoIaMSmtKClOMeb7buIqwWSTU2XGZ =7Fkl -----END PGP SIGNATURE----- --f+W+jCU1fRNres8c--