summaryrefslogtreecommitdiffstats
path: root/Completion/Unix
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-08-04 12:12:27 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-08-04 12:12:27 +0000
commiteb2361b8a26177cd1f699f5a9821bd9bb6ea9a39 (patch)
tree85f7bd468c388d6bcfdd09d68505047b9080c527 /Completion/Unix
parentfile _pump was added on branch zsh-4_2-patches on 2007-05-08 03:45:16 +0000 (diff)
downloadzsh-eb2361b8a26177cd1f699f5a9821bd9bb6ea9a39.tar
zsh-eb2361b8a26177cd1f699f5a9821bd9bb6ea9a39.tar.gz
zsh-eb2361b8a26177cd1f699f5a9821bd9bb6ea9a39.tar.bz2
zsh-eb2361b8a26177cd1f699f5a9821bd9bb6ea9a39.tar.lz
zsh-eb2361b8a26177cd1f699f5a9821bd9bb6ea9a39.tar.xz
zsh-eb2361b8a26177cd1f699f5a9821bd9bb6ea9a39.tar.zst
zsh-eb2361b8a26177cd1f699f5a9821bd9bb6ea9a39.zip
unposted: patch _subversion changes from head
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Command/_subversion197
1 files changed, 197 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion
new file mode 100644
index 000000000..1f28ac2e4
--- /dev/null
+++ b/Completion/Unix/Command/_subversion
@@ -0,0 +1,197 @@
+#compdef svn svnadmin svnadmin-static=svnadmin
+
+_svn () {
+
+ _arguments -s \
+ '(-)--help[print help information]' \
+ '(- *)--version[print client version information]' \
+ '*::svn command:_svn_command'
+}
+
+_svnadmin () {
+
+ _arguments -s \
+ '(-)--help[print help information]' \
+ '(- *)--version[print client version information]' \
+ '*::svnadmin command:_svnadmin_command'
+}
+
+(( $+functions[_svn_controlled] )) ||
+_svn_controlled() {
+ [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]]
+}
+
+(( $+functions[_svn_deletedfiles] )) ||
+_svn_deletedfiles() {
+ # Typical usage would be _files -g '.svn(/e:_svn_deletedfiles:)'
+ local cont controlled
+ reply=( )
+ [[ $REPLY = (*/|).svn ]] || return
+ controlled=( $REPLY/text-base/*.svn-base(N:r:t) )
+ for cont in ${controlled}; do
+ [[ -e $REPLY:h/$cont ]] || reply+=( ${REPLY%.svn}$cont )
+ done
+}
+
+(( $+functions[_svn_status] )) ||
+_svn_status() {
+ local dir=$REPLY:h
+ local pat="${1:-([ADMR]|?M)}"
+
+ if (( ! $+_cache_svn_status[$dir] )); then
+ _cache_svn_status[$dir]="$(_call_program files svn status -N $dir)"
+ fi
+
+ (( ${(M)#${(f)_cache_svn_status[$dir]}:#(#s)${~pat}*$REPLY} ))
+}
+
+(( $+functions[_svn_urls] )) ||
+_svn_urls() {
+ local expl
+
+ if [[ -prefix *: ]]; then
+ _urls
+ else
+ compset -S '[^:]*'
+ _wanted url-schemas expl 'URL schema' compadd -S '' - \
+ file:// http:// https:// svn:// svn+ssh://
+ fi
+}
+
+(( $+functions[_svn_command] )) ||
+_svn_command () {
+ local cmd
+
+ if (( ! $+_svn_cmds )); then
+ typeset -gHA _svn_cmds
+ _svn_cmds=(
+ ${=${(f)${${"$(LC_MESSAGES=C _call_program commands svn help)"#l#*Available subcommands:}%%Subversion is a tool*}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
+ )
+ fi
+
+ if (( CURRENT == 1 )); then
+ _tags commands && { compadd "$@" -k _svn_cmds || compadd "$@" ${(s.:.)_svn_cmds} }
+ else
+ local curcontext="$curcontext"
+
+ cmd="${${(k)_svn_cmds[(R)*:$words[1]:*]}:-${(k)_svn_cmds[(i):$words[1]:]}}"
+ if (( $#cmd )); then
+ curcontext="${curcontext%:*:*}:svn-${cmd}:"
+ _svn_subcommand $cmd
+ else
+ _message "unknown svn command: $words[1]"
+ fi
+ fi
+}
+
+(( $+functions[_svn_subcommand] )) ||
+_svn_subcommand () {
+ local subcmd _svn_subcmds _svn_subcmd_usage
+ typeset -gHA _cache_svn_status
+
+ _svn_subcmd_usage=${${(M)${(f)"$(LC_MESSAGES=C _call_program options svn help $1)"}:#usage:*}#usage: $1 }
+
+ _svn_subcmds=(
+ ${=${${${(M)${(f)"$(LC_MESSAGES=C _call_program options svn help $1)"##*Valid options:}:#* :*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+ )
+
+ case $1 in;
+ add)
+ _svn_subcmds+=(
+ '*:file:_files -g "*(^e:_svn_controlled:)"'
+ )
+ ;;
+ commit)
+ _svn_subcmds+=(
+ '*:file:_files -g "*(e:_svn_status:)"'
+ )
+ ;;
+ delete)
+ _svn_subcmds+=(
+ '*:file:_files -g ".svn(/e:_svn_deletedfiles:)"'
+ )
+ ;;
+ log)
+ _svn_subcmds+=(
+ '1: : _alternative "files:file:_files -g \*\(e:_svn_controlled:\)" "urls:URL:_svn_urls"'
+ '*:file:_files -g "*(e:_svn_controlled:)"'
+ )
+ ;;
+ revert)
+ _svn_subcmds+=(
+ '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"'
+ )
+ ;;
+ *)
+ case $_svn_subcmd_usage in
+ *(SRC|DST|TARGET|URL*PATH)*)
+ _svn_subcmds+=(
+ '*: : _alternative "files:file:_files" "urls:URL:_svn_urls"'
+ )
+ ;;
+ *URL*) _svn_subcmds+=( ':URL:_svn_urls' ) ;;
+ *PATH*) _svn_subcmds+=( '*:file:_files' ) ;;
+ esac
+ ;;
+ esac
+
+ _arguments "$_svn_subcmds[@]" && ret=0
+
+ return ret
+}
+
+
+(( $+functions[_svnadmin_command] )) ||
+_svnadmin_command () {
+ local cmd
+
+ if (( ! $+_svnadmin_cmds )); then
+ typeset -gHA _svnadmin_cmds
+ _svnadmin_cmds=(
+ ${=${(f)${${"$(LC_MESSAGES=C _call_program commands svnadmin help)"#l#*Available subcommands:}}}/(#s)[[:space:]]#(#b)([a-z]##)[[:space:]]#(\([a-z, ?]##\))#/$match[1] :$match[1]${match[2]:+:${${match[2]//[(),]}// /:}}:}
+ )
+ fi
+
+ if (( CURRENT == 1 )); then
+ _tags commands && { compadd "$@" -k _svnadmin_cmds || compadd "$@" ${(s.:.)_svnadmin_cmds} }
+ else
+ local curcontext="$curcontext"
+
+ cmd="${${(k)_svnadmin_cmds[(R)*:$words[1]:*]}:-${(k)_svnadmin_cmds[(i):$words[1]:]}}"
+ if (( $#cmd )); then
+ curcontext="${curcontext%:*:*}:svnadmin-${cmd}:"
+ _svnadmin_subcommand $cmd
+ else
+ _message "unknown svnadmin command: $words[1]"
+ fi
+ fi
+}
+
+(( $+functions[_svnadmin_subcommand] )) ||
+_svnadmin_subcommand () {
+ local subcmd _svnadmin_subcmds _svnadmin_subcmd_usage
+
+ _svnadmin_subcmd_usage=${${(M)${(f)"$(LC_MESSAGES=C _call_program options svnadmin help $1)"}:#$1: usage:*}#$1: usage: svnadmin $1 }
+
+ _svnadmin_subcmds=(
+ ${=${${${(M)${(f)"$(LC_MESSAGES=C _call_program options svnadmin help $1)"##*Valid options:}:#*:*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+ )
+
+ [[ "$_svnadmin_subcmd_usage" == *REPOS_PATH* ]] &&
+ _svnadmin_subcmds=($_svnadmin_subcmds ":path:_files -/")
+
+ _arguments "$_svnadmin_subcmds[@]" && ret=0
+
+ return ret
+
+}
+
+
+_subversion () {
+ case $service in
+ (svn) _svn "$@" ;;
+ (svnadmin) _svnadmin "$@" ;;
+ esac
+}
+
+_subversion "$@"