1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-27 04:40:59 +01:00

Frank Terbeck: 26125: add "command" style to VCS_INFO

This commit is contained in:
Peter Stephenson 2008-12-11 09:53:12 +00:00
parent 37a4dce4bc
commit b4a2d51e57
22 changed files with 86 additions and 26 deletions

View file

@ -1,3 +1,27 @@
2008-12-11 Peter Stephenson <pws@csr.com>
* Frank Terbeck: 26125: Doc/Zsh/contrib.yo,
Functions/VCS_Info/.distfiles,
Functions/VCS_Info/VCS_INFO_check_com,
Functions/VCS_Info/VCS_INFO_get_cmd, Functions/VCS_Info/vcs_info,
Functions/VCS_Info/Backends/VCS_INFO_detect_cdv,
Functions/VCS_Info/Backends/VCS_INFO_detect_cvs,
Functions/VCS_Info/Backends/VCS_INFO_detect_darcs,
Functions/VCS_Info/Backends/VCS_INFO_detect_git,
Functions/VCS_Info/Backends/VCS_INFO_detect_hg,
Functions/VCS_Info/Backends/VCS_INFO_detect_mtn,
Functions/VCS_Info/Backends/VCS_INFO_detect_p4,
Functions/VCS_Info/Backends/VCS_INFO_detect_svk,
Functions/VCS_Info/Backends/VCS_INFO_detect_svn,
Functions/VCS_Info/Backends/VCS_INFO_detect_tla,
Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr,
Functions/VCS_Info/Backends/VCS_INFO_get_data_git,
Functions/VCS_Info/Backends/VCS_INFO_get_data_mtn,
Functions/VCS_Info/Backends/VCS_INFO_get_data_p4,
Functions/VCS_Info/Backends/VCS_INFO_get_data_svn,
Functions/VCS_Info/Backends/VCS_INFO_get_data_tla: add
"command" style for VCS command to use.
2008-12-10 Peter Stephenson <pws@csr.com>
* 26121: Doc/Zsh/calsys.yo, Functions/Calendar/calendar: add

View file

@ -506,6 +506,25 @@ A list of VCSs, you don't want var(vcs_info) to test for
repositories (checked in the var(-init-) context, too). Only used if
tt(enable) contains tt(ALL).
)
kindex(command)
item(tt(command))(
This style causes var(vcs_info) to use the supplied string as the command
to use as the vcs's binary. Note, that setting this in ':vcs_info:*' is
not a good idea.
If the value of this style is empty (which is the default), the used binary
name is the name of the backend in use (e.g. var(svn) is used in a var(svn)
repository).
The var(repo-root-name) part in the context is always the default tt(-all-)
when this style is looked up.
For example, this style can be used to use binaries from non-default
installation directories. Assume, var(git) is installed in /usr/bin, but
your sysadmin installed a newer version in /usr/bin/local. Now, instead of
changing the order of your tt($PATH) parameter, you can do this:
example(zstyle ':vcs_info:git:*:-all-' command /usr/local/bin/git)
)
kindex(use-server)
item(tt(use-server))(
This is used by the Perforce backend (tt(p4)) to decide if it should
@ -547,6 +566,7 @@ sitem(tt(nvcsformats))("")
sitem(tt(max-exports))(2)
sitem(tt(enable))(ALL)
sitem(tt(disable))((empty list))
sitem(tt(command))((empty string))
sitem(tt(use-simple))(false)
sitem(tt(use-prompt-escapes))(true)
endsitem()

View file

@ -5,6 +5,7 @@ VCS_INFO_adjust
VCS_INFO_bydir_detect
VCS_INFO_check_com
VCS_INFO_formats
VCS_INFO_get_cmd
vcs_info_lastmsg
VCS_INFO_maxexports
VCS_INFO_nvcsformats

View file

@ -6,7 +6,7 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && return 1
VCS_INFO_check_com cdv || return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
vcs_comm[detect_need_file]=format
VCS_INFO_bydir_detect '.cdv'
return $?

View file

@ -6,6 +6,6 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && return 1
VCS_INFO_check_com svn || return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
[[ -d "./CVS" ]] && [[ -r "./CVS/Repository" ]] && return 0
return 1

View file

@ -6,7 +6,7 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && return 1
VCS_INFO_check_com darcs || return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
vcs_comm[detect_need_file]=format
VCS_INFO_bydir_detect '_darcs'
return $?

View file

@ -6,8 +6,8 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && { print -l git-p4 git-svn; return 0 }
if VCS_INFO_check_com git && git rev-parse --is-inside-work-tree &> /dev/null ; then
vcs_comm[gitdir]="$(git rev-parse --git-dir 2> /dev/null)" || return 1
if VCS_INFO_check_com ${vcs_comm[cmd]} && ${vcs_comm[cmd]} rev-parse --is-inside-work-tree &> /dev/null ; then
vcs_comm[gitdir]="$(${vcs_comm[cmd]} rev-parse --git-dir 2> /dev/null)" || return 1
if [[ -d ${vcs_comm[gitdir]}/svn ]] ; then vcs_comm[overwrite_name]='git-svn'
elif [[ -d ${vcs_comm[gitdir]}/refs/remotes/p4 ]] ; then vcs_comm[overwrite_name]='git-p4' ; fi
return 0

View file

@ -6,7 +6,7 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && return 1
VCS_INFO_check_com hg || return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
vcs_comm[detect_need_file]=branch
VCS_INFO_bydir_detect '.hg'
return $?

View file

@ -6,7 +6,7 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && return 1
VCS_INFO_check_com mtn || return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
vcs_comm[detect_need_file]=revision
VCS_INFO_bydir_detect '_MTN'
return $?

View file

@ -21,7 +21,7 @@ VCS_INFO_p4_get_server() {
setopt extendedglob
local -a settings
settings=(${(f)"$(p4 set)"})
settings=(${(f)"$(${vcs_comm[cmd]} set)"})
serverport=${${settings[(r)P4PORT=*]##P4PORT=}%% *}
case $serverport in
(''|:)
@ -54,7 +54,7 @@ VCS_INFO_detect_p4() {
VCS_INFO_p4_get_server
[[ -n $vcs_info_p4_dead_servers[$serverport] ]] && return 1
fi
if p4where="$(p4 where 2>&1)"; then
if p4where="$(${vcs_comm[cmd]} where 2>&1)"; then
return 0
fi
if [[ $p4where = *"Connect to server failed"* ]]; then
@ -67,7 +67,7 @@ VCS_INFO_detect_p4() {
return 1
else
[[ -n ${P4CONFIG} ]] || return 1
VCS_INFO_check_com p4 || return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
vcs_comm[detect_need_file]="${P4CONFIG}"
VCS_INFO_bydir_detect .
return $?

View file

@ -17,7 +17,7 @@ setopt localoptions noksharrays extendedglob
local -i fhash
fhash=0
VCS_INFO_check_com svk || return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
[[ -f ~/.svk/config ]] || return 1
while IFS= read -r line ; do

View file

@ -6,6 +6,6 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && return 1
VCS_INFO_check_com svn || return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
[[ -d ".svn" ]] && return 0
return 1

View file

@ -6,6 +6,6 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && return 1
VCS_INFO_check_com tla || return 1
vcs_comm[basedir]="$(tla tree-root 2> /dev/null)" && return 0
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
vcs_comm[basedir]="$(${vcs_comm[cmd]} tree-root 2> /dev/null)" && return 0
return 1

View file

@ -14,8 +14,8 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-simple" ; then
bzrinfo[1]=${${bzrinfo[1]}%% *}
fi
else
bzrbase=${${(M)${(f)"$( bzr info )"}:# ##branch\ root:*}/*: ##/}
bzrinfo=( ${${${(M)${(f)"$( bzr version-info )"}:#(#s)(revno|branch-nick)*}/*: /}/*\//} )
bzrbase=${${(M)${(f)"$( ${vcs_comm[cmd]} info )"}:# ##branch\ root:*}/*: ##/}
bzrinfo=( ${${${(M)${(f)"$( ${vcs_comm[cmd]} version-info )"}:#(#s)(revno|branch-nick)*}/*: /}/*\//} )
bzrbase="$(VCS_INFO_realpath ${bzrbase})"
fi

View file

@ -55,7 +55,7 @@ VCS_INFO_git_getaction () {
VCS_INFO_git_getbranch () {
local gitbranch gitdir=$1
local gitsymref='git symbolic-ref HEAD'
local gitsymref="${vcs_comm[cmd]} symbolic-ref HEAD"
if [[ -d "${gitdir}/rebase-apply" ]] \
|| [[ -d "${gitdir}/rebase" ]] \
@ -77,7 +77,7 @@ VCS_INFO_git_getbranch () {
gitbranch="$(${(z)gitsymref} 2> /dev/null)"
if [[ $? -ne 0 ]] ; then
gitbranch="$(git describe --exact-match HEAD 2>/dev/null)"
gitbranch="$(${vcs_comm[cmd]} describe --exact-match HEAD 2>/dev/null)"
if [[ $? -ne 0 ]] ; then
gitbranch="${${"$(< $gitdir/HEAD)"}[1,7]}..."
@ -98,7 +98,7 @@ fi
VCS_INFO_adjust
gitaction="$(VCS_INFO_git_getaction ${gitdir})"
gitbase=${PWD%/${$( git rev-parse --show-prefix )%/##}}
gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}}
rrn=${gitbase:t}
VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}"
return 0

View file

@ -7,6 +7,6 @@ local mtnbranch mtnbase
mtnbase=${vcs_comm[basedir]}
rrn=${mtnbase:t}
mtnbranch=${${(M)${(f)"$( mtn status )"}:#(#s)Current branch:*}/*: /}
mtnbranch=${${(M)${(f)"$( ${vcs_comm[cmd]} status )"}:#(#s)Current branch:*}/*: /}
VCS_INFO_formats '' "${mtnbranch}" "${mtnbase}"
return 0

View file

@ -7,7 +7,7 @@ setopt localoptions extendedglob
local p4base a b
local -A p4info
p4 info | while IFS=: read a b; do p4info[${a// /_}]="${b## #}"; done
${vcs_comm[cmd]} info | while IFS=: read a b; do p4info[${a// /_}]="${b## #}"; done
p4base=${vcs_comm[basedir]}
# We'll use the client name as the branch; close enough.
@ -15,7 +15,7 @@ local p4branch change
# We'll use the latest change number to which the hierarchy from
# here down is synced as the revision.
# I suppose the following might be slow on a tortuous client view.
change="${${$(p4 changes -m 1 ...\#have)##Change }%% *}"
change="${${$(${vcs_comm[cmd]} changes -m 1 ...\#have)##Change }%% *}"
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat p4branch ||
p4branch="%b:%r"
zformat -f p4branch "${p4branch}" "b:${p4info[Client_name]}" \

View file

@ -10,10 +10,10 @@ local -A svninfo parentinfo
svnbase=".";
svninfo=()
svn info --non-interactive | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done
${vcs_comm[cmd]} info --non-interactive | while IFS=: read a b; do svninfo[${a// /_}]="${b## #}"; done
while [[ -d "${svnbase}/../.svn" ]]; do
parentinfo=()
svn info --non-interactive "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done
${vcs_comm[cmd]} info --non-interactive "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done
[[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break
svninfo=(${(kv)parentinfo})
svnbase="${svnbase}/.."

View file

@ -8,6 +8,6 @@ local tlabase tlabranch
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=${${"$( tla tree-id )"}/*\//}
tlabranch=${${"$( ${vcs_comm[cmd]} tree-id )"}/*\//}
VCS_INFO_formats '' "${tlabranch}" "${tlabase}"
return 0

View file

@ -4,5 +4,12 @@
setopt localoptions NO_shwordsplit
(( ${+commands[$1]} )) && [[ -x ${commands[$1]} ]] && return 0
case $1 in
(/*)
[[ -x $1 ]] && return 0
;;
(*)
(( ${+commands[$1]} )) && [[ -x ${commands[$1]} ]] && return 0
esac
return 1

View file

@ -0,0 +1,6 @@
## vim:ft=zsh
# find out if the user wants us to use a special binary.
# the default command name is the same as the backend name.
local cmd
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" "command" cmd
vcs_comm[cmd]=${cmd:-$vcs}

View file

@ -17,6 +17,7 @@ static_functions=(
VCS_INFO_bydir_detect
VCS_INFO_check_com
VCS_INFO_formats
VCS_INFO_get_cmd
VCS_INFO_maxexports
VCS_INFO_nvcsformats
VCS_INFO_realpath
@ -74,6 +75,7 @@ vcs_info () {
continue
fi
vcs_comm=()
VCS_INFO_get_cmd
VCS_INFO_detect_${vcs} && (( found = 1 )) && break
done