1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-06-03 13:56:03 +02:00
zsh/Functions/VCS_Info/VCS_INFO_hook
Frank Terbeck 0501efc54a Seth House, Simon Ruderich and myself: 27948: various vcs_info changes
Here's a diff-stat:

 Doc/Zsh/contrib.yo                                |  506 ++++++++++++++-------
 Functions/VCS_Info/.distfiles                     |    1 +
 Functions/VCS_Info/Backends/VCS_INFO_detect_hg    |   14 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git |   35 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg  |  295 +++++++++----
 Functions/VCS_Info/VCS_INFO_formats               |   26 +-
 Functions/VCS_Info/VCS_INFO_hook                  |   10 +-
 Functions/VCS_Info/VCS_INFO_quilt                 |  190 ++++++++
 Functions/VCS_Info/vcs_info                       |   30 +-
 Misc/.distfiles                                   |    1 +
 Misc/vcs_info-examples                            |  496 ++++++++++++++++++++
 11 files changed, 1303 insertions(+), 301 deletions(-)

The major changes are vast improvements for the mercurial (hg) backend
(which was done almost entirely by Seth); improved documentation (mostly
done by Simon and again Seth); quilt support (as an addon and stand
alone, see the manual for details); a number of new hooks and a fair
share of bugfixes.
2010-05-10 10:46:48 +00:00

47 lines
1.3 KiB
Bash

### vim:ft=zsh:foldmethod=marker
## Written by Frank Terbeck <ft@bewatermyfriend.org>
## Distributed under the same BSD-ish license as zsh itself.
local hook func
local -x context hook_name
local -xi ret
local -a hooks
local -i debug
ret=0
hook_name="$1"
shift
context=":vcs_info:${vcs}+${hook_name}:${usercontext}:${rrn}"
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}"
fi
zstyle -a "${context}" hooks hooks || 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*
# parameters in this function's scope.
typeset -g -r vcs rrn usercontext maxexports msgs vcs_comm
for hook in ${hooks} ; do
func="+vi-${hook}"
if (( ${+functions[$func]} == 0 )); then
(( debug )) && printf ' + Unknown function: "%s"\n' "${func}"
continue
fi
(( debug )) && printf ' + Running function: "%s"\n' "${func}"
true
${func} "$@"
case $? in
(0)
;;
(*)
break
;;
esac
done
typeset -g +r vcs rrn usercontext maxexports msgs vcs_comm
return $ret