diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Completion/Unix/Command/_subversion | 35 |
2 files changed, 35 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog index 0104fc8e5..6fd8075cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-03-31 Oliver Kiddle <opk@zsh.org> + + * 21076: Completion/Unix/Command/_subversion: use _files with + (e) glob qualifier to handle completing files by their status + 2005-03-27 Clint Adams <clint@zsh.org> * 21075: Completion/Unix/Command/_baz: update baz completion diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index 5f50b4c27..6f9a4f4cc 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -21,9 +21,28 @@ _svn_controlled() { [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]] } -(( $+functions[_svn_adm_files] )) || -_svn_adm_files() { - compadd ${${(M)${(f)"$(svn status)"}:#(#s)[ADM]*}##[ADM] ##} +(( $+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] )) || @@ -68,6 +87,7 @@ _svn_command () { (( $+functions[_svn_subcommand] )) || _svn_subcommand () { local subcmd _svn_subcmds _svn_subcmd_usage + typeset -A _cache_svn_status _svn_subcmd_usage=${${(M)${(f)"$(LC_MESSAGES=C _call_program options svn help $1)"}:#usage:*}#usage: $1 } @@ -87,9 +107,14 @@ _svn_subcommand () { '*:file:_files -g "*(e:_svn_controlled:)"' ) ;; - (revert) + delete) + _svn_subcmds+=( + '*:file:_files -g ".svn(/e:_svn_deletedfiles:)"' + ) + ;; + revert|commit) _svn_subcmds+=( - '*:file:_svn_adm_files' + '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"' ) ;; *) |