From bca563a6998f736ec7bc1bcf1f4ec3e01667dc57 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 4 Oct 2000 05:10:18 +0000 Subject: * 12872: Completion/User/_cvs: Fix modules completion when a cvsroot specified in a command line begins with tilde. Generate subcommand list from `cvs --help-commands' and `cvs --help-synonyms'. Complete remote modules. Complete vendor branch for a second argument of `cvs import'. Use _call. --- Completion/User/_cvs | 203 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 166 insertions(+), 37 deletions(-) (limited to 'Completion/User/_cvs') diff --git a/Completion/User/_cvs b/Completion/User/_cvs index 410cc4258..3f00bc1c3 100644 --- a/Completion/User/_cvs +++ b/Completion/User/_cvs @@ -36,24 +36,26 @@ _cvs () { (( $+functions[_cvs_command] )) || _cvs_command () { - local cmd cvsroot="${opt_args[-d]:Q}" - typeset -A cmds - cmds=(add " ad new " admin " adm rcs " annotate " ann " - checkout " co get " commit " ci com " diff " di dif " - edit "" editors "" export " exp ex " - history " hi his " import " im imp " init "" - log " lo rlog " login " logon lgn " logout "" - rdiff " patch pa " release " re rel " remove " rm delete " - status " st stat " rtag " rt rfreeze " tag " ta freeze " - unedit "" update " up upd " watch "" - watchers "") + local cmd cvsroot="$CVSROOT" + [[ -f CVS/Root ]] && cvsroot="$(&1)"}:# *}/(#b) #([a-z]##) */$match[1] + }}} + ${(f)${(F)${${(M)${(f)"$(_call synonyms cvs --help-synonyms 2>&1)"}:# *}/(#b) #([a-z]#) #([a-z]#) ([a-z]#)/$match[1] + $match[2] $match[3] }}} + ) + fi if (( CURRENT == 1 )); then - _tags commands && { compadd "$@" -k cmds || compadd "$@" ${(kv)=cmds} } + _tags commands && { compadd "$@" -k _cvs_cmds || compadd "$@" ${(kv)=_cvs_cmds} } else local curcontext="$curcontext" - cmd="${${(k)cmds[(R)* $words[1] *]}:-${(k)cmds[(i)$words[1]]}}" + cmd="${${(k)_cvs_cmds[(R)* $words[1] *]}:-${(k)_cvs_cmds[(i)$words[1]]}}" if (( $#cmd )); then curcontext="${curcontext%:*:*}:cvs-${cmd}:" _cvs_$cmd @@ -355,13 +357,13 @@ _cvs_import () { # "+Qqdb:m:I:k:W:" _arguments -s \ '-d[use file modification time]' \ - '-b+[specify vendor branch]:branch:' \ + '-b+[specify vendor branch]:branch:(1.1.3)' \ '-m+[message]:message:_cvs_m' \ '*-I+[ignore files]:name:_files' \ '-k+[keyword]:keyword substitution:_cvs_k' \ '*-W+[wrapper specification]:spec:_files' \ ':repository:_cvs_modules' \ - ':vendor tag:' \ + ':vendor tag:_cvs_vendor_branches' \ ':release tag:' } @@ -555,6 +557,11 @@ _cvs_watchers () { '*:file:_cvs_files' } +(( $+functions[_cvs_version] )) || +_cvs_version () { + false +} + (( $+functions[_cvs_loadstat] )) || _cvs_loadstat () { zstyle -t ":completion:${curcontext}:" disable-stat && return 1 @@ -584,7 +591,9 @@ _cvs_root () { fi _tags files && { - compadd -M 'r:|[:@./]=** r:|=**' "$@" -a _cvs_roots || _files "$@" -/ + compadd -M 'r:|[:@./]=** r:|=**' "$@" -a _cvs_roots || { + compset -P ':(local|fork):'; _files "$@" -W / -/ + } } } @@ -638,43 +647,163 @@ _cvs_m () { (( $+functions[_cvs_modules] )) || _cvs_modules () { - local root="$CVSROOT" expl - [[ -f CVS/Root ]] && root=$(&/dev/null + cd $d + mkdir CVS >&/dev/null + print -r - "$cvsroot" > CVS/Root + print "$dir" > CVS/Repository + print D > CVS/Entries + CVS_IGNORE_REMOTE_ROOT= cvs "$@" + cd $OLDPWD + rm -rf $d +} + +# _cvs_remote_directories cvsroot directory [variable] +(( $+functions[_cvs_remote_directories] )) || +_cvs_remote_directories () { + local root="$1" dir="$2" subdirs + shift 2 + subdirs=(${${(M)${(f)"$(_call directories _cvs_run "$root" "$dir" update -r00 -d -p 2>&1)"}:#* New directory \`*\' -- ignored}/(#b)*\`(*)\'*/$match[1]}) + if (( $# )); then + eval "$1=(\"\$subdirs[@]\")" + else + if (( $#subdirs )); then + print -lr - $subdirs + fi + fi +} + +(( $+functions[_cvs_vendor_branches] )) || +_cvs_vendor_branches () { + local expl vendor_branch + if [[ -n $opt_args[-b] ]]; then + _cvs_extract_vendor_branch -b "$opt_args[-b]" "$cvsroot" "$line[1]" \ + vendor_branch + else + _cvs_extract_vendor_branch "$cvsroot" "$line[1]" vendor_branch + fi + if (( $#vendor_branch )); then + _wanted values expl 'vendor branch' compadd -a vendor_branch + else + _message 'vendor branch' + fi +} + +# _cvs_extract_vendor_branch [-b numeric-branch] cvsroot directory [variable] +(( $+functions[_cvs_extract_vendor_branch] )) || +_cvs_extract_vendor_branch () { + local numeric='1\.1\.1' + if [[ $1 = -b ]]; then + numeric="${2//./\\.}" + shift 2 + fi + local root="$1" dir="$2" + shift 2 + + local vtags + vtags=($( + _call tags _cvs_run "$root" "$dir" -Q log -h 2>/dev/null | + sed -ne $'/^symbolic names:/{ +n +:loop +/^[^ \t]/d +/: '"$numeric"$'$/b found +n +b loop +:found +s/^[ \t]*\\(.*\\): '"$numeric"$'$/\\1/p +n +/^[ \t]/b found +q +}')) + if (( $# )); then + eval "$1=(\"\$vtags[@]\")" + else + if (( $#vtags )); then + print -lr - "$vtags[@]" + fi fi } (( $+functions[_cvs_revisions] )) || _cvs_revisions () { - local root="$CVSROOT" expl - [[ -f CVS/Root ]] && root=$(