diff options
author | Peter Stephenson <pws@users.sourceforge.net> | 2009-04-06 19:19:08 +0000 |
---|---|---|
committer | Peter Stephenson <pws@users.sourceforge.net> | 2009-04-06 19:19:08 +0000 |
commit | 8dd8067f13e5aaf2fc740748b0afeca00b1ea424 (patch) | |
tree | 0d189361f983668aebbf590cc8e7bd9ec24b0b6b | |
parent | b148a56869958ee691c57ddaf633a8a4e038b3dc (diff) | |
download | zsh-8dd8067f13e5aaf2fc740748b0afeca00b1ea424.tar.gz zsh-8dd8067f13e5aaf2fc740748b0afeca00b1ea424.tar.xz zsh-8dd8067f13e5aaf2fc740748b0afeca00b1ea424.zip |
Frank Terbeck: 26816 to 26820: VCS_Info updates
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | Doc/Zsh/contrib.yo | 17 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_cdv | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_darcs | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 17 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_svk | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_svn | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_tla | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_formats | 21 |
14 files changed, 71 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog index c9b0ca9d4..a07eafa4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-04-06 Peter Stephenson <p.w.stephenson@ntlworld.com> + + * Frank Terbeck <ft@bewatermyfriend.org>: Functions/VCS_Info/*: + 26816: vcs_info: add revision and "misc" argument to + VCS_INFO_formats(); 26817: updates for get-revision, %i and %m; + 26818: Add git's sha1 hash as revision information; 26819: Add + information about hg's local revision number and the commit's + hash; 26820: Make the hg backend work with new versions of + mercurial. + 2009-04-06 Peter Stephenson <pws@csr.com> * 26806 (doc tweaked): Add CORRECT_IGNORE variable for pattern to @@ -11518,5 +11528,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.4643 $ +* $Revision: 1.4644 $ ***************************************************** diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 2eb26ab99..7412f810d 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -579,6 +579,17 @@ the default is to use the not-that-simple code, which is potentially a lot slower but might be more accurate in all possible cases. This style is only used by the tt(bzr) backend. ) +kindex(get-revision) +item(tt(get-revision))( +If set to true, vcs_info goes the extra mile to figure out the revision of +a repository's work tree (currently for the tt(git) and tt(hg) backends, +where this kind of information is not always vital). For tt(git), the +hash value of the currently checked out commit is available via the tt(%i) +expansion. With tt(hg), the local revision number is available via tt(%i) +and the corresponding global hash is available via tt(%m). +If this style is set in the tt(hg) context, the backend supports the +branchformat style. +) kindex(use-prompt-escapes) item(tt(use-prompt-escapes))( Determines if we assume that the assembled @@ -604,6 +615,7 @@ sitem(tt(unstagedstr))((string: "U")) sitem(tt(command))((empty string)) sitem(tt(use-server))(false) sitem(tt(use-simple))(false) +sitem(tt(get-revision))(false) sitem(tt(use-prompt-escapes))(true) endsitem() @@ -615,6 +627,7 @@ sitem(tt(%s))(The vcs in use (git, hg, svn etc.)) 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(%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 @@ -624,6 +637,10 @@ sitem(tt(%r))(repository name. If tt(%R) is var(/foo/bar/repoXY), tt(%r) is var(repoXY).) sitem(tt(%S))(subdirectory within a repository. If tt($PWD) is var(/foo/bar/reposXY/beer/tasty), tt(%S) is var(beer/tasty).) +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 only by +the tt(hg) backend. The hg backend replaces tt(%m) with the global hash +value of the current revision.) endsitem() In tt(branchformat) these replacements are done: diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr index 1030c06ab..e85de311e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr @@ -22,5 +22,5 @@ fi rrn=${bzrbase:t} zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat bzrbr || bzrbr="%b:%r" zformat -f bzrbr "${bzrbr}" "b:${bzrinfo[2]}" "r:${bzrinfo[1]}" -VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' '' +VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' '' "${bzrinfo[1]}" '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cdv b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cdv index 2c516ea4b..4f8118489 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cdv +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cdv @@ -7,5 +7,5 @@ local cdvbase cdvbase=${vcs_comm[basedir]} rrn=${cdvbase:t} -VCS_INFO_formats '' "${cdvbase:t}" "${cdvbase}" '' '' +VCS_INFO_formats '' "${cdvbase:t}" "${cdvbase}" '' '' '' '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs index 1c222ceec..ed738b98f 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_cvs @@ -14,5 +14,5 @@ cvsbranch=$(< ./CVS/Repository) rrn=${cvsbase:t} cvsbranch=${cvsbranch##${rrn}/} [[ -z ${cvsbranch} ]] && cvsbranch=${rrn} -VCS_INFO_formats '' "${cvsbranch}" "${cvsbase}" '' '' +VCS_INFO_formats '' "${cvsbranch}" "${cvsbase}" '' '' '' '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_darcs b/Functions/VCS_Info/Backends/VCS_INFO_get_data_darcs index a1ebbb6ea..3f6a22646 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_darcs +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_darcs @@ -7,5 +7,5 @@ local darcsbase darcsbase=${vcs_comm[basedir]} rrn=${darcsbase:t} -VCS_INFO_formats '' "${darcsbase:t}" "${darcsbase}" '' '' +VCS_INFO_formats '' "${darcsbase:t}" "${darcsbase}" '' '' '' '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git index 75d39cc4a..faab2b88a 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git @@ -3,7 +3,7 @@ ## Distributed under the same BSD-ish license as zsh itself. setopt localoptions extendedglob NO_shwordsplit -local gitdir gitbase gitbranch gitaction gitunstaged gitstaged +local gitdir gitbase gitbranch gitaction gitunstaged gitstaged gitsha1 VCS_INFO_git_getaction () { local gitaction='' gitdir=$1 @@ -77,7 +77,7 @@ VCS_INFO_git_getbranch () { gitbranch="$(${(z)gitsymref} 2> /dev/null)" if [[ $? -ne 0 ]] ; then - gitbranch="$(${vcs_comm[cmd]} describe --exact-match HEAD 2>/dev/null)" + gitbranch="refs/tags/$(${vcs_comm[cmd]} describe --exact-match HEAD 2>/dev/null)" if [[ $? -ne 0 ]] ; then gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..." @@ -85,12 +85,21 @@ VCS_INFO_git_getbranch () { fi fi - printf '%s' "${gitbranch##refs/heads/}" + printf '%s' "${gitbranch}" return 0 } gitdir=${vcs_comm[gitdir]} gitbranch="$(VCS_INFO_git_getbranch ${gitdir})" +if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision && \ + [[ ${gitbranch} == refs/* ]] && \ + [[ -r "${gitdir}/${gitbranch}" ]] ; then + + gitsha1="${"$(< $gitdir/$gitbranch)"}" +else + gitsha1='' +fi +gitbranch="${gitbranch##refs/[^/]##/}" if [[ -z ${gitdir} ]] || [[ -z ${gitbranch} ]] ; then return 1 @@ -108,5 +117,5 @@ VCS_INFO_adjust gitaction="$(VCS_INFO_git_getaction ${gitdir})" gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}} rrn=${gitbase:t} -VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" +VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index fb7c45087..d70e03c00 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -8,5 +8,5 @@ local hgbranch hgbase hgbase=${vcs_comm[basedir]} rrn=${hgbase:t} hgbranch=$(< ${hgbase}/.hg/branch) -VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' +VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' '' '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn index 63f060163..0a8064c36 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn @@ -8,5 +8,5 @@ local mtnbranch mtnbase mtnbase=${vcs_comm[basedir]} rrn=${mtnbase:t} mtnbranch=${${(M)${(f)"$( ${vcs_comm[cmd]} status )"}:#(#s)Current branch:*}/*: /} -VCS_INFO_formats '' "${mtnbranch}" "${mtnbase}" '' '' +VCS_INFO_formats '' "${mtnbranch}" "${mtnbase}" '' '' '' '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 index ac87fafe5..e4bbb06c4 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_p4 @@ -21,4 +21,4 @@ p4branch="%b:%r" zformat -f p4branch "${p4branch}" "b:${p4info[Client_name]}" \ "r:$change" -VCS_INFO_formats '' "${p4branch}" "${p4base}" '' '' +VCS_INFO_formats '' "${p4branch}" "${p4base}" '' '' "$change" '' diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svk b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svk index 48e5edb2c..29cda818c 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svk +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svk @@ -9,5 +9,5 @@ svkbase=${vcs_comm[basedir]} rrn=${svkbase:t} zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svkbranch || svkbranch="%b:%r" zformat -f svkbranch "${svkbranch}" "b:${vcs_comm[branch]}" "r:${vcs_comm[revision]}" -VCS_INFO_formats '' "${svkbranch}" "${svkbase}" '' '' +VCS_INFO_formats '' "${svkbranch}" "${svkbase}" '' '' "${${vcs_comm[revision]}" '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn index e18080585..75da22bda 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn @@ -24,5 +24,5 @@ svnbase="$(VCS_INFO_realpath ${svnbase})" rrn=${svnbase:t} zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r" zformat -f svnbranch "${svnbranch}" "b:${svninfo[URL]##*/}" "r:${svninfo[Revision]}" -VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' '' +VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' '' "${svninfo[Revision]}" '' return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla index 69a82eb19..f015e0cce 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_tla @@ -9,5 +9,5 @@ tlabase="$(VCS_INFO_realpath ${vcs_comm[basedir]})" rrn=${tlabase:t} # tree-id gives us something like 'foo@example.com/demo--1.0--patch-4', so: tlabranch=${${"$( ${vcs_comm[cmd]} tree-id )"}/*\//} -VCS_INFO_formats '' "${tlabranch}" "${tlabase}" '' '' +VCS_INFO_formats '' "${tlabranch}" "${tlabase}" '' '' '' '' return 0 diff --git a/Functions/VCS_Info/VCS_INFO_formats b/Functions/VCS_Info/VCS_INFO_formats index 72030ccdc..35b3b963d 100644 --- a/Functions/VCS_Info/VCS_INFO_formats +++ b/Functions/VCS_Info/VCS_INFO_formats @@ -3,7 +3,24 @@ ## Distributed under the same BSD-ish license as zsh itself. setopt localoptions noksharrays NO_shwordsplit -local action=$1 branch=$2 base=$3 staged=$4 unstaged=$5 +local action=$1 branch=$2 base=$3 staged=$4 unstaged=$5 rev=$6 misc=$7 + +## description: +# action: a string that signals a certain non-default condition in the +# repository (like 'rebase-i' in git). If this in non-empty, +# the actionformats will be used, too. +# branch: the name of the currently checked out branch. +# base: the full name of the repository's root directory. +# staged: non-empty if the repository contains staged changes. +# unstaged: non-empty if the repository contains unstaged changes. +# rev: an identifier of the currently checked out revision. +# misc: a string that may contain anything the author likes. +# the backends should document what they put in it and when. +# +# If an argument has no valid value for a given backend, an empty value +# should be provided. eg: +# VCS_INFO_formats '' "${foobranch}" "${foobase}" '' '' '' "${foomisc}" + local msg local -i i j @@ -31,6 +48,8 @@ for i in {1..${#msgs}} ; do a:${action} \ b:${branch} \ c:${staged} \ + i:${rev} \ + m:${misc} \ r:${base:t} \ s:${vcs} \ u:${unstaged} \ |