From 76e087f4b29ac04afb07e3d655891ee6c10f6145 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 15 Nov 2009 17:52:02 +0000 Subject: Greg Klanderman: 27409: subversion and URL paths --- Completion/Unix/Command/_subversion | 63 ++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 19 deletions(-) (limited to 'Completion/Unix/Command/_subversion') diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index b4e47d330..9d6babed5 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -205,32 +205,57 @@ _svn_status() { (( ${(M)#${(f)_cache_svn_status[$key]}:#(#s)${~pat}*$REPLY} )) } -(( $+functions[_svn_urls] )) || -_svn_urls() { +(( $+functions[_svn_remote_paths] )) || +_svn_remote_paths() { local expl remfiles remdispf remdispd suf ret=1 - if [[ -prefix *: ]] && ! _urls && - zstyle -T ":completion:${curcontext}:" remote-access - then - remfiles=( ${(f)"$(svn list $IPREFIX${PREFIX%%[^./][^/]#} 2>/dev/null)"} ) - compset -P '*/' - compset -S '/*' || suf=file - remdispf=(${remfiles:#*/}) - remdispd=(${(M)remfiles:#*/}) - _tags files - while _tags; do - while _next_label files expl ${suf:-directory}; do - [[ -n $suf ]] && compadd -S ' ' -q "$@" "$expl[@]" -d remdispf $remdispf && ret=0 - compadd -S "${suf:+/}" -q "$@" "$expl[@]" -d remdispd ${remdispd%/} && ret=0 - done - (( ret )) || return 0 + [[ -prefix *://*/ ]] || return 1 + zstyle -T ":completion:${curcontext}:" remote-access || return 1 + + remfiles=( ${(f)"$(svn list $IPREFIX${PREFIX%%[^./][^/]#} 2>/dev/null)"} ) + (( $? == 0 )) || return 1 + + # you might consider trying to return early if $#remfiles is zero, + # but for whatever reason remfiles will always contain at least a + # single empty string; that case is handled correctly below. + + compset -P '*/' + compset -S '/*' || suf=file + remdispf=(${remfiles:#*/}) + remdispd=(${(M)remfiles:#*/}) + _tags files + while _tags; do + while _next_label files expl ${suf:-directory}; do + # add files, unless there is a '/' immediately to the right + [[ -n $suf ]] && + compadd -S ' ' -q "$@" "$expl[@]" -d remdispf $remdispf && ret=0 + # add directories; use empty suffix if there is a '/' immediately to the right + compadd -S "${suf:+/}" -q "$@" "$expl[@]" -d remdispd ${remdispd%/} && ret=0 done - else + (( ret )) || return 0 + done + + return 1 +} + +(( $+functions[_svn_urls] )) || +_svn_urls() { + local expl ret=1 + + # first try completing a remote path; if successful, we are all done.. + _svn_remote_paths && return 0 + + # allow configuring svn repository locations using the 'urls' zstyle. + # always attempt completion of these because then matcher-list styles + # which do substring matching will work correctly. + _urls -S/ && ret=0 + + if [[ ! -prefix *://? ]] ; then compset -S '[^:]*' _wanted url-schemas expl 'URL schema' compadd -S '' - \ file:// http:// https:// svn:// svn+ssh:// && ret=0 fi - + return ret } -- cgit 1.4.1