Show More
@@ -17,25 +17,31 b' local curcontext="$curcontext" state lin' | |||||
17 | typeset -A _hg_cmd_globals |
|
17 | typeset -A _hg_cmd_globals | |
18 |
|
18 | |||
19 | _hg() { |
|
19 | _hg() { | |
20 | local cmd |
|
20 | local cmd _hg_root | |
21 | integer i=2 |
|
21 | integer i=2 | |
22 | _hg_cmd_globals=() |
|
22 | _hg_cmd_globals=() | |
23 |
|
23 | |||
24 | while (( i < $#words )) |
|
24 | while (( i < $#words )) | |
25 | do |
|
25 | do | |
26 | case "$words[$i]" in |
|
26 | case "$words[$i]" in | |
27 |
-R|--repository |
|
27 | -R|--repository) | |
28 | # pass along arguments to hg completer |
|
28 | _hg_root="$words[$i+1]" | |
29 | _hg_cmd_globals+="$words[$i]" |
|
29 | _hg_cmd_globals+=("$words[$i]" "$_hg_root") | |
30 | _hg_cmd_globals+="$words[$i+1]" |
|
|||
31 | (( i += 2 )) |
|
30 | (( i += 2 )) | |
32 | continue |
|
31 | continue | |
33 | ;; |
|
32 | ;; | |
34 | -R*) |
|
33 | -R*) | |
35 | _hg_cmd_globals+="$words[$i]" |
|
34 | _hg_cmd_globals+="$words[$i]" | |
|
35 | _hg_root="${words[$i]#-R}" | |||
36 | (( i++ )) |
|
36 | (( i++ )) | |
37 | continue |
|
37 | continue | |
38 | ;; |
|
38 | ;; | |
|
39 | --cwd|--config) | |||
|
40 | # pass along arguments to hg completer | |||
|
41 | _hg_cmd_globals+=("$words[$i]" "$words[$i+1]") | |||
|
42 | (( i += 2 )) | |||
|
43 | continue | |||
|
44 | ;; | |||
39 | -*) |
|
45 | -*) | |
40 | # skip option |
|
46 | # skip option | |
41 | (( i++ )) |
|
47 | (( i++ )) | |
@@ -91,7 +97,7 b' typeset -A _hg_cmd_globals' | |||||
91 | else |
|
97 | else | |
92 | # complete unknown commands normally |
|
98 | # complete unknown commands normally | |
93 | _arguments -s -w : $_hg_global_opts \ |
|
99 | _arguments -s -w : $_hg_global_opts \ | |
94 |
'*:files:_files |
|
100 | '*:files:_hg_files' | |
95 | fi |
|
101 | fi | |
96 | } |
|
102 | } | |
97 |
|
103 | |||
@@ -154,6 +160,23 b' typeset -A _hg_cmd_globals' | |||||
154 | (( $#tags )) && _describe -t tags 'tags' tags |
|
160 | (( $#tags )) && _describe -t tags 'tags' tags | |
155 | } |
|
161 | } | |
156 |
|
162 | |||
|
163 | _hg_files() { | |||
|
164 | if [[ -n "$_hg_root" ]] | |||
|
165 | then | |||
|
166 | [[ -d "$_hg_root/.hg" ]] || return | |||
|
167 | case "$_hg_root" in | |||
|
168 | /*) | |||
|
169 | _files -W $_hg_root | |||
|
170 | ;; | |||
|
171 | *) | |||
|
172 | _files -W $PWD/$_hg_root | |||
|
173 | ;; | |||
|
174 | esac | |||
|
175 | else | |||
|
176 | _files | |||
|
177 | fi | |||
|
178 | } | |||
|
179 | ||||
157 | _hg_status() { |
|
180 | _hg_status() { | |
158 | status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 . 2>/dev/null)"}) |
|
181 | status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 . 2>/dev/null)"}) | |
159 | } |
|
182 | } | |
@@ -316,7 +339,7 b' typeset -A _hg_cmd_globals' | |||||
316 | '(--date -d)'{-d,--date}'[list the date]' \ |
|
339 | '(--date -d)'{-d,--date}'[list the date]' \ | |
317 | '(--number -n)'{-n,--number}'[list the revision number (default)]' \ |
|
340 | '(--number -n)'{-n,--number}'[list the revision number (default)]' \ | |
318 | '(--changeset -c)'{-c,--changeset}'[list the changeset]' \ |
|
341 | '(--changeset -c)'{-c,--changeset}'[list the changeset]' \ | |
319 |
'*:files:_files |
|
342 | '*:files:_hg_files' | |
320 | } |
|
343 | } | |
321 |
|
344 | |||
322 | _hg_cmd_archive() { |
|
345 | _hg_cmd_archive() { | |
@@ -340,7 +363,7 b' typeset -A _hg_cmd_globals' | |||||
340 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ |
|
363 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ | |
341 | '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \ |
|
364 | '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \ | |
342 | '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \ |
|
365 | '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \ | |
343 |
'*:file:_files |
|
366 | '*:file:_hg_files' | |
344 | } |
|
367 | } | |
345 |
|
368 | |||
346 | _hg_cmd_clone() { |
|
369 | _hg_cmd_clone() { | |
@@ -359,14 +382,14 b' typeset -A _hg_cmd_globals' | |||||
359 | '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_file -g \*.txt' \ |
|
382 | '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_file -g \*.txt' \ | |
360 | '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \ |
|
383 | '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \ | |
361 | '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \ |
|
384 | '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \ | |
362 |
'*:file:_files |
|
385 | '*:file:_hg_files' | |
363 | } |
|
386 | } | |
364 |
|
387 | |||
365 | _hg_cmd_copy() { |
|
388 | _hg_cmd_copy() { | |
366 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ |
|
389 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ | |
367 | '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \ |
|
390 | '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \ | |
368 | '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ |
|
391 | '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ | |
369 |
'*:file:_files |
|
392 | '*:file:_hg_files' | |
370 | } |
|
393 | } | |
371 |
|
394 | |||
372 | _hg_cmd_diff() { |
|
395 | _hg_cmd_diff() { | |
@@ -383,7 +406,7 b' typeset -A _hg_cmd_globals' | |||||
383 | then |
|
406 | then | |
384 | if [[ -n $opt_args[-r] ]] |
|
407 | if [[ -n $opt_args[-r] ]] | |
385 | then |
|
408 | then | |
386 | _files -W $(_hg_cmd root) |
|
409 | _hg_files | |
387 | else |
|
410 | else | |
388 | _hg_modified |
|
411 | _hg_modified | |
389 | fi |
|
412 | fi | |
@@ -407,7 +430,7 b' typeset -A _hg_cmd_globals' | |||||
407 | '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \ |
|
430 | '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \ | |
408 | '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \ |
|
431 | '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \ | |
409 | '(--user -u)'{-u,--user}'[print user who committed change]' \ |
|
432 | '(--user -u)'{-u,--user}'[print user who committed change]' \ | |
410 |
'*:search pattern:_files |
|
433 | '*:search pattern:_hg_files' | |
411 | } |
|
434 | } | |
412 |
|
435 | |||
413 | _hg_cmd_heads() { |
|
436 | _hg_cmd_heads() { | |
@@ -449,7 +472,7 b' typeset -A _hg_cmd_globals' | |||||
449 | '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_tags' \ |
|
472 | '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_tags' \ | |
450 | '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ |
|
473 | '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ | |
451 | '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \ |
|
474 | '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \ | |
452 |
'*:search pattern:_files |
|
475 | '*:search pattern:_hg_files' | |
453 | } |
|
476 | } | |
454 |
|
477 | |||
455 | _hg_cmd_log() { |
|
478 | _hg_cmd_log() { | |
@@ -464,7 +487,7 b' typeset -A _hg_cmd_globals' | |||||
464 | '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \ |
|
487 | '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \ | |
465 | '(--patch -p)'{-p,--patch}'[show patch]' \ |
|
488 | '(--patch -p)'{-p,--patch}'[show patch]' \ | |
466 | '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_tags' \ |
|
489 | '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_tags' \ | |
467 |
'*:files:_files |
|
490 | '*:files:_hg_files' | |
468 | } |
|
491 | } | |
469 |
|
492 | |||
470 | _hg_cmd_manifest() { |
|
493 | _hg_cmd_manifest() { | |
@@ -511,14 +534,14 b' typeset -A _hg_cmd_globals' | |||||
511 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ |
|
534 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ | |
512 | '(--after -A)'{-A,--after}'[record remove that has already occurred]' \ |
|
535 | '(--after -A)'{-A,--after}'[record remove that has already occurred]' \ | |
513 | '(--force -f)'{-f,--force}'[remove file even if modified]' \ |
|
536 | '(--force -f)'{-f,--force}'[remove file even if modified]' \ | |
514 |
'*:file:_files |
|
537 | '*:file:_hg_files' | |
515 | } |
|
538 | } | |
516 |
|
539 | |||
517 | _hg_cmd_rename() { |
|
540 | _hg_cmd_rename() { | |
518 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ |
|
541 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ | |
519 | '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \ |
|
542 | '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \ | |
520 | '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ |
|
543 | '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ | |
521 |
'*:file:_files |
|
544 | '*:file:_hg_files' | |
522 | } |
|
545 | } | |
523 |
|
546 | |||
524 | _hg_cmd_revert() { |
|
547 | _hg_cmd_revert() { | |
@@ -532,7 +555,7 b' typeset -A _hg_cmd_globals' | |||||
532 | then |
|
555 | then | |
533 | if [[ -n $opt_args[-r] ]] |
|
556 | if [[ -n $opt_args[-r] ]] | |
534 | then |
|
557 | then | |
535 | _files -W $(_hg_cmd root) |
|
558 | _hg_files | |
536 | else |
|
559 | else | |
537 | typeset -a status_files |
|
560 | typeset -a status_files | |
538 | _hg_status mard |
|
561 | _hg_status mard | |
@@ -657,7 +680,7 b' typeset -A _hg_cmd_globals' | |||||
657 |
|
680 | |||
658 | _hg_cmd_qdiff() { |
|
681 | _hg_cmd_qdiff() { | |
659 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ |
|
682 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ | |
660 |
'*:pattern:_files |
|
683 | '*:pattern:_hg_files' | |
661 | } |
|
684 | } | |
662 |
|
685 | |||
663 | _hg_cmd_qfold() { |
|
686 | _hg_cmd_qfold() { | |
@@ -724,7 +747,7 b' typeset -A _hg_cmd_globals' | |||||
724 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \ |
|
747 | _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \ | |
725 | '(--git -g)'{-g,--git}'[use git extended diff format]' \ |
|
748 | '(--git -g)'{-g,--git}'[use git extended diff format]' \ | |
726 | '(--short -s)'{-s,--short}'[short refresh]' \ |
|
749 | '(--short -s)'{-s,--short}'[short refresh]' \ | |
727 |
'*:files:_files |
|
750 | '*:files:_hg_files' | |
728 | } |
|
751 | } | |
729 |
|
752 | |||
730 | _hg_cmd_qrename() { |
|
753 | _hg_cmd_qrename() { |
General Comments 0
You need to be logged in to leave comments.
Login now