Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

minor tweak to _subversion remote path completion



This follows on to my previous patch:

Add a typeset -A that the _arguments documentation says is required:

| A function calling _arguments with at least one action containing a
| '->string' therefore must declare appropriate local parameters:
|     local context state line
|     typeset -A opt_args
| to avoid _arguments from altering the global environment.


Add support for the special '^/path/..' style repository paths which
I didn't even know about until making the claim that remote path
completion was now complete to a friend.

thanks,
Greg



Index: Completion/Unix/Command/_subversion
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_subversion,v
retrieving revision 1.29
diff -u -r1.29 _subversion
--- Completion/Unix/Command/_subversion	15 Nov 2009 17:52:02 -0000	1.29
+++ Completion/Unix/Command/_subversion	18 Nov 2009 21:16:57 -0000
@@ -2,6 +2,7 @@
 
 _svn () {
   local curcontext="$curcontext" state line expl ret=1
+  typeset -A opt_args
 
   _arguments -C \
     '(-)--help[print help information]' \
@@ -207,12 +208,20 @@
 
 (( $+functions[_svn_remote_paths] )) ||
 _svn_remote_paths() {
-  local expl remfiles remdispf remdispd suf ret=1
+  local expl remfiles remdispf remdispd suf ret=1 pfx='\^/' sub='^/'
 
-  [[ -prefix *://*/ ]] || return 1
+  # prefix must match a valid repository path format, either standard style
+  # schema://host/path/.. or ^/path/.. specifying a path relative to the
+  # root of the working directory repository.  In the second form, allow the
+  # leading '^' be escaped in case the user has the extendedglob option set.
+  [[ -prefix *://*/ ]] ||
+  [[ -f .svn/entries && ( -prefix '^/' || -prefix '\^/' ) ]] ||
+  return 1
+
+  # return if remote access is not permitted
   zstyle -T ":completion:${curcontext}:" remote-access || return 1
 
-  remfiles=( ${(f)"$(svn list $IPREFIX${PREFIX%%[^./][^/]#} 2>/dev/null)"} )
+  remfiles=( ${(f)"$(svn list $IPREFIX${${PREFIX%%[^/]#}/#$pfx/$sub} 2>/dev/null)"} )
   (( $? == 0 )) || return 1
 
   # you might consider trying to return early if $#remfiles is zero,



Messages sorted by: Reverse Date, Date, Thread, Author