1## vim:ft=zsh 2## subversion support by: 3## + Frank Terbeck <ft@bewatermyfriend.org> 4## + Phil Pennock 5## Distributed under the same BSD-ish license as zsh itself. 6 7setopt localoptions noksharrays extendedglob NO_shwordsplit 8local svnbase svnbranch a b rrn 9local -i rc 10local -A svninfo parentinfo 11local -xA hook_com 12 13svnbase="."; 14svninfo=() 15# Unfortunately, `$pipestatus' is broken currently. Until that problem is 16# resolved, here is a workaround that will get things done, without using it. 17# Clumsily, but that's life. 18local -a dat 19dat=( ${(f)"$(${vcs_comm[cmd]} info --non-interactive 2>&1)"} ) 20rc=$? 21(( rc != 0 )) && return 1 22# The following line is the real code, the following is the workaround. 23#${vcs_comm[cmd]} info --non-interactive \ 24print -l "${dat[@]}" \ 25|& while IFS=: read a b; do 26 svninfo[${a// /_}]="${b## #}" 27done 28#rc=${pipestatus[1]} 29#(( rc != 0 )) && return 1 30 31while [[ -d "${svnbase}/../.svn" ]]; do 32 parentinfo=() 33 ${vcs_comm[cmd]} info --non-interactive "${svnbase}/.." | while IFS=: read a b; do parentinfo[${a// /_}]="${b## #}"; done 34 [[ ${parentinfo[Repository_UUID]} != ${svninfo[Repository_UUID]} ]] && break 35 svninfo=(${(kv)parentinfo}) 36 svnbase="${svnbase}/.." 37done 38 39svnbase="$(VCS_INFO_realpath ${svnbase})" 40 41rrn=${svnbase:t} 42zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r" 43hook_com=( branch "${svninfo[URL]##*/}" revision "${svninfo[Revision]}" ) 44if VCS_INFO_hook 'set-branch-format' "${svnbranch}"; then 45 zformat -f svnbranch "${svnbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}" 46else 47 svnbranch=${hook_com[branch-replace]} 48fi 49hook_com=() 50VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' '' "${svninfo[Revision]}" '' 51return 0 52