From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2787 invoked from network); 27 Jan 2006 03:42:17 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,FORGED_RCVD_HELO autolearn=ham version=3.1.0 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 27 Jan 2006 03:42:17 -0000 Received: (qmail 37029 invoked from network); 27 Jan 2006 03:42:09 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 27 Jan 2006 03:42:09 -0000 Received: (qmail 2359 invoked by alias); 27 Jan 2006 03:42:00 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9858 Received: (qmail 2288 invoked from network); 27 Jan 2006 03:41:58 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 27 Jan 2006 03:41:58 -0000 Received: (qmail 35901 invoked from network); 27 Jan 2006 03:41:58 -0000 Received: from smtp1.cc.ksu.edu (129.130.7.15) by a.mx.sunsite.dk with SMTP; 27 Jan 2006 03:41:56 -0000 Received: from koopa (ip68-102-201-46.ks.ok.cox.net [68.102.201.46]) (authenticated bits=0) by smtp1.cc.ksu.edu (8.13.4/8.13.4) with ESMTP id k0R3fm8Q027846 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 26 Jan 2006 21:41:55 -0600 (CST) Date: Thu, 26 Jan 2006 21:41:34 -0600 From: Andrew Ruder To: zsh-users@sunsite.dk Subject: Re: Subversion tab completion module Message-ID: <20060127034134.GA26988@localdomain> References: <20060126091852.GB6236@localdomain> <20060127002109.GP1149@prunille.vinc17.org> <20060127005748.GB17179@localdomain> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="Q68bSM7Ycu6FN28Q" Content-Disposition: inline In-Reply-To: <20060127005748.GB17179@localdomain> User-Agent: Mutt/1.5.9i --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jan 26, 2006 at 06:57:48PM -0600, Andrew Ruder wrote: > ... I have attached a copy of the module with the changes based > against the latest CVS of _subversion instead... Yea.. right, about that. Its really attached this time. :) Thanks, Andy -- Andrew Ruder http://www.aeruder.net --Q68bSM7Ycu6FN28Q Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=_subversion #compdef svn svnadmin svnadmin-static=svnadmin _remote_files () { # There should be coloring based on all the different ls -F classifiers. local expl remfiles remdispf remdispd args suf ret=1 if zstyle -T ":completion:${curcontext}:files" remote-access; then remfiles=(${(M)${(f)"$(_call_program files svn list "${(Q)PREFIX%%[^./][^/]#}" 2>/dev/null)"}%%[^/]#(|/)}) compset -P '*/' compset -S '/*' || suf='remote file' remdispf=(${remfiles:#*/}) remdispd=(${(M)remfiles:#*/}) _tags files while _tags; do while _next_label files expl ${suf:-remote directory}; do [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \ ${(q)remdispf%[*=@|]} && ret=0 compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \ ${(q)remdispd%/} && ret=0 done (( ret )) || return 0 done else _message -e remote-files 'remote file' fi } _svn () { local curcontext="$curcontext" state line expl ret=1 _arguments -C \ '(-)--help[print help information]' \ '(- *)--version[print client version information]' \ '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 -C \ '(-)--help[print help information]' \ '(- *)--version[print client version information]' \ '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] )) || _svn_controlled() { [[ -f ${(M)REPLY##*/}.svn/text-base/${REPLY##*/}.svn-base ]] } (( $+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] )) || _svn_urls() { local expl local myprefix if [[ -prefix file:/// ]]; then myprefix="${PREFIX#file://}" myprefix="${(Q)myprefix%%[^./][^/]#}" # Directory doesn't exist? prolly a repos if ! [[ -d "$myprefix" ]]; then _remote_files # Take a wild guess that this is prolly a svn repos elif [[ -e "$myprefix"/README.txt ]] && [[ -d "$myprefix"/hooks ]] && [[ -d "$myprefix"/locks ]]; then _remote_files # Ok, looks to be not a svn repos (yet) else _urls fi elif [[ -prefix *: ]]; then _remote_files else compset -S '[^:]*' _wanted url-schemas expl 'URL schema' compadd -S '' - \ file:// http:// https:// svn:// svn+ssh:// fi } (( $+functions[_svn_commands] )) || _svn_commands() { compadd "$@" -k _svn_cmds || compadd "$@" ${(s.:.)_svn_cmds} } (( $+functions[_svnadmin_command] )) || _svnadmin_commands() { compadd "$@" -k _svnadmin_cmds || compadd "$@" ${(s.:.)_svnadmin_cmds} } _subversion () { case $service in (svn) _svn "$@" ;; (svnadmin) _svnadmin "$@" ;; esac } _subversion "$@" --Q68bSM7Ycu6FN28Q--