about summary refs log tree commit diff
path: root/Functions/VCS_Info/Backends/VCS_INFO_get_data_svn
blob: ae3c499593915e2f1e2d6eafce5dced065f2ed67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## vim:ft=zsh
## subversion support by:
##  + Frank Terbeck <ft@bewatermyfriend.org>
##  + Phil Pennock
## Distributed under the same BSD-ish license as zsh itself.

setopt localoptions noksharrays extendedglob NO_shwordsplit
local svnbase svnbranch a b rrn
local -i rc
local -A svninfo parentinfo cwdinfo
local -xA hook_com

svnbase=".";
svninfo=()
# Unfortunately, `$pipestatus' is broken currently. Until that problem is
# resolved, here is a workaround that will get things done, without using it.
# Clumsily, but that's life.
local -a dat
dat=( ${(f)"$(${vcs_comm[cmd]} info --non-interactive 2>&1)"} )
rc=$?
(( rc != 0 )) && return 1
# The following line is the real code, the following is the workaround.
#${vcs_comm[cmd]} info --non-interactive \
print -l "${dat[@]}" \
|& while IFS=: read a b; do
    svninfo[${a// /_}]="${b## #}"
done
#rc=${pipestatus[1]}
#(( rc != 0 )) && return 1

cwdinfo=(${(kv)svninfo})

while [[ -d "${svnbase}/../.svn" ]]; do
    parentinfo=()
    ${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}/.."
done

svnbase="$(VCS_INFO_realpath ${svnbase})"

rrn=${svnbase:t}
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat svnbranch || svnbranch="%b:%r"
hook_com=( branch "${svninfo[URL]##*/}" revision "${cwdinfo[Revision]}" )
if VCS_INFO_hook 'set-branch-format' "${svnbranch}"; then
    zformat -f svnbranch "${svnbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
else
    svnbranch=${hook_com[branch-replace]}
fi
hook_com=()
VCS_INFO_formats '' "${svnbranch}" "${svnbase}" '' '' "${cwdinfo[Revision]}" ''
return 0