summaryrefslogtreecommitdiff
path: root/Functions/VCS_Info
diff options
context:
space:
mode:
authorFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
committerFrank Terbeck <ft@bewatermyfriend.org>2011-12-01 10:02:04 +0100
commitd8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca (patch)
tree9fd9a57486ac4702608d92088ffd91f52971244f /Functions/VCS_Info
parentaf2bb4fdb09414d21922d3fafe4e3a0ac1332f01 (diff)
parent9d71f4c207fb34e8d64af0443c83231b1cc3b494 (diff)
downloadzsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.tar.gz
zsh-d8da5ea2f2bc5f837d0b364fff2636ebdb2f90ca.zip
Merge commit 'zsh-4.3.13' into debian
Diffstat (limited to 'Functions/VCS_Info')
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_detect_svn4
-rw-r--r--Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr89
-rw-r--r--Functions/VCS_Info/vcs_info3
3 files changed, 88 insertions, 8 deletions
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_svn b/Functions/VCS_Info/Backends/VCS_INFO_detect_svn
index a777ecc43..43dedcde9 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_detect_svn
+++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_svn
@@ -7,5 +7,5 @@ setopt localoptions NO_shwordsplit
[[ $1 == '--flavours' ]] && return 1
VCS_INFO_check_com ${vcs_comm[cmd]} || return 1
-{ [[ -f ".svn/entries" ]] || [[ -f ".svn/format" ]] } && return 0
-return 1
+vcs_comm[detect_need_file]="entries format"
+VCS_INFO_bydir_detect '.svn' || return 1
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
index 5d4deaac9..cae1a3b08 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr
@@ -1,13 +1,52 @@
-## vim:ft=zsh
+## 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
+local bzrbase bzrbr bzr_changes bzr_type
local -a bzrinfo
-local -xA hook_com
+local -xA hook_com bzr_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
+}
+
+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
+}
+
+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
@@ -15,9 +54,46 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "use-simple" ; then
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)*}/*: /}/*\//} )
+ # 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="$(VCS_INFO_realpath ${bzrbase})"
+
+ 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}
@@ -29,5 +105,6 @@ else
bzrbr=${hook_com[branch-replace]}
fi
hook_com=()
-VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' '' "${bzrinfo[1]}" ''
+
+VCS_INFO_formats '' "${bzrbr}" "${bzrbase}" '' "${bzr_changes}" "${bzrinfo[1]}" "${bzr_changes}"
return 0
diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info
index 513489b70..5a421dfed 100644
--- a/Functions/VCS_Info/vcs_info
+++ b/Functions/VCS_Info/vcs_info
@@ -70,6 +70,9 @@ vcs_info () {
if (( retval == 1 )); then
return 0
elif (( retval == 2 )); then
+ # This needs `max-exports' set. We're still setting it again later
+ # for more specific contexts.
+ VCS_INFO_maxexports
VCS_INFO_set --nvcs
return 0
fi