Mercurial > hg > mercurial-crew-with-dirclash
comparison contrib/zsh_completion @ 3482:46958e428fcd
zsh completion: basic mq support
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Sat, 21 Oct 2006 23:51:36 -0700 |
parents | b3184bea3eb3 |
children | 1b9494d2b070 |
comparison
equal
deleted
inserted
replaced
3481:f699d4eb25d9 | 3482:46958e428fcd |
---|---|
12 # option) any later version. | 12 # option) any later version. |
13 # | 13 # |
14 | 14 |
15 local curcontext="$curcontext" state line | 15 local curcontext="$curcontext" state line |
16 typeset -A opt_args | 16 typeset -A opt_args |
17 local subcmds repos tags newFiles addedFiles includeExclude | 17 local subcmds repos tags newFiles addedFiles includeExclude commitMessage |
18 | |
19 _mq_state () { | |
20 case "$state" in | |
21 (qapplied) | |
22 compadd $(hg qapplied) | |
23 ;; | |
24 (qunapplied) | |
25 compadd $(hg qunapplied) | |
26 ;; | |
27 esac | |
28 } | |
18 | 29 |
19 tags=($(hg tags 2> /dev/null | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')) | 30 tags=($(hg tags 2> /dev/null | sed -e 's/[0-9]*:[a-f0-9]\{40\}$//; s/ *$//')) |
20 subcmds=($(hg -v help | sed -e '1,/^list of commands:/d' \ | 31 subcmds=($(hg -v help | sed -e '1,/^list of commands:/d' \ |
21 -e '/^global options:/,$d' -e '/^ [^ ]/!d; s/[,:].*//g;')) | 32 -e '/^global options:/,$d' -e '/^ [^ ]/!d; s/[,:].*//g;')) |
22 | 33 |
24 includeExclude=( | 35 includeExclude=( |
25 '*-I-[include names matching the given patterns]:dir:_files -W $(hg root) -/' | 36 '*-I-[include names matching the given patterns]:dir:_files -W $(hg root) -/' |
26 '*--include-[include names matching the given patterns]:dir:_files -W $(hg root) -/' | 37 '*--include-[include names matching the given patterns]:dir:_files -W $(hg root) -/' |
27 '*-X-[exclude names matching the given patterns]:dir:_files -W $(hg root) -/' | 38 '*-X-[exclude names matching the given patterns]:dir:_files -W $(hg root) -/' |
28 '*--exclude-[exclude names matching the given patterns]:dir:_files -W $(hg root) -/') | 39 '*--exclude-[exclude names matching the given patterns]:dir:_files -W $(hg root) -/') |
40 | |
41 commitMessage=( | |
42 '(-m --message -l --logfile --edit)-e[edit commit message]' | |
43 '(-m --message -l --logfile -e)--edit[edit commit message]' | |
44 '(-e --edit -l --logfile --message)-m[use <text> as commit message]:message:' | |
45 '(-e --edit -l --logfile -m)--message[use <text> as commit message]:message:' | |
46 '(-e --edit -m --message --logfile)-l[read the commit message from <file>]:log file:_files' | |
47 '(-e --edit -m --message -l)--logfile[read the commit message from <file>]:log file:_files') | |
29 | 48 |
30 if [[ $service == "hg" ]]; then | 49 if [[ $service == "hg" ]]; then |
31 _arguments -C -A "-*" \ | 50 _arguments -C -A "-*" \ |
32 '(--repository)-R[repository root directory]:root:_files -/' \ | 51 '(--repository)-R[repository root directory]:root:_files -/' \ |
33 '(-R)--repository[repository root directory]:root:_files -/' \ | 52 '(-R)--repository[repository root directory]:root:_files -/' \ |
417 | 436 |
418 (identify|recover|root|undo|view|verify|version|ct|tags) | 437 (identify|recover|root|undo|view|verify|version|ct|tags) |
419 # no arguments for these commands | 438 # no arguments for these commands |
420 ;; | 439 ;; |
421 | 440 |
441 # MQ commands | |
442 (qdel*|qrm|qrem*) | |
443 _arguments \ | |
444 {-k,--keep}'[keep patch file]' \ | |
445 {-r,--rev}'[revision]:applied patch:->qapplied' \ | |
446 '*:unapplied patches:->qunapplied' | |
447 _mq_state | |
448 ;; | |
449 | |
450 (qnew) | |
451 _arguments $commitMessage \ | |
452 {-f,--force}'[import uncommitted changes into patch]' \ | |
453 ':patch name:' | |
454 ;; | |
455 | |
456 (qpo*) | |
457 applied=( $(hg qapplied) ) | |
458 _arguments \ | |
459 (1){-a,--all}'[pop all patches]' \ | |
460 {-f,--force}'[forget any local changes]' \ | |
461 ':applied patch:->qapplied' | |
462 _mq_state | |
463 ;; | |
464 | |
465 (qpu*) | |
466 _arguments \ | |
467 (1){-a,--all}'[apply all patches]' \ | |
468 {-f,--force}'[apply if the patch has rejects]' \ | |
469 ':unapplied patch:->qunapplied' | |
470 _mq_state | |
471 ;; | |
472 (qref*) | |
473 _arguments $commitMessage $includeExclude \ | |
474 {-g,--git}'[use git extended diff format]' \ | |
475 {-s,--short}'[short refresh]' | |
476 ;; | |
477 | |
422 (*) | 478 (*) |
423 _message "unknown hg command completion: $service" | 479 _message "unknown hg command completion: $service" |
424 ;; | 480 ;; |
425 esac | 481 esac |