# HG changeset patch # User Steve Borho # Date 1128150121 25200 # Node ID d1d605d1e839e59717ae52b7931879ce9d82cb1a # Parent a7678cbd7c28335da895d1b247737143403b19c9 Fix completion function for 'hg pull'. Fix truncation bug and remove tabs. diff --git a/contrib/zsh_completion b/contrib/zsh_completion --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -16,34 +16,34 @@ local curcontext="$curcontext" state lin typeset -A opt_args local subcmds repos tags newFiles addedFiles -tags=($(hg tags 2> /dev/null | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$// +tags=($(hg tags 2> /dev/null | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')) subcmds=($(hg -v help | sed -e '1,/^list of commands:/d' \ -e '/^global options:/,$d' -e '/^ [^ ]/!d; s/[,:]//g;')) if [[ $service == "hg" ]]; then - _arguments -C -A "-*" \ - '-R+[repository root directory]' \ - '-y[non-interactive]' \ - '-v[verbose]' \ - '-q[quiet]' \ - '--time[time how long the command takes]' \ - '--profile[profile]' \ - '-h-[display help and exit]' \ - '--version-[output version information and exit]' \ + _arguments -C -A "-*" \ + '-R+[repository root directory]' \ + '-y[non-interactive]' \ + '-v[verbose]' \ + '-q[quiet]' \ + '--time[time how long the command takes]' \ + '--profile[profile]' \ + '-h-[display help and exit]' \ + '--version-[output version information and exit]' \ '--cwd[change working directory]:new working directory:_files -/' \ - '*::command:->subcmd' && return 0 + '*::command:->subcmd' && return 0 - if (( CURRENT == 1 )); then - _wanted commands expl 'hg command' compadd -a subcmds - return - fi - service="$words[1]" - curcontext="${curcontext%:*}=$service:" + if (( CURRENT == 1 )); then + _wanted commands expl 'hg command' compadd -a subcmds + return + fi + service="$words[1]" + curcontext="${curcontext%:*}=$service:" fi case $service in (addremove) - _arguments \ + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '*:directories:_files -/' # assume they want to add/remove a dir @@ -51,106 +51,106 @@ case $service in (add) newFiles=( $(hg status -un) ) - _arguments \ + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' _wanted files expl 'unknown files' compadd -a newFiles ;; (remove|rm) - _arguments \ + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '*:file:_files' ;; - (cat) - _arguments \ + (cat) + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '-o[output to file]:file:' \ '-r[revision]:revision:($tags)' \ '*:file:_files' - ;; + ;; - (checkout|update|up|co) - _arguments \ + (checkout|update|up|co) + _arguments \ '-b[checkout the head of a specific branch]:tag:' \ '-m[allow merging of conflicts]' \ '-C[overwrite locally modified files]' \ '*:revision:->revs' _wanted revs expl 'revision or tag' compadd -a tags - ;; + ;; - (commit|ci) - _arguments \ + (commit|ci) + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ - '-A[run addremove during commit]' \ - '-m[commit message]:string:' \ - '-d[date code]:string:' \ - '-u[user]:string:' \ + '-A[run addremove during commit]' \ + '-m[commit message]:string:' \ + '-d[date code]:string:' \ + '-u[user]:string:' \ '*:file:_files' - ;; + ;; - (tag) - _arguments \ - '-l[make the tag local]:' \ - '-m[commit message]:string:' \ - '-d[date code]:string:' \ - '-u[user]:string:' \ + (tag) + _arguments \ + '-l[make the tag local]:' \ + '-m[commit message]:string:' \ + '-d[date code]:string:' \ + '-u[user]:string:' \ '*:name and revision:' - ;; + ;; - (clone) - _arguments \ - '-U[skip update after cloning]' \ - '-e[ssh command]:string:' \ - '--pull[use pull protocol to copy metadata]' \ - '--remotecmd[remote hg command]:command:->subcmd' - ;; + (clone) + _arguments \ + '-U[skip update after cloning]' \ + '-e[ssh command]:string:' \ + '--pull[use pull protocol to copy metadata]' \ + '--remotecmd[remote hg command]:command:->subcmd' + ;; - (export) - _arguments \ + (export) + _arguments \ '-o[output to a file]:file:' \ '-a-[tread all files as text]' \ '*:revision:->revs' _wanted revs expl 'revision or tag' compadd -a tags - ;; - - (heads) - _arguments '-b[find branch info]' - ;; + ;; - (outgoing|out) - _arguments '-p[show patch]' - ;; + (heads) + _arguments '-b[find branch info]' + ;; - (paths) - _arguments '*:symbolic name:(default default-push)' - ;; - - (init) - _arguments '*:new repo directory:_files -/' + (outgoing|out) + _arguments '-p[show patch]' ;; - (unbundle) + (paths) + _arguments '*:symbolic name:(default default-push)' + ;; + + (init) + _arguments '*:new repo directory:_files -/' + ;; + + (unbundle) _arguments '*:changegroup file:_files' ;; - (manifest) - _arguments \ + (manifest) + _arguments \ '*:revision:->revs' _wanted revs expl 'revision or tag' compadd -a tags ;; - (parents) - _arguments \ + (parents) + _arguments \ '*:revision:->revs' _wanted revs expl 'revision or tag' compadd -a tags ;; - (serve) + (serve) _arguments \ '-A[access log file]:log file:_files' \ '-E[error log file]:log file:_files' \ @@ -163,34 +163,34 @@ case $service in '-6[use IPv6 in addition to IPv4]' ;; - (pull) + (pull) repos=( $(hg paths | sed -e 's/^.*= //') ) - _arguments \ + _arguments \ '-u[update working directory]' \ '-e[ssh command]:remote commands:' \ - '--remotecmd[remote hg command]:command:->subcmd' \ + '--remotecmd[remote hg command]:command:->subcmd' \ '*:pull source:->repo' - _wanted source expl 'source repository' compadd -a repos + _wanted source expl 'source repository' compadd -a repos ;; - (pull) + (push) repos=( $(hg paths | sed -e 's/^.*= //') ) - _arguments \ + _arguments \ '-f[force push]' \ '-e[ssh command]:remote commands:' \ - '--remotecmd[remote hg command]:command:->subcmd' \ + '--remotecmd[remote hg command]:command:->subcmd' \ '*:pull source:->repo' - _wanted source expl 'source repository' compadd -a repos + _wanted source expl 'source repository' compadd -a repos ;; - (id|identify) - ;; + (id|identify) + ;; - (recover) - ;; + (recover) + ;; - (rawcommit) - _arguments \ + (rawcommit) + _arguments \ '-p[parent]:revision:($tags)' \ '-d[date]:date:' \ '-u[user]:user:' \ @@ -198,71 +198,71 @@ case $service in '-m[commit message]:string:' \ '-l[commit message file]:message file:_files -g *.txt' \ '*:files to commit:_files' - ;; + ;; - (copy|cp) - _arguments \ + (copy|cp) + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '-A-[record a copy after it has happened]' \ '-f[replace destination if it exists]' \ '-p[append source path to dest]' \ '*:destination:' - ;; + ;; - (rename|mv) - _arguments \ + (rename|mv) + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '-A-[record a copy after it has happened]' \ '-f[replace destination if it exists]' \ '-p[append source path to dest]' \ '*:destination:' - ;; + ;; - (forget) + (forget) addedFiles=( $(hg status -an) ) - _arguments \ + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' _wanted files expl 'newly added files' compadd -a addedFiles - ;; + ;; - (import|patch) - _arguments \ + (import|patch) + _arguments \ '-p[path strip (default: 1)]:count:' \ '-f[skip check for outstanding changes]' \ '-b[base path]:file:_files -W $(hg root)' \ '*:patch file:_files' - ;; + ;; - (incoming|in) - _arguments \ + (incoming|in) + _arguments \ '-p[show patch]' \ '*:mercurial repository:_files' - ;; + ;; - (diff) - _arguments \ + (diff) + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '-r[revision]:revision:($tags)' \ '-a-[tread all files as text]' \ '*:file:_files' - ;; + ;; - (log|history) - _arguments \ + (log|history) + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '-r[revision]:revision:($tags)' \ '-b[show branches]' \ '-p[show patch]' \ '*:file:_files' - ;; + ;; - (grep) - _arguments \ + (grep) + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '-0[end fields with NUL]' \ @@ -273,10 +273,10 @@ case $service in '-r[search in revision rev]:revision:($tags)' \ '-u[print user who made change]' \ '*:search pattern, then files:_files' - ;; + ;; - (status) - _arguments \ + (status) + _arguments \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '-0[end filenames with NUL]' \ @@ -286,27 +286,27 @@ case $service in '-u[show only unknown files]' \ '-n[hide status prefix]' \ '*:search pattern, then files:_files' - ;; + ;; - (locate) - _arguments \ + (locate) + _arguments \ '-r[search in revision rev]:revision:($tags)' \ '-0[end fields with NUL]' \ '-f[print complete paths]' \ '-I[include path in search]:dir:_files -W $(hg root) -/' \ '-X[exclude path in search]:dir:_files -W $(hg root) -/' \ '*:search pattern:' - ;; + ;; - (help) - _wanted commands expl 'hg command' compadd -a subcmds - ;; + (help) + _wanted commands expl 'hg command' compadd -a subcmds + ;; (root|undo|view|verify|version) # no arguments for these commands ;; - (*) - _message "unknown hg command completion: $service" - ;; + (*) + _message "unknown hg command completion: $service" + ;; esac