about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2005-11-10 14:44:56 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2005-11-10 14:44:56 +0000
commitfbd44f3573d6d411c498465673633f1e1d88edbf (patch)
tree3215192113e6d7f0f23f4251e0d087b0403834d9
parent2ee89700d11662157f067ee87ce109f1fdeb582b (diff)
downloadzsh-fbd44f3573d6d411c498465673633f1e1d88edbf.tar.gz
zsh-fbd44f3573d6d411c498465673633f1e1d88edbf.tar.xz
zsh-fbd44f3573d6d411c498465673633f1e1d88edbf.zip
unposted: copy latest _subversion from main branch
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_subversion263
2 files changed, 137 insertions, 131 deletions
diff --git a/ChangeLog b/ChangeLog
index 31d5f6116..4c2ae7241 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-11-10  Peter Stephenson  <pws@csr.com>
+
+	* unposted: Completion/Unix/Command/_subversion: patch latest
+	version from main branch.
+
 2005-10-31  Wayne Davison  <wayned@users.sourceforge.net>
 
 	* 21960: R. Ramkumar: Functions/Misc/zcalc:
diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion
index 1f28ac2e4..04509611c 100644
--- a/Completion/Unix/Command/_subversion
+++ b/Completion/Unix/Command/_subversion
@@ -1,19 +1,139 @@
 #compdef svn svnadmin svnadmin-static=svnadmin
 
 _svn () {
+  local curcontext="$curcontext" state line expl ret=1
 
-  _arguments -s \
+  _arguments -C \
     '(-)--help[print help information]' \
     '(- *)--version[print client version information]' \
-    '*::svn command:_svn_command'
+    '1: :->cmds' \
+    '*:: :->args' && ret=0
+
+  if [[ -n $state ]] && (( ! $+_svn_cmds )); then
+    typeset -gHA _svn_cmds
+    _svn_cmds=(
+      ${=${(f)${${"$(LC_ALL=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
+
+  case $state in
+    cmds)
+      _wanted commands expl 'svn command' _svn_commands && ret=0
+    ;;
+    args)
+      local cmd args usage
+      typeset -gHA _cache_svn_status
+
+      cmd="${${(k)_svn_cmds[(R)*:$words[1]:*]}:-${(k)_svn_cmds[(i):$words[1]:]}}"
+      if (( $#cmd )); then
+        curcontext="${curcontext%:*:*}:svn-${cmd}:"
+
+        usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
+        args=(
+          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"##*Valid options:}:#* :*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+        )
+
+        case $cmd in;
+          add)
+            args+=(
+              '*:file:_files -g "*(^e:_svn_controlled:)"'
+            )
+          ;;
+          commit)
+            args+=(
+              '*:file:_files -g "*(e:_svn_status:)"'
+            )
+          ;;
+          delete)
+            args+=(
+              '*:file:_files -g ".svn(/e:_svn_deletedfiles:)"'
+            )
+          ;;
+          help)
+            args+=(
+              '*::sub command:_svn_commands'
+            )
+          ;;
+          log)
+            args+=(
+              '1: : _alternative "files:file:_files -g \*\(e:_svn_controlled:\)" "urls:URL:_svn_urls"'
+	      '*:file:_files -g "*(e:_svn_controlled:)"'
+            )
+          ;;
+          revert)
+            args+=(
+              '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"'
+            )
+          ;;
+          *)
+            case $usage in
+              *(SRC|DST|TARGET|URL*PATH)*)
+                args+=(
+	          '*: : _alternative "files:file:_files" "urls:URL:_svn_urls"'
+	        )
+	      ;;
+              *URL*) args+=( ':URL:_svn_urls' ) ;;
+              *PATH*) args+=( '*:file:_files' ) ;;
+            esac
+          ;;
+        esac
+
+        _arguments "$args[@]" && ret=0
+
+      else
+        _message "unknown svn command: $words[1]"
+      fi
+    ;;
+  esac
+
+  return ret
 }
 
 _svnadmin () {
+  local curcontext="$curcontext" state line ret=1
 
-  _arguments -s \
+  _arguments -C \
     '(-)--help[print help information]' \
     '(- *)--version[print client version information]' \
-    '*::svnadmin command:_svnadmin_command'
+    '1: :->cmds' \
+    '*:: :->args' && ret=0
+
+  if [[ -n $state ]] && (( ! $+_svnadmin_cmds )); then
+    typeset -gHA _svnadmin_cmds
+    _svnadmin_cmds=(
+      ${=${(f)${${"$(LC_ALL=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
+
+  case $state in
+    cmds)
+      _wanted commands expl 'svnadmin command' _svnadmin_commands && ret=0
+    ;;
+    args)
+      local cmd args usage
+
+      cmd="${${(k)_svnadmin_cmds[(R)*:$words[1]:*]}:-${(k)_svnadmin_cmds[(i):$words[1]:]}}"
+      if (( $#cmd )); then
+        curcontext="${curcontext%:*:*}:svnadmin-${cmd}:"
+
+        usage=${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $cmd)"}:#$cmd: usage:*}#$cmd: usage: svnadmin $cmd }
+        args=(
+          ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svnadmin help $cmd)"##*Valid options:}:#*:*}%% #:*}/ arg/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
+        )
+        if [[ $_svnadmin_subcmd_usage == *REPOS_PATH* ]]; then
+          args+=( ":path:_files -/" )
+        elif [[ $cmd = help ]]; then
+          args+=( "*:subcommand:_svnadmin_commands" )
+        fi
+
+        _arguments "$args[@]" && ret=0
+      else
+        _message "unknown svnadmin command: $words[1]"
+      fi
+    ;;
+  esac
+
+  return ret
 }
 
 (( $+functions[_svn_controlled] )) ||
@@ -23,7 +143,7 @@ _svn_controlled() {
 
 (( $+functions[_svn_deletedfiles] )) ||
 _svn_deletedfiles() {
-  # Typical usage would be _files -g '.svn(/e:_svn_deletedfiles:)' 
+  # Typical usage would be _files -g '.svn(/e:_svn_deletedfiles:)'
   local cont controlled
   reply=( )
   [[ $REPLY = (*/|).svn ]] || return
@@ -36,7 +156,7 @@ _svn_deletedfiles() {
 (( $+functions[_svn_status] )) ||
 _svn_status() {
   local dir=$REPLY:h
-  local pat="${1:-([ADMR]|?M)}"
+  local pat="${1:-([ADMR~]|?M)}"
 
   if (( ! $+_cache_svn_status[$dir] )); then
     _cache_svn_status[$dir]="$(_call_program files svn status -N $dir)"
@@ -54,139 +174,20 @@ _svn_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
+        file:// http:// https:// svn:// svn+ssh://
   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[_svn_commands] )) ||
+_svn_commands() {
+  compadd "$@" -k _svn_cmds || compadd "$@" ${(s.:.)_svn_cmds}
 }
 
-
 (( $+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
+_svnadmin_commands() {
+  compadd "$@" -k _svnadmin_cmds || compadd "$@" ${(s.:.)_svnadmin_cmds}
 }
 
-(( $+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 "$@" ;;