##// END OF EJS Templates
zsh: make resolve with no options only complete unresolved files
Brendan Cully -
r7386:86bfd655 default
parent child Browse files
Show More
@@ -1,885 +1,886 b''
1 1 #compdef hg
2 2
3 3 # Zsh completion script for mercurial. Rename this file to _hg and copy
4 4 # it into your zsh function path (/usr/share/zsh/site-functions for
5 5 # instance)
6 6 #
7 7 # Copyright (C) 2005 Steve Borho
8 8 # Copyright (C) 2006-8 Brendan Cully <brendan@kublai.com>
9 9 #
10 10 # This is free software; you can redistribute it and/or modify it under
11 11 # the terms of the GNU General Public License as published by the Free
12 12 # Software Foundation; either version 2 of the License, or (at your
13 13 # option) any later version.
14 14 #
15 15
16 16 emulate -LR zsh
17 17 setopt extendedglob
18 18
19 19 local curcontext="$curcontext" state line
20 20 typeset -A _hg_cmd_globals
21 21
22 22 _hg() {
23 23 local cmd _hg_root
24 24 integer i=2
25 25 _hg_cmd_globals=()
26 26
27 27 while (( i < $#words ))
28 28 do
29 29 case "$words[$i]" in
30 30 -R|--repository)
31 31 eval _hg_root="$words[$i+1]"
32 32 _hg_cmd_globals+=("$words[$i]" "$_hg_root")
33 33 (( i += 2 ))
34 34 continue
35 35 ;;
36 36 -R*)
37 37 _hg_cmd_globals+="$words[$i]"
38 38 eval _hg_root="${words[$i]#-R}"
39 39 (( i++ ))
40 40 continue
41 41 ;;
42 42 --cwd|--config)
43 43 # pass along arguments to hg completer
44 44 _hg_cmd_globals+=("$words[$i]" "$words[$i+1]")
45 45 (( i += 2 ))
46 46 continue
47 47 ;;
48 48 -*)
49 49 # skip option
50 50 (( i++ ))
51 51 continue
52 52 ;;
53 53 esac
54 54 if [[ -z "$cmd" ]]
55 55 then
56 56 cmd="$words[$i]"
57 57 words[$i]=()
58 58 (( CURRENT-- ))
59 59 fi
60 60 (( i++ ))
61 61 done
62 62
63 63 if [[ -z "$cmd" ]]
64 64 then
65 65 _arguments -s -w : $_hg_global_opts \
66 66 ':mercurial command:_hg_commands'
67 67 return
68 68 fi
69 69
70 70 # resolve abbreviations and aliases
71 71 if ! (( $+functions[_hg_cmd_${cmd}] ))
72 72 then
73 73 local cmdexp
74 74 (( $#_hg_cmd_list )) || _hg_get_commands
75 75
76 76 cmdexp=$_hg_cmd_list[(r)${cmd}*]
77 77 if [[ $cmdexp == $_hg_cmd_list[(R)${cmd}*] ]]
78 78 then
79 79 # might be nice to rewrite the command line with the expansion
80 80 cmd="$cmdexp"
81 81 fi
82 82 if [[ -n $_hg_alias_list[$cmd] ]]
83 83 then
84 84 cmd=$_hg_alias_list[$cmd]
85 85 fi
86 86 fi
87 87
88 88 curcontext="${curcontext%:*:*}:hg-${cmd}:"
89 89
90 90 zstyle -s ":completion:$curcontext:" cache-policy update_policy
91 91
92 92 if [[ -z "$update_policy" ]]
93 93 then
94 94 zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy
95 95 fi
96 96
97 97 if (( $+functions[_hg_cmd_${cmd}] ))
98 98 then
99 99 _hg_cmd_${cmd}
100 100 else
101 101 # complete unknown commands normally
102 102 _arguments -s -w : $_hg_global_opts \
103 103 '*:files:_hg_files'
104 104 fi
105 105 }
106 106
107 107 _hg_cache_policy() {
108 108 typeset -a old
109 109
110 110 # cache for a minute
111 111 old=( "$1"(mm+10) )
112 112 (( $#old )) && return 0
113 113
114 114 return 1
115 115 }
116 116
117 117 _hg_get_commands() {
118 118 typeset -ga _hg_cmd_list
119 119 typeset -gA _hg_alias_list
120 120 local hline cmd cmdalias
121 121 _call_program help hg --verbose help | while read -A hline
122 122 do
123 123 cmd="$hline[1]"
124 124 case $cmd in
125 125 *:)
126 126 cmd=${cmd%:}
127 127 _hg_cmd_list+=($cmd)
128 128 ;;
129 129 *,)
130 130 cmd=${cmd%,}
131 131 _hg_cmd_list+=($cmd)
132 132 integer i=2
133 133 while (( i <= $#hline ))
134 134 do
135 135 cmdalias=${hline[$i]%(:|,)}
136 136 _hg_cmd_list+=($cmdalias)
137 137 _hg_alias_list+=($cmdalias $cmd)
138 138 (( i++ ))
139 139 done
140 140 ;;
141 141 esac
142 142 done
143 143 }
144 144
145 145 _hg_commands() {
146 146 (( $#_hg_cmd_list )) || _hg_get_commands
147 147 _describe -t commands 'mercurial command' _hg_cmd_list
148 148 }
149 149
150 150 _hg_revrange() {
151 151 compset -P 1 '*:'
152 152 _hg_tags "$@"
153 153 }
154 154
155 155 _hg_tags() {
156 156 typeset -a tags
157 157 local tag rev
158 158
159 159 _hg_cmd tags 2> /dev/null | while read tag
160 160 do
161 161 tags+=(${tag/ # [0-9]#:*})
162 162 done
163 163 (( $#tags )) && _describe -t tags 'tags' tags
164 164 }
165 165
166 166 _hg_files() {
167 167 if [[ -n "$_hg_root" ]]
168 168 then
169 169 [[ -d "$_hg_root/.hg" ]] || return
170 170 case "$_hg_root" in
171 171 /*)
172 172 _files -W $_hg_root
173 173 ;;
174 174 *)
175 175 _files -W $PWD/$_hg_root
176 176 ;;
177 177 esac
178 178 else
179 179 _files
180 180 fi
181 181 }
182 182
183 183 _hg_status() {
184 184 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
185 185 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX 2>/dev/null)"})
186 186 }
187 187
188 188 _hg_unknown() {
189 189 typeset -a status_files
190 190 _hg_status u
191 191 _wanted files expl 'unknown files' _multi_parts / status_files
192 192 }
193 193
194 194 _hg_missing() {
195 195 typeset -a status_files
196 196 _hg_status d
197 197 _wanted files expl 'missing files' _multi_parts / status_files
198 198 }
199 199
200 200 _hg_modified() {
201 201 typeset -a status_files
202 202 _hg_status m
203 203 _wanted files expl 'modified files' _multi_parts / status_files
204 204 }
205 205
206 206 _hg_resolve() {
207 207 local rstate rpah
208 208
209 209 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
210 210
211 211 _hg_cmd resolve -l ./$PREFIX 2> /dev/null | while read rstate rpath
212 212 do
213 213 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
214 214 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
215 215 done
216 216 }
217 217
218 218 _hg_resolved() {
219 219 typeset -a resolved_files unresolved_files
220 220 _hg_resolve
221 221 _wanted files expl 'resolved files' _multi_parts / resolved_files
222 222 }
223 223
224 224 _hg_unresolved() {
225 225 typeset -a resolved_files unresolved_files
226 226 _hg_resolve
227 227 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
228 228 }
229 229
230 230 _hg_config() {
231 231 typeset -a items
232 232 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
233 233 (( $#items )) && _describe -t config 'config item' items
234 234 }
235 235
236 236 _hg_addremove() {
237 237 _alternative 'files:unknown files:_hg_unknown' \
238 238 'files:missing files:_hg_missing'
239 239 }
240 240
241 241 _hg_ssh_urls() {
242 242 if [[ -prefix */ ]]
243 243 then
244 244 if zstyle -T ":completion:${curcontext}:files" remote-access
245 245 then
246 246 local host=${PREFIX%%/*}
247 247 typeset -a remdirs
248 248 compset -p $(( $#host + 1 ))
249 249 local rempath=${(M)PREFIX##*/}
250 250 local cacheid="hg:${host}-${rempath//\//_}"
251 251 cacheid=${cacheid%[-_]}
252 252 compset -P '*/'
253 253 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
254 254 then
255 255 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/})
256 256 _store_cache "$cacheid" remdirs
257 257 fi
258 258 _describe -t directories 'remote directory' remdirs -S/
259 259 else
260 260 _message 'remote directory'
261 261 fi
262 262 else
263 263 if compset -P '*@'
264 264 then
265 265 _hosts -S/
266 266 else
267 267 _alternative 'hosts:remote host name:_hosts -S/' \
268 268 'users:user:_users -S@'
269 269 fi
270 270 fi
271 271 }
272 272
273 273 _hg_urls() {
274 274 if compset -P bundle://
275 275 then
276 276 _files
277 277 elif compset -P ssh://
278 278 then
279 279 _hg_ssh_urls
280 280 elif [[ -prefix *: ]]
281 281 then
282 282 _urls
283 283 else
284 284 local expl
285 285 compset -S '[^:]*'
286 286 _wanted url-schemas expl 'URL schema' compadd -S '' - \
287 287 http:// https:// ssh:// bundle://
288 288 fi
289 289 }
290 290
291 291 _hg_paths() {
292 292 typeset -a paths pnames
293 293 _hg_cmd paths 2> /dev/null | while read -A pnames
294 294 do
295 295 paths+=($pnames[1])
296 296 done
297 297 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
298 298 }
299 299
300 300 _hg_remote() {
301 301 _alternative 'path-aliases:repository alias:_hg_paths' \
302 302 'directories:directory:_files -/' \
303 303 'urls:URL:_hg_urls'
304 304 }
305 305
306 306 _hg_clone_dest() {
307 307 _alternative 'directories:directory:_files -/' \
308 308 'urls:URL:_hg_urls'
309 309 }
310 310
311 311 # Common options
312 312 _hg_global_opts=(
313 313 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
314 314 '--cwd[change working directory]:new working directory:_files -/'
315 315 '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
316 316 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
317 317 '*--config[set/override config option]:defined config items:_hg_config'
318 318 '(--quiet -q)'{-q,--quiet}'[suppress output]'
319 319 '(--help -h)'{-h,--help}'[display help and exit]'
320 320 '--debug[debug mode]'
321 321 '--debugger[start debugger]'
322 322 '--encoding[set the charset encoding (default: UTF8)]'
323 323 '--encodingmode[set the charset encoding mode (default: strict)]'
324 324 '--lsprof[print improved command execution profile]'
325 325 '--traceback[print traceback on exception]'
326 326 '--time[time how long the command takes]'
327 327 '--profile[profile]'
328 328 '--version[output version information and exit]'
329 329 )
330 330
331 331 _hg_pat_opts=(
332 332 '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
333 333 '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
334 334
335 335 _hg_diff_opts=(
336 336 '(--text -a)'{-a,--text}'[treat all files as text]'
337 337 '(--git -g)'{-g,--git}'[use git extended diff format]'
338 338 "--nodates[don't include dates in diff headers]")
339 339
340 340 _hg_dryrun_opts=(
341 341 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
342 342
343 343 _hg_style_opts=(
344 344 '--style[display using template map file]:'
345 345 '--template[display with template]:')
346 346
347 347 _hg_commit_opts=(
348 348 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
349 349 '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use <text> as commit message]:message:'
350 350 '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from <file>]:log file:_files')
351 351
352 352 _hg_remote_opts=(
353 353 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
354 354 '--remotecmd[specify hg command to run on the remote side]:')
355 355
356 356 _hg_cmd() {
357 357 _call_program hg hg "$_hg_cmd_globals[@]" "$@"
358 358 }
359 359
360 360 _hg_cmd_add() {
361 361 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
362 362 '*:unknown files:_hg_unknown'
363 363 }
364 364
365 365 _hg_cmd_addremove() {
366 366 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
367 367 '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
368 368 '*:unknown or missing files:_hg_addremove'
369 369 }
370 370
371 371 _hg_cmd_annotate() {
372 372 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
373 373 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_tags' \
374 374 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
375 375 '(--text -a)'{-a,--text}'[treat all files as text]' \
376 376 '(--user -u)'{-u,--user}'[list the author]' \
377 377 '(--date -d)'{-d,--date}'[list the date]' \
378 378 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
379 379 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
380 380 '*:files:_hg_files'
381 381 }
382 382
383 383 _hg_cmd_archive() {
384 384 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
385 385 '--no-decode[do not pass files through decoders]' \
386 386 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
387 387 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_tags' \
388 388 '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
389 389 '*:destination:_files'
390 390 }
391 391
392 392 _hg_cmd_backout() {
393 393 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
394 394 '--merge[merge with old dirstate parent after backout]' \
395 395 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
396 396 '--parent[parent to choose when backing out merge]' \
397 397 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
398 398 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
399 399 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
400 400 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt'
401 401 }
402 402
403 403 _hg_cmd_bundle() {
404 404 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
405 405 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
406 406 '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_tags' \
407 407 ':output file:_files' \
408 408 ':destination repository:_files -/'
409 409 }
410 410
411 411 _hg_cmd_cat() {
412 412 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
413 413 '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
414 414 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
415 415 '*:file:_hg_files'
416 416 }
417 417
418 418 _hg_cmd_clone() {
419 419 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
420 420 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
421 421 '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
422 422 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
423 423 ':source repository:_hg_remote' \
424 424 ':destination:_hg_clone_dest'
425 425 }
426 426
427 427 _hg_cmd_commit() {
428 428 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
429 429 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
430 430 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
431 431 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt' \
432 432 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
433 433 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
434 434 '*:file:_hg_files'
435 435 }
436 436
437 437 _hg_cmd_copy() {
438 438 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
439 439 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
440 440 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
441 441 '*:file:_hg_files'
442 442 }
443 443
444 444 _hg_cmd_diff() {
445 445 typeset -A opt_args
446 446 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
447 447 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
448 448 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
449 449 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
450 450 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
451 451 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \
452 452 '*:file:->diff_files'
453 453
454 454 if [[ $state == 'diff_files' ]]
455 455 then
456 456 if [[ -n $opt_args[-r] ]]
457 457 then
458 458 _hg_files
459 459 else
460 460 _hg_modified
461 461 fi
462 462 fi
463 463 }
464 464
465 465 _hg_cmd_export() {
466 466 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
467 467 '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
468 468 '--switch-parent[diff against the second parent]' \
469 469 '*:revision:_hg_tags'
470 470 }
471 471
472 472 _hg_cmd_grep() {
473 473 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
474 474 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
475 475 '--all[print all revisions with matches]' \
476 476 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
477 477 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
478 478 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
479 479 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
480 480 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
481 481 '(--user -u)'{-u,--user}'[print user who committed change]' \
482 482 '1:search pattern:' \
483 483 '*:files:_hg_files'
484 484 }
485 485
486 486 _hg_cmd_heads() {
487 487 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
488 488 '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_tags'
489 489 }
490 490
491 491 _hg_cmd_help() {
492 492 _arguments -s -w : $_hg_global_opts \
493 493 '*:mercurial command:_hg_commands'
494 494 }
495 495
496 496 _hg_cmd_identify() {
497 497 _arguments -s -w : $_hg_global_opts \
498 498 '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_tags' \
499 499 '(--num -n)'{-n+,--num}'[show local revision number]' \
500 500 '(--id -i)'{-i+,--id}'[show global revision id]' \
501 501 '(--branch -b)'{-b+,--branch}'[show branch]' \
502 502 '(--tags -t)'{-t+,--tags}'[show tags]'
503 503 }
504 504
505 505 _hg_cmd_import() {
506 506 _arguments -s -w : $_hg_global_opts \
507 507 '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
508 508 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
509 509 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
510 510 '*:patch:_files'
511 511 }
512 512
513 513 _hg_cmd_incoming() {
514 514 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
515 515 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
516 516 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
517 517 '(--patch -p)'{-p,--patch}'[show patch]' \
518 518 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
519 519 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
520 520 '--bundle[file to store the bundles into]:bundle file:_files' \
521 521 ':source:_hg_remote'
522 522 }
523 523
524 524 _hg_cmd_init() {
525 525 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
526 526 ':dir:_files -/'
527 527 }
528 528
529 529 _hg_cmd_locate() {
530 530 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
531 531 '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_tags' \
532 532 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
533 533 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
534 534 '*:search pattern:_hg_files'
535 535 }
536 536
537 537 _hg_cmd_log() {
538 538 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
539 539 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
540 540 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
541 541 '(--copies -C)'{-C,--copies}'[show copied files]' \
542 542 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
543 543 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
544 544 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
545 545 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
546 546 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
547 547 '(--patch -p)'{-p,--patch}'[show patch]' \
548 548 '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_tags' \
549 549 '*:files:_hg_files'
550 550 }
551 551
552 552 _hg_cmd_manifest() {
553 553 _arguments -s -w : $_hg_global_opts \
554 554 ':revision:_hg_tags'
555 555 }
556 556
557 557 _hg_cmd_outgoing() {
558 558 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
559 559 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
560 560 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
561 561 '(--patch -p)'{-p,--patch}'[show patch]' \
562 562 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
563 563 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
564 564 ':destination:_hg_remote'
565 565 }
566 566
567 567 _hg_cmd_parents() {
568 568 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
569 569 '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_tags' \
570 570 ':last modified file:_hg_files'
571 571 }
572 572
573 573 _hg_cmd_paths() {
574 574 _arguments -s -w : $_hg_global_opts \
575 575 ':path:_hg_paths'
576 576 }
577 577
578 578 _hg_cmd_pull() {
579 579 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
580 580 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
581 581 '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
582 582 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
583 583 ':source:_hg_remote'
584 584 }
585 585
586 586 _hg_cmd_push() {
587 587 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
588 588 '(--force -f)'{-f,--force}'[force push]' \
589 589 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_tags' \
590 590 ':destination:_hg_remote'
591 591 }
592 592
593 593 _hg_cmd_remove() {
594 594 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
595 595 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
596 596 '(--force -f)'{-f,--force}'[remove file even if modified]' \
597 597 '*:file:_hg_files'
598 598 }
599 599
600 600 _hg_cmd_rename() {
601 601 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
602 602 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
603 603 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
604 604 '*:file:_hg_files'
605 605 }
606 606
607 607 _hg_cmd_resolve() {
608 608 local context state line
609 609 typeset -A opt_args
610 610
611 611 _arguments -s -w : $_hg_global_opts \
612 612 '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
613 613 '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
614 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved'
614 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
615 '*:file:_hg_unresolved'
615 616
616 617 if [[ $state == 'resolve_files' ]]
617 618 then
618 619 _alternative 'files:resolved files:_hg_resolved' \
619 620 'files:unresolved files:_hg_unresolved'
620 621 fi
621 622 }
622 623
623 624 _hg_cmd_revert() {
624 625 local context state line
625 626 typeset -A opt_args
626 627
627 628 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
628 629 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
629 630 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_tags' \
630 631 '--no-backup[do not save backup copies of files]' \
631 632 '*:file:->diff_files'
632 633
633 634 if [[ $state == 'diff_files' ]]
634 635 then
635 636 if [[ -n $opt_args[-r] ]]
636 637 then
637 638 _hg_files
638 639 else
639 640 typeset -a status_files
640 641 _hg_status mard
641 642 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files
642 643 fi
643 644 fi
644 645 }
645 646
646 647 _hg_cmd_serve() {
647 648 _arguments -s -w : $_hg_global_opts \
648 649 '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
649 650 '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
650 651 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
651 652 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
652 653 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
653 654 '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
654 655 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
655 656 '--style[web template style]:style' \
656 657 '--stdio[for remote clients]' \
657 658 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
658 659 }
659 660
660 661 _hg_cmd_showconfig() {
661 662 _arguments -s -w : $_hg_global_opts \
662 663 '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
663 664 ':config item:_hg_config'
664 665 }
665 666
666 667 _hg_cmd_status() {
667 668 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
668 669 '(--all -A)'{-A,--all}'[show status of all files]' \
669 670 '(--modified -m)'{-m,--modified}'[show only modified files]' \
670 671 '(--added -a)'{-a,--added}'[show only added files]' \
671 672 '(--removed -r)'{-r,--removed}'[show only removed files]' \
672 673 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
673 674 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
674 675 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
675 676 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
676 677 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
677 678 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
678 679 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
679 680 '--rev[show difference from revision]:revision:_hg_tags' \
680 681 '*:files:_files'
681 682 }
682 683
683 684 _hg_cmd_tag() {
684 685 _arguments -s -w : $_hg_global_opts \
685 686 '(--local -l)'{-l,--local}'[make the tag local]' \
686 687 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
687 688 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
688 689 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
689 690 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_tags' \
690 691 ':tag name:'
691 692 }
692 693
693 694 _hg_cmd_tip() {
694 695 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
695 696 '(--patch -p)'{-p,--patch}'[show patch]'
696 697 }
697 698
698 699 _hg_cmd_unbundle() {
699 700 _arguments -s -w : $_hg_global_opts \
700 701 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
701 702 ':files:_files'
702 703 }
703 704
704 705 _hg_cmd_update() {
705 706 _arguments -s -w : $_hg_global_opts \
706 707 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
707 708 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
708 709 ':revision:_hg_tags'
709 710 }
710 711
711 712 # bisect extension
712 713 _hg_cmd_bisect() {
713 714 _arguments -s -w : $_hg_global_opts ':evaluation:(help init reset next good bad)'
714 715 }
715 716
716 717 # HGK
717 718 _hg_cmd_view() {
718 719 _arguments -s -w : $_hg_global_opts \
719 720 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
720 721 ':revision range:_hg_tags'
721 722 }
722 723
723 724 # MQ
724 725 _hg_qseries() {
725 726 typeset -a patches
726 727 patches=(${(f)"$(_hg_cmd qseries 2>/dev/null)"})
727 728 (( $#patches )) && _describe -t hg-patches 'patches' patches
728 729 }
729 730
730 731 _hg_qapplied() {
731 732 typeset -a patches
732 733 patches=(${(f)"$(_hg_cmd qapplied 2>/dev/null)"})
733 734 if (( $#patches ))
734 735 then
735 736 patches+=(qbase qtip)
736 737 _describe -t hg-applied-patches 'applied patches' patches
737 738 fi
738 739 }
739 740
740 741 _hg_qunapplied() {
741 742 typeset -a patches
742 743 patches=(${(f)"$(_hg_cmd qunapplied 2>/dev/null)"})
743 744 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
744 745 }
745 746
746 747 _hg_qguards() {
747 748 typeset -a guards
748 749 local guard
749 750 compset -P "+|-"
750 751 _hg_cmd qselect -s 2>/dev/null | while read guard
751 752 do
752 753 guards+=(${guard#(+|-)})
753 754 done
754 755 (( $#guards )) && _describe -t hg-guards 'guards' guards
755 756 }
756 757
757 758 _hg_qseries_opts=(
758 759 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
759 760
760 761 _hg_cmd_qapplied() {
761 762 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
762 763 }
763 764
764 765 _hg_cmd_qdelete() {
765 766 _arguments -s -w : $_hg_global_opts \
766 767 '(--keep -k)'{-k,--keep}'[keep patch file]' \
767 768 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
768 769 '*:unapplied patch:_hg_qunapplied'
769 770 }
770 771
771 772 _hg_cmd_qdiff() {
772 773 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
773 774 '*:pattern:_hg_files'
774 775 }
775 776
776 777 _hg_cmd_qfold() {
777 778 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
778 779 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
779 780 '*:unapplied patch:_hg_qunapplied'
780 781 }
781 782
782 783 _hg_cmd_qgoto() {
783 784 _arguments -s -w : $_hg_global_opts \
784 785 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
785 786 ':patch:_hg_qseries'
786 787 }
787 788
788 789 _hg_cmd_qguard() {
789 790 _arguments -s -w : $_hg_global_opts \
790 791 '(--list -l)'{-l,--list}'[list all patches and guards]' \
791 792 '(--none -n)'{-n,--none}'[drop all guards]' \
792 793 ':patch:_hg_qseries' \
793 794 '*:guards:_hg_qguards'
794 795 }
795 796
796 797 _hg_cmd_qheader() {
797 798 _arguments -s -w : $_hg_global_opts \
798 799 ':patch:_hg_qseries'
799 800 }
800 801
801 802 _hg_cmd_qimport() {
802 803 _arguments -s -w : $_hg_global_opts \
803 804 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
804 805 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
805 806 '(--force -f)'{-f,--force}'[overwrite existing files]' \
806 807 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
807 808 '*:patch:_files'
808 809 }
809 810
810 811 _hg_cmd_qnew() {
811 812 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
812 813 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
813 814 ':patch:'
814 815 }
815 816
816 817 _hg_cmd_qnext() {
817 818 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
818 819 }
819 820
820 821 _hg_cmd_qpop() {
821 822 _arguments -s -w : $_hg_global_opts \
822 823 '(--all -a :)'{-a,--all}'[pop all patches]' \
823 824 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
824 825 '(--force -f)'{-f,--force}'[forget any local changes]' \
825 826 ':patch:_hg_qapplied'
826 827 }
827 828
828 829 _hg_cmd_qprev() {
829 830 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
830 831 }
831 832
832 833 _hg_cmd_qpush() {
833 834 _arguments -s -w : $_hg_global_opts \
834 835 '(--all -a :)'{-a,--all}'[apply all patches]' \
835 836 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
836 837 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
837 838 '(--name -n)'{-n+,--name}'[merge queue name]:' \
838 839 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
839 840 ':patch:_hg_qunapplied'
840 841 }
841 842
842 843 _hg_cmd_qrefresh() {
843 844 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
844 845 '(--git -g)'{-g,--git}'[use git extended diff format]' \
845 846 '(--short -s)'{-s,--short}'[short refresh]' \
846 847 '*:files:_hg_files'
847 848 }
848 849
849 850 _hg_cmd_qrename() {
850 851 _arguments -s -w : $_hg_global_opts \
851 852 ':patch:_hg_qseries' \
852 853 ':destination:'
853 854 }
854 855
855 856 _hg_cmd_qselect() {
856 857 _arguments -s -w : $_hg_global_opts \
857 858 '(--none -n :)'{-n,--none}'[disable all guards]' \
858 859 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
859 860 '--pop[pop to before first guarded applied patch]' \
860 861 '--reapply[pop and reapply patches]' \
861 862 '*:guards:_hg_qguards'
862 863 }
863 864
864 865 _hg_cmd_qseries() {
865 866 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
866 867 '(--missing -m)'{-m,--missing}'[print patches not in series]'
867 868 }
868 869
869 870 _hg_cmd_qunapplied() {
870 871 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
871 872 }
872 873
873 874 _hg_cmd_qtop() {
874 875 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
875 876 }
876 877
877 878 _hg_cmd_strip() {
878 879 _arguments -s -w : $_hg_global_opts \
879 880 '(--force -f)'{-f,--force}'[force multi-head removal]' \
880 881 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
881 882 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
882 883 ':revision:_hg_tags'
883 884 }
884 885
885 886 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now