summaryrefslogtreecommitdiff
path: root/.zsh/functions/VCS_INFO_get_data_bzr
blob: 374988afd81f32174951de7f4dd20d6256c8e324 (plain)
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
## vim:ft=zsh
## bazaar support by: Frank Terbeck <ft@bewatermyfriend.org>
## Distributed under the same BSD-ish license as zsh itself.

## Modified by René 'Necoro' Neumann <necoro@necoro.net>

setopt localoptions noksharrays extendedglob NO_shwordsplit
local bzrbase bzrbr
local -a bzrinfo
local bzrunstaged

if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-simple" ; then
    bzrbase=${vcs_comm[basedir]}
    bzrinfo[2]=${bzrbase:t}
    if [[ -f ${bzrbase}/.bzr/branch/last-revision ]] ; then
        bzrinfo[1]=$(< ${bzrbase}/.bzr/branch/last-revision)
        bzrinfo[1]=${${bzrinfo[1]}%% *}
    fi
else
    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})"
    
    if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" ; then
        [[ -n $(${vcs_comm[cmd]} status -S -V 2> /dev/null) && $? == 0 ]] && bzrunstaged=1
    fi
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}" '' "${bzrunstaged}" "${bzrinfo[1]}" ''
return 0