zsh-workers
 help / color / mirror / code / Atom feed
b30e0e12ba1edada0fdf9b72e942e46640a40880 blob 3623 bytes (raw)

  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
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 
## vim:ft=zsh et
## bazaar support by: Frank Terbeck <ft@bewatermyfriend.org>
## mostly rewritten by: Jan Pobrislo <ccx@webprojekty.cz>
## Distributed under the same BSD-ish license as zsh itself.

setopt localoptions noksharrays extendedglob NO_shwordsplit
local bzrbase bzrbr bzr_changes bzr_type
local -a bzrinfo
local -A hook_com bzr_info

(( ${+functions[VCS_INFO_bzr_get_info]} )) ||
VCS_INFO_bzr_get_info() {
    bzrinfo=( ${(s.:.)$( ${vcs_comm[cmd]} version-info --custom \
        --template="{revno}:{branch_nick}:{clean}")} )
    if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes"
    then
        VCS_INFO_bzr_get_changes
    elif [[ ${bzrinfo[2]} == 1 ]]
    then
        bzr_changes = '1'
    fi
}

(( ${+functions[VCS_INFO_bzr_get_info_restricted]} )) ||
VCS_INFO_bzr_get_info_restricted() {
    # we are forbidden from fetching info on bound branch from remote repository
    bzrinfo=( $(${vcs_comm[cmd]} revno) ${bzrbase:t} )
    if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" && \
       [[ ! $bzr_type == lightweigth ]]
    then
        VCS_INFO_bzr_get_changes
    fi
}

(( ${+functions[VCS_INFO_bzr_get_changes]} )) ||
VCS_INFO_bzr_get_changes() {
    local -A counts
    local line flag
    bzr_changes=$(
        ${vcs_comm[cmd]} stat -SV | while read flag line
        do
            counts[${flag}]=$(( ${counts[${flag}]:-0} + 1 ))
        done
        for flag in ${(k)counts}
        do
            printf "%s:%d " $flag ${counts[${flag}]}
        done
    )
}

if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-simple" ; then
    # simple parsing will fail to fetch information from lightweigth checkouts
    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
    # Parse the output of 'bzr info' into associative array bzr_info
    ${vcs_comm[cmd]} info | {
        local line key value dirtype
        read dirtype
        grep '^[ a-zA-Z0-9]\+: ' | while read line
        do
            value=${line#*': '}
            key=${${line%%: *}// /_}
            bzr_info[$key]=$value
        done
    }

    case "$dirtype" in
        ('Checkout'*)
            bzr_type=checkout
            bzrbase=${bzr_info[checkout_root]} ;;
        ('Repository checkout'*)
            bzr_type=checkout
            bzrbase=${bzr_info[repository_checkout_root]} ;;
        ('Lightweight checkout'*)
            bzr_type=lightweigth
            bzrbase=${bzr_info[light_checkout_root]} ;;
        (*)
            bzr_type=standalone
            bzrbase=${bzr_info[branch_root]} ;;
    esac

    bzrbase=${bzrbase:P}

    if [ -n "${bzr_info[checkout_of_branch]}" ] && \
       zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-server"
    then
        VCS_INFO_bzr_get_info
    else
        case ${bzr_info[checkout_of_branch]} in
            (file://*) VCS_INFO_bzr_get_info ;;
            (*://*) VCS_INFO_bzr_get_info_restricted ;;
            (*) VCS_INFO_bzr_get_info ;;
        esac
    fi
fi

rrn=${bzrbase:t}
zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat bzrbr || bzrbr="%b:%r"
hook_com=( branch "${bzrinfo[2]}" revision "${bzrinfo[1]}" )
if VCS_INFO_hook 'set-branch-format' "${bzrbr}"; then
    zformat -f bzrbr "${bzrbr}" "b:${hook_com[branch]}" "r:${hook_com[revision]}"
else
    bzrbr=${hook_com[branch-replace]}
fi
hook_com=()

VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' "${bzr_changes}" "${bzrinfo[1]}" "${bzr_changes}"
return 0
debug log:

solving b30e0e12b ...
found b30e0e12b in https://git.vuxu.org/mirror/zsh/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).