diff options
Diffstat (limited to 'Functions/VCS_Info')
-rw-r--r-- | Functions/VCS_Info/.distfiles | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/.distfiles | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_detect_fossil | 13 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_detect_hg | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_detect_svn | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil | 24 | ||||
-rw-r--r-- | Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 2 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_bydir_detect | 10 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_hook | 18 | ||||
-rw-r--r-- | Functions/VCS_Info/VCS_INFO_set | 6 | ||||
-rw-r--r-- | Functions/VCS_Info/vcs_info | 7 | ||||
-rw-r--r-- | Functions/VCS_Info/vcs_info_hookadd | 22 | ||||
-rw-r--r-- | Functions/VCS_Info/vcs_info_hookdel | 45 |
13 files changed, 138 insertions, 17 deletions
diff --git a/Functions/VCS_Info/.distfiles b/Functions/VCS_Info/.distfiles index 988e7ada4..b6e55d2fc 100644 --- a/Functions/VCS_Info/.distfiles +++ b/Functions/VCS_Info/.distfiles @@ -1,6 +1,8 @@ DISTFILES_SRC=' .distfiles vcs_info +vcs_info_hookadd +vcs_info_hookdel VCS_INFO_adjust VCS_INFO_bydir_detect VCS_INFO_check_com diff --git a/Functions/VCS_Info/Backends/.distfiles b/Functions/VCS_Info/Backends/.distfiles index 46e9d6e67..67fb06cda 100644 --- a/Functions/VCS_Info/Backends/.distfiles +++ b/Functions/VCS_Info/Backends/.distfiles @@ -4,6 +4,7 @@ VCS_INFO_detect_bzr VCS_INFO_detect_cdv VCS_INFO_detect_cvs VCS_INFO_detect_darcs +VCS_INFO_detect_fossil VCS_INFO_detect_git VCS_INFO_detect_hg VCS_INFO_detect_mtn @@ -15,6 +16,7 @@ VCS_INFO_get_data_bzr VCS_INFO_get_data_cdv VCS_INFO_get_data_cvs VCS_INFO_get_data_darcs +VCS_INFO_get_data_fossil VCS_INFO_get_data_git VCS_INFO_get_data_hg VCS_INFO_get_data_mtn diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_fossil b/Functions/VCS_Info/Backends/VCS_INFO_detect_fossil new file mode 100644 index 000000000..551528361 --- /dev/null +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_fossil @@ -0,0 +1,13 @@ +## vim:ft=zsh +## fossil support by: Mike Meyer <mwm@mired.org> +## Distributed under the same BSD-ish license as zsh itself. + +setopt localoptions NO_shwordsplit + +[[ $1 == '--flavours' ]] && return 1 + +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 +vcs_comm[detect_need_file]=_FOSSIL_ +VCS_INFO_bydir_detect . || return 1 + +return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg index e2866afd5..a22c1ee0f 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_detect_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_hg @@ -7,7 +7,7 @@ setopt localoptions NO_shwordsplit [[ $1 == '--flavours' ]] && { print -l hg-git hg-hgsubversion hg-hgsvn; return 0 } VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 -vcs_comm[detect_need_file]=store +vcs_comm[detect_need_file]="store data" VCS_INFO_bydir_detect '.hg' || return 1 if [[ -d ${vcs_comm[basedir]}/.hg/svn ]] ; then diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_svn b/Functions/VCS_Info/Backends/VCS_INFO_detect_svn index bb9d083ac..a777ecc43 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 -[[ -d ".svn" ]] && return 0 +{ [[ -f ".svn/entries" ]] || [[ -f ".svn/format" ]] } && return 0 return 1 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil b/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil new file mode 100644 index 000000000..fd0f8389e --- /dev/null +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil @@ -0,0 +1,24 @@ +## vim:ft=zsh +## fossil support by: Mike Meyer (mwm@mired.org) +## Distributed under the same BSD-ish license as zsh itself. + +setopt localoptions extendedglob +local a b +local -A fsinfo +local fshash fsbranch changed merging action + +${vcs_comm[cmd]} status | + while IFS=: read a b; do + fsinfo[${a//-/_}]="${b## #}" + done + +fshash=${fsinfo[checkout]%% *} +fsbranch=${fsinfo[tags]%%, *} +changed=${(Mk)fsinfo:#(ADDED|EDITED|DELETED|UPDATED)*} +merging=${(Mk)fsinfo:#*_BY_MERGE*} +if [ -n "$merging" ]; then + action="merging" +fi + +VCS_INFO_formats "$action" "${fsbranch}" "${fsinfo[local_root]}" '' "$changed" "${fshash}" "${fsinfo[repository]}" +return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index 8e91d2651..a1b87f59e 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -50,7 +50,7 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then "check-for-changes" || hgid_args+=( -r. ) local HGRCPATH - HGRCPATH="/dev/null" ${vcs_comm[cmd]} ${(z)hgid_args} \ + HGRCPATH="/dev/null" ${vcs_comm[cmd]} ${(z)hgid_args} 2> /dev/null \ | read -r r_csetid r_lrev r_branch fi fi diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect index 0b5996fd8..70b0fb6fa 100644 --- a/Functions/VCS_Info/VCS_INFO_bydir_detect +++ b/Functions/VCS_Info/VCS_INFO_bydir_detect @@ -4,15 +4,17 @@ setopt localoptions NO_shwordsplit local dirname=$1 -local basedir="." realbasedir +local basedir="." realbasedir file realbasedir="$(VCS_INFO_realpath ${basedir})" while [[ ${realbasedir} != '/' ]]; do [[ -r ${realbasedir} ]] || return 1 if [[ -n ${vcs_comm[detect_need_file]} ]] ; then - [[ -d ${basedir}/${dirname} ]] && \ - [[ -e ${basedir}/${dirname}/${vcs_comm[detect_need_file]} ]] && \ - break + [[ -d ${basedir}/${dirname} ]] && { + for file in ${(s: :)${vcs_comm[detect_need_file]}}; do + [[ -e ${basedir}/${dirname}/${file} ]] && break 2 + done + } else [[ -d ${basedir}/${dirname} ]] && break fi diff --git a/Functions/VCS_Info/VCS_INFO_hook b/Functions/VCS_Info/VCS_INFO_hook index 7274d726f..479f5968b 100644 --- a/Functions/VCS_Info/VCS_INFO_hook +++ b/Functions/VCS_Info/VCS_INFO_hook @@ -2,24 +2,36 @@ ## Written by Frank Terbeck <ft@bewatermyfriend.org> ## Distributed under the same BSD-ish license as zsh itself. -local hook func +local hook static func local -x context hook_name local -xi ret -local -a hooks +local -a hooks tmp local -i debug ret=0 hook_name="$1" shift context=":vcs_info:${vcs}+${hook_name}:${usercontext}:${rrn}" +static=":vcs_info-static_hooks:${hook_name}" zstyle -t "${context}" debug && debug=1 || debug=0 if (( debug )); then printf 'VCS_INFO_hook: running hook: "%s"\n' "${hook_name}" printf 'VCS_INFO_hook: current context: "%s"\n' "${context}" + printf 'VCS_INFO_hook: static context: "%s"\n' "${static}" fi -zstyle -a "${context}" hooks hooks || return 0 +zstyle -a "${static}" hooks hooks +if (( debug )); then + printf '+ static hooks: %s\n' "${(j:, :)hooks}" +fi +zstyle -a "${context}" hooks tmp +if (( debug )); then + printf '+ context hooks: %s\n' "${(j:, :)tmp}" +fi +hooks+=( "${tmp[@]}" ) +(( ${#hooks} == 0 )) && return 0 + # Protect some internal variables in hooks. The `-g' parameter to # typeset does *not* make the parameters global here (they are already # "*-local-export). It prevents typeset from creating *new* *local* diff --git a/Functions/VCS_Info/VCS_INFO_set b/Functions/VCS_Info/VCS_INFO_set index a2b838cdb..5087be43f 100644 --- a/Functions/VCS_Info/VCS_INFO_set +++ b/Functions/VCS_Info/VCS_INFO_set @@ -5,17 +5,13 @@ setopt localoptions noksharrays NO_shwordsplit local -i i j -if [[ $1 == '--clear' ]] ; then - for i in {0..9} ; do - unset vcs_info_msg_${i}_ - done -fi if [[ $1 == '--nvcs' ]] ; then [[ $2 == '-preinit-' ]] && (( maxexports == 0 )) && (( maxexports = 1 )) for i in {0..$((maxexports - 1))} ; do typeset -gx vcs_info_msg_${i}_= done VCS_INFO_nvcsformats $2 + [[ $2 != '-preinit-' ]] && VCS_INFO_hook "no-vcs" fi (( ${#msgs} - 1 < 0 )) && return 0 diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info index 6ce1cd702..513489b70 100644 --- a/Functions/VCS_Info/vcs_info +++ b/Functions/VCS_Info/vcs_info @@ -26,6 +26,8 @@ static_functions=( VCS_INFO_reposub VCS_INFO_set + vcs_info_hookadd + vcs_info_hookdel vcs_info_lastmsg vcs_info_printsys vcs_info_setsys @@ -35,6 +37,7 @@ for func in ${static_functions} ; do autoload -Uz ${func} done +[[ -n ${(Mk)parameters:#vcs_info_msg_<->_} ]] && unset ${parameters[(I)vcs_info_msg_<->_]} VCS_INFO_set --nvcs '-preinit-' vcs_info_setsys @@ -75,7 +78,7 @@ vcs_info () { (( ${#enabled} == 0 )) && enabled=( all ) if [[ -n ${(M)enabled:#(#i)none} ]] ; then - [[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set --clear + [[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set --nvcs return 0 fi @@ -88,7 +91,7 @@ vcs_info () { for pat in ${dps} ; do if [[ ${PWD} == ${~pat} ]] ; then - [[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set --clear + [[ -n ${vcs_info_msg_0_} ]] && VCS_INFO_set --nvcs return 0 fi done diff --git a/Functions/VCS_Info/vcs_info_hookadd b/Functions/VCS_Info/vcs_info_hookadd new file mode 100644 index 000000000..867f7e271 --- /dev/null +++ b/Functions/VCS_Info/vcs_info_hookadd @@ -0,0 +1,22 @@ +## vim:ft=zsh +## Written by Frank Terbeck <ft@bewatermyfriend.org> +## Distributed under the same BSD-ish license as zsh itself. + +emulate -L zsh +setopt extendedglob + +if (( ${#argv} < 2 )); then + print 'usage: vcs_info_hookadd <HOOK> <FUNCTION(s)...>' + return 1 +fi + +local hook func context +local -a old + +hook=$1 +shift +context=":vcs_info-static_hooks:${hook}" + +zstyle -a "${context}" hooks old +zstyle "${context}" hooks "${old[@]}" "$@" +return $? diff --git a/Functions/VCS_Info/vcs_info_hookdel b/Functions/VCS_Info/vcs_info_hookdel new file mode 100644 index 000000000..e09a0575e --- /dev/null +++ b/Functions/VCS_Info/vcs_info_hookdel @@ -0,0 +1,45 @@ +## vim:ft=zsh +## Written by Frank Terbeck <ft@bewatermyfriend.org> +## Distributed under the same BSD-ish license as zsh itself. + +emulate -L zsh +setopt extendedglob + +local -i all + +if [[ "x$1" == 'x-a' ]]; then + all=1 + shift +else + all=0 +fi + +if (( ${#argv} < 2 )); then + print 'usage: vcs_info_hookdel [-a] <HOOK> <FUNCTION(s)...>' + return 1 +fi + +local hook func context +local -a old + +hook=$1 +shift +context=":vcs_info-static_hooks:${hook}" + +zstyle -a "${context}" hooks old || return 0 +for func in "$@"; do + if [[ -n ${(M)old:#$func} ]]; then + old[(Re)$func]=() + else + printf 'Not statically registered to `%s'\'': "%s"\n' \ + "${hook}" "${func}" + continue + fi + if (( all )); then + while [[ -n ${(M)old:#$func} ]]; do + old[(Re)$func]=() + done + fi +done +zstyle "${context}" hooks "${old[@]}" +return $? |