svn-12842468.patch   [plain text]


--- Completion/Unix/Command/_subversion	2009-12-17 01:48:12.000000000 -0800
+++ Completion/Unix/Command/_subversion	2012-02-10 11:33:42.000000000 -0800
@@ -4,6 +4,12 @@
   local curcontext="$curcontext" state line expl ret=1
   typeset -A opt_args
 
+  local update_policy
+  zstyle -s ":completion:*:*:$service:*" cache-policy update_policy
+  if [[ -z "$update_policy" ]]; then
+    zstyle ":completion:*:*:$service:*" cache-policy _svn_caching_policy
+  fi
+
   _arguments -C \
     '(-)--help[print help information]' \
     '(- *)--version[print client version information]' \
@@ -12,9 +18,12 @@
 
   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]//[(),]}// /:}}:}
-    )
+    if _cache_invalid svn-cmds || ! _retrieve_cache svn-cmds; then
+      _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]//[(),]}// /:}}:}
+      )
+      _store_cache svn-cmds _svn_cmds
+    fi
   fi
 
   case $state in
@@ -22,17 +31,30 @@
       _wanted commands expl 'svn command' _svn_commands && ret=0
     ;;
     args)
-      local cmd args usage
+      local cmd args usage idx
       typeset -gHA _cache_svn_status _cache_svn_mtime
 
       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:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)-([[:alpha:]]) \[--([a-z-]##)\](:arg:)#/(--$match[2])-$match[1]$match[3] (-$match[1])--$match[2]$match[3]}
-        )
+	if _cache_invalid svn-${cmd}-usage || \
+	    ! _retrieve_cache svn-${cmd}-usage;
+	then
+	  usage=${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"}:#usage:*}#usage:*$cmd] }
+	  _store_cache svn-${cmd}-usage usage
+	fi
+	if _cache_invalid svn-${cmd}-usage || \
+	    ! _retrieve_cache svn-${cmd}-args;
+	then
+	  args=(
+	    ${=${${${(M)${(f)"$(LC_ALL=C _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)(-##)([[:alpha:]]##) \[--([a-z-]##)\](:arg:)#/(--$match[3])$match[1]$match[2]$match[4] ($match[1]$match[2])--$match[3]$match[4]}
+	  )
+          while (( idx=$args[(I)*--c(l|hangelist):arg:] )); do
+            args[(I)*--c(l|hangelist):arg:]=( \*{--cl,--changelist}':change list:_svn_changelists' )
+          done
+	  _store_cache svn-${cmd}-args args
+	fi
 
         case $cmd in;
           (add)
@@ -73,6 +95,9 @@
 	      '*:file:_files -g "*(e:_svn_controlled:)"'
             )
           ;;
+          (mergeinfo)
+            args[(r)--show-revs:arg:]=( '--show-revs:revisions:(merged eligible)' )
+          ;;
 	  (propget|propedit)
 	    args+=(
 		'1:property name:_svn_props'
@@ -262,7 +287,7 @@
   if [[ ! -prefix *://? ]] ; then
     zstyle -a ":completion:${curcontext}:" url-schemas urlsch \
      || urlsch=( file:// http:// https:// svn:// svn+ssh:// )
-    
+
     if (( $#urlsch )) ; then
       compset -S '[^:]*'
       _wanted url-schemas expl 'URL schema' compadd -S '' - $urlsch[@] && ret=0
@@ -290,6 +315,14 @@
   compadd "$@" -a properties && return 0
 }
 
+(( $+functions[_svn_changelists] )) ||
+_svn_changelists() {
+  local cls
+
+  cls=( ${${${(M)${(f)"$(LC_ALL=C _call_program changelists svn status 2>/dev/null)"}:#--- Changelist*}%??}##*\'} )
+  compadd "$@" -a cls && return 0
+}
+
 _subversion () {
   case $service in
     (svn) _svn "$@" ;;
@@ -297,4 +330,8 @@
   esac
 }
 
+_svn_caching_policy() {
+  [[ =$service -nt $1 ]]
+}
+
 _subversion "$@"