##// END OF EJS Templates
zsh completion: update mq commands completion...
Nikolaj Sjujskij -
r17402:f6851cd9 default
parent child Browse files
Show More
@@ -1,1213 +1,1227
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 # If you do not want to install it globally, you can copy it somewhere
8 8 # else and add that directory to $fpath. This must be done before
9 9 # compinit is called. If the file is copied to ~/.zsh.d, your ~/.zshrc
10 10 # file could look like this:
11 11 #
12 12 # fpath=("$HOME/.zsh.d" $fpath)
13 13 # autoload -U compinit
14 14 # compinit
15 15 #
16 16 # Copyright (C) 2005, 2006 Steve Borho <steve@borho.org>
17 17 # Copyright (C) 2006-10 Brendan Cully <brendan@kublai.com>
18 18 #
19 19 # Permission is hereby granted, without written agreement and without
20 20 # licence or royalty fees, to use, copy, modify, and distribute this
21 21 # software and to distribute modified versions of this software for any
22 22 # purpose, provided that the above copyright notice and the following
23 23 # two paragraphs appear in all copies of this software.
24 24 #
25 25 # In no event shall the authors be liable to any party for direct,
26 26 # indirect, special, incidental, or consequential damages arising out of
27 27 # the use of this software and its documentation, even if the authors
28 28 # have been advised of the possibility of such damage.
29 29 #
30 30 # The authors specifically disclaim any warranties, including, but not
31 31 # limited to, the implied warranties of merchantability and fitness for
32 32 # a particular purpose. The software provided hereunder is on an "as
33 33 # is" basis, and the authors have no obligation to provide maintenance,
34 34 # support, updates, enhancements, or modifications.
35 35
36 36 emulate -LR zsh
37 37 setopt extendedglob
38 38
39 39 local curcontext="$curcontext" state line
40 40 typeset -A _hg_cmd_globals
41 41
42 42 _hg() {
43 43 local cmd _hg_root
44 44 integer i=2
45 45 _hg_cmd_globals=()
46 46
47 47 while (( i < $#words ))
48 48 do
49 49 case "$words[$i]" in
50 50 -R|--repository)
51 51 eval _hg_root="$words[$i+1]"
52 52 _hg_cmd_globals+=("$words[$i]" "$_hg_root")
53 53 (( i += 2 ))
54 54 continue
55 55 ;;
56 56 -R*)
57 57 _hg_cmd_globals+="$words[$i]"
58 58 eval _hg_root="${words[$i]#-R}"
59 59 (( i++ ))
60 60 continue
61 61 ;;
62 62 --cwd|--config)
63 63 # pass along arguments to hg completer
64 64 _hg_cmd_globals+=("$words[$i]" "$words[$i+1]")
65 65 (( i += 2 ))
66 66 continue
67 67 ;;
68 68 -*)
69 69 # skip option
70 70 (( i++ ))
71 71 continue
72 72 ;;
73 73 esac
74 74 if [[ -z "$cmd" ]]
75 75 then
76 76 cmd="$words[$i]"
77 77 words[$i]=()
78 78 (( CURRENT-- ))
79 79 fi
80 80 (( i++ ))
81 81 done
82 82
83 83 if [[ -z "$cmd" ]]
84 84 then
85 85 _arguments -s -w : $_hg_global_opts \
86 86 ':mercurial command:_hg_commands'
87 87 return
88 88 fi
89 89
90 90 # resolve abbreviations and aliases
91 91 if ! (( $+functions[_hg_cmd_${cmd}] ))
92 92 then
93 93 local cmdexp
94 94 (( $#_hg_cmd_list )) || _hg_get_commands
95 95
96 96 cmdexp=$_hg_cmd_list[(r)${cmd}*]
97 97 if [[ $cmdexp == $_hg_cmd_list[(R)${cmd}*] ]]
98 98 then
99 99 # might be nice to rewrite the command line with the expansion
100 100 cmd="$cmdexp"
101 101 fi
102 102 if [[ -n $_hg_alias_list[$cmd] ]]
103 103 then
104 104 cmd=$_hg_alias_list[$cmd]
105 105 fi
106 106 fi
107 107
108 108 curcontext="${curcontext%:*:*}:hg-${cmd}:"
109 109
110 110 zstyle -s ":completion:$curcontext:" cache-policy update_policy
111 111
112 112 if [[ -z "$update_policy" ]]
113 113 then
114 114 zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy
115 115 fi
116 116
117 117 if (( $+functions[_hg_cmd_${cmd}] ))
118 118 then
119 119 _hg_cmd_${cmd}
120 120 else
121 121 # complete unknown commands normally
122 122 _arguments -s -w : $_hg_global_opts \
123 123 '*:files:_hg_files'
124 124 fi
125 125 }
126 126
127 127 _hg_cache_policy() {
128 128 typeset -a old
129 129
130 130 # cache for a minute
131 131 old=( "$1"(mm+10) )
132 132 (( $#old )) && return 0
133 133
134 134 return 1
135 135 }
136 136
137 137 _hg_get_commands() {
138 138 typeset -ga _hg_cmd_list
139 139 typeset -gA _hg_alias_list
140 140 local hline cmd cmdalias
141 141
142 142 _call_program hg hg debugcomplete -v | while read -A hline
143 143 do
144 144 cmd=$hline[1]
145 145 _hg_cmd_list+=($cmd)
146 146
147 147 for cmdalias in $hline[2,-1]
148 148 do
149 149 _hg_cmd_list+=($cmdalias)
150 150 _hg_alias_list+=($cmdalias $cmd)
151 151 done
152 152 done
153 153 }
154 154
155 155 _hg_commands() {
156 156 (( $#_hg_cmd_list )) || _hg_get_commands
157 157 _describe -t commands 'mercurial command' _hg_cmd_list
158 158 }
159 159
160 160 _hg_revrange() {
161 161 compset -P 1 '*:'
162 162 _hg_labels "$@"
163 163 }
164 164
165 165 _hg_labels() {
166 166 _hg_tags "$@"
167 167 _hg_bookmarks "$@"
168 168 _hg_branches "$@"
169 169 }
170 170
171 171 _hg_tags() {
172 172 typeset -a tags
173 173 local tag rev
174 174
175 175 _hg_cmd tags | while read tag
176 176 do
177 177 tags+=(${tag/ # [0-9]#:*})
178 178 done
179 179 (( $#tags )) && _describe -t tags 'tags' tags
180 180 }
181 181
182 182 _hg_bookmarks() {
183 183 typeset -a bookmark bookmarks
184 184
185 185 _hg_cmd bookmarks | while read -A bookmark
186 186 do
187 187 if test -z ${bookmark[-1]:#[0-9]*}
188 188 then
189 189 bookmarks+=($bookmark[-2])
190 190 fi
191 191 done
192 192 (( $#bookmarks )) && _describe -t bookmarks 'bookmarks' bookmarks
193 193 }
194 194
195 195 _hg_branches() {
196 196 typeset -a branches
197 197 local branch
198 198
199 199 _hg_cmd branches | while read branch
200 200 do
201 201 branches+=(${branch/ # [0-9]#:*})
202 202 done
203 203 (( $#branches )) && _describe -t branches 'branches' branches
204 204 }
205 205
206 206 # likely merge candidates
207 207 _hg_mergerevs() {
208 208 typeset -a heads
209 209 local myrev
210 210
211 211 heads=(${(f)"$(_hg_cmd heads --template '{rev}\\n')"})
212 212 # exclude own revision
213 213 myrev=$(_hg_cmd log -r . --template '{rev}\\n')
214 214 heads=(${heads:#$myrev})
215 215
216 216 (( $#heads )) && _describe -t heads 'heads' heads
217 217 }
218 218
219 219 _hg_files() {
220 220 if [[ -n "$_hg_root" ]]
221 221 then
222 222 [[ -d "$_hg_root/.hg" ]] || return
223 223 case "$_hg_root" in
224 224 /*)
225 225 _files -W $_hg_root
226 226 ;;
227 227 *)
228 228 _files -W $PWD/$_hg_root
229 229 ;;
230 230 esac
231 231 else
232 232 _files
233 233 fi
234 234 }
235 235
236 236 _hg_status() {
237 237 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
238 238 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
239 239 }
240 240
241 241 _hg_unknown() {
242 242 typeset -a status_files
243 243 _hg_status u
244 244 _wanted files expl 'unknown files' _multi_parts / status_files
245 245 }
246 246
247 247 _hg_missing() {
248 248 typeset -a status_files
249 249 _hg_status d
250 250 _wanted files expl 'missing files' _multi_parts / status_files
251 251 }
252 252
253 253 _hg_modified() {
254 254 typeset -a status_files
255 255 _hg_status m
256 256 _wanted files expl 'modified files' _multi_parts / status_files
257 257 }
258 258
259 259 _hg_resolve() {
260 260 local rstate rpath
261 261
262 262 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
263 263
264 264 _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
265 265 do
266 266 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
267 267 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
268 268 done
269 269 }
270 270
271 271 _hg_resolved() {
272 272 typeset -a resolved_files unresolved_files
273 273 _hg_resolve
274 274 _wanted files expl 'resolved files' _multi_parts / resolved_files
275 275 }
276 276
277 277 _hg_unresolved() {
278 278 typeset -a resolved_files unresolved_files
279 279 _hg_resolve
280 280 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
281 281 }
282 282
283 283 _hg_config() {
284 284 typeset -a items
285 285 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
286 286 (( $#items )) && _describe -t config 'config item' items
287 287 }
288 288
289 289 _hg_addremove() {
290 290 _alternative 'files:unknown files:_hg_unknown' \
291 291 'files:missing files:_hg_missing'
292 292 }
293 293
294 294 _hg_ssh_urls() {
295 295 if [[ -prefix */ ]]
296 296 then
297 297 if zstyle -T ":completion:${curcontext}:files" remote-access
298 298 then
299 299 local host=${PREFIX%%/*}
300 300 typeset -a remdirs
301 301 compset -p $(( $#host + 1 ))
302 302 local rempath=${(M)PREFIX##*/}
303 303 local cacheid="hg:${host}-${rempath//\//_}"
304 304 cacheid=${cacheid%[-_]}
305 305 compset -P '*/'
306 306 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
307 307 then
308 308 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}")"}##*/}%/})
309 309 _store_cache "$cacheid" remdirs
310 310 fi
311 311 _describe -t directories 'remote directory' remdirs -S/
312 312 else
313 313 _message 'remote directory'
314 314 fi
315 315 else
316 316 if compset -P '*@'
317 317 then
318 318 _hosts -S/
319 319 else
320 320 _alternative 'hosts:remote host name:_hosts -S/' \
321 321 'users:user:_users -S@'
322 322 fi
323 323 fi
324 324 }
325 325
326 326 _hg_urls() {
327 327 if compset -P bundle://
328 328 then
329 329 _files
330 330 elif compset -P ssh://
331 331 then
332 332 _hg_ssh_urls
333 333 elif [[ -prefix *: ]]
334 334 then
335 335 _urls
336 336 else
337 337 local expl
338 338 compset -S '[^:]*'
339 339 _wanted url-schemas expl 'URL schema' compadd -S '' - \
340 340 http:// https:// ssh:// bundle://
341 341 fi
342 342 }
343 343
344 344 _hg_paths() {
345 345 typeset -a paths pnames
346 346 _hg_cmd paths | while read -A pnames
347 347 do
348 348 paths+=($pnames[1])
349 349 done
350 350 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
351 351 }
352 352
353 353 _hg_remote() {
354 354 _alternative 'path-aliases:repository alias:_hg_paths' \
355 355 'directories:directory:_files -/' \
356 356 'urls:URL:_hg_urls'
357 357 }
358 358
359 359 _hg_clone_dest() {
360 360 _alternative 'directories:directory:_files -/' \
361 361 'urls:URL:_hg_urls'
362 362 }
363 363
364 364 _hg_add_help_topics=(
365 365 config dates diffs environment extensions filesets glossary hgignore hgweb
366 366 merge-tools multirevs obsolescence patterns phases revisions revsets
367 367 subrepos templating urls
368 368 )
369 369
370 370 _hg_help_topics() {
371 371 local topics
372 372 (( $#_hg_cmd_list )) || _hg_get_commands
373 373 topics=($_hg_cmd_list $_hg_add_help_topics)
374 374 _describe -t help_topics 'help topics' topics
375 375 }
376 376
377 377 # Common options
378 378 _hg_global_opts=(
379 379 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
380 380 '--cwd[change working directory]:new working directory:_files -/'
381 381 '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
382 382 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
383 383 '*--config[set/override config option]:defined config items:_hg_config'
384 384 '(--quiet -q)'{-q,--quiet}'[suppress output]'
385 385 '(--help -h)'{-h,--help}'[display help and exit]'
386 386 '--debug[debug mode]'
387 387 '--debugger[start debugger]'
388 388 '--encoding[set the charset encoding]'
389 389 '--encodingmode[set the charset encoding mode]'
390 390 '--lsprof[print improved command execution profile]'
391 391 '--traceback[print traceback on exception]'
392 392 '--time[time how long the command takes]'
393 393 '--profile[profile]'
394 394 '--version[output version information and exit]'
395 395 )
396 396
397 397 _hg_pat_opts=(
398 398 '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
399 399 '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
400 400
401 401 _hg_clone_opts=(
402 402 $_hg_remote_opts
403 403 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]'
404 404 '--pull[use pull protocol to copy metadata]'
405 405 '--uncompressed[use uncompressed transfer (fast over LAN)]')
406 406
407 407 _hg_date_user_opts=(
408 408 '(--currentdate -D)'{-D,--currentdate}'[record the current date as commit date]'
409 409 '(--currentuser -U)'{-U,--currentuser}'[record the current user as committer]'
410 410 '(--date -d)'{-d+,--date}'[record the specified date as commit date]:date:'
411 411 '(--user -u)'{-u+,--user}'[record the specified user as committer]:user:')
412 412
413 413 _hg_gitlike_opts=(
414 414 '(--git -g)'{-g,--git}'[use git extended diff format]')
415 415
416 416 _hg_diff_opts=(
417 417 $_hg_gitlike_opts
418 418 '(--text -a)'{-a,--text}'[treat all files as text]'
419 419 '--nodates[omit dates from diff headers]')
420 420
421 421 _hg_mergetool_opts=(
422 422 '(--tool -t)'{-t+,--tool}'[specify merge tool]:tool:')
423 423
424 424 _hg_dryrun_opts=(
425 425 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
426 426
427 427 _hg_ignore_space_opts=(
428 428 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]'
429 429 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]'
430 430 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]')
431 431
432 432 _hg_style_opts=(
433 433 '--style[display using template map file]:'
434 434 '--template[display with template]:')
435 435
436 436 _hg_log_opts=(
437 437 $_hg_global_opts $_hg_style_opts $_hg_gitlike_opts
438 438 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:'
439 439 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]'
440 440 '(--patch -p)'{-p,--patch}'[show patch]'
441 441 '--stat[output diffstat-style summary of changes]'
442 442 )
443 443
444 444 _hg_commit_opts=(
445 445 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
446 446 '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use <text> as commit message]:message:'
447 447 '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from <file>]:log file:_files')
448 448
449 449 _hg_remote_opts=(
450 450 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
451 451 '--remotecmd[specify hg command to run on the remote side]:')
452 452
453 453 _hg_branch_bmark_opts=(
454 454 '(--bookmark -B)'{-B+,--bookmark}'[specify bookmark(s)]:bookmark:_hg_bookmarks'
455 455 '(--branch -b)'{-b+,--branch}'[specify branch(es)]:branch:_hg_branches'
456 456 )
457 457
458 458 _hg_subrepos_opts=(
459 459 '(--subrepos -S)'{-S,--subrepos}'[recurse into subrepositories]')
460 460
461 461 _hg_cmd() {
462 462 _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null
463 463 }
464 464
465 465 _hg_cmd_add() {
466 466 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \
467 467 '*:unknown files:_hg_unknown'
468 468 }
469 469
470 470 _hg_cmd_addremove() {
471 471 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
472 472 '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
473 473 '*:unknown or missing files:_hg_addremove'
474 474 }
475 475
476 476 _hg_cmd_annotate() {
477 477 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
478 478 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_labels' \
479 479 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
480 480 '(--text -a)'{-a,--text}'[treat all files as text]' \
481 481 '(--user -u)'{-u,--user}'[list the author]' \
482 482 '(--date -d)'{-d,--date}'[list the date]' \
483 483 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
484 484 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
485 485 '*:files:_hg_files'
486 486 }
487 487
488 488 _hg_cmd_archive() {
489 489 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
490 490 '--no-decode[do not pass files through decoders]' \
491 491 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
492 492 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_labels' \
493 493 '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
494 494 '*:destination:_files'
495 495 }
496 496
497 497 _hg_cmd_backout() {
498 498 _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
499 499 '--merge[merge with old dirstate parent after backout]' \
500 500 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
501 501 '--parent[parent to choose when backing out merge]' \
502 502 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
503 503 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
504 504 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
505 505 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt'
506 506 }
507 507
508 508 _hg_cmd_bisect() {
509 509 _arguments -s -w : $_hg_global_opts \
510 510 '(-)'{-r,--reset}'[reset bisect state]' \
511 511 '(--extend -e)'{-e,--extend}'[extend the bisect range]' \
512 512 '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_labels \
513 513 '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_labels \
514 514 '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
515 515 '(--command -c --noupdate -U)'{-c+,--command}'[use command to check changeset state]':commands:_command_names \
516 516 '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
517 517 }
518 518
519 519 _hg_cmd_bookmarks() {
520 520 _arguments -s -w : $_hg_global_opts \
521 521 '(--force -f)'{-f,--force}'[force]' \
522 522 '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \
523 523 '(--rev -r --delete -d --rename -m)'{-r+,--rev}'[revision]:revision:_hg_labels' \
524 524 '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
525 525 '(--rev -r --delete -d --rename -m)'{-m+,--rename}'[rename a given bookmark]:bookmark:_hg_bookmarks' \
526 526 ':bookmark:_hg_bookmarks'
527 527 }
528 528
529 529 _hg_cmd_branch() {
530 530 _arguments -s -w : $_hg_global_opts \
531 531 '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
532 532 '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
533 533 }
534 534
535 535 _hg_cmd_branches() {
536 536 _arguments -s -w : $_hg_global_opts \
537 537 '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]' \
538 538 '(--closed -c)'{-c,--closed}'[show normal and closed branches]'
539 539 }
540 540
541 541 _hg_cmd_bundle() {
542 542 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
543 543 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
544 544 '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_labels' \
545 545 '(--branch -b)'{-b+,--branch}'[a specific branch to bundle]' \
546 546 '(--rev -r)'{-r+,--rev}'[changeset(s) to bundle]:' \
547 547 '--all[bundle all changesets in the repository]' \
548 548 ':output file:_files' \
549 549 ':destination repository:_files -/'
550 550 }
551 551
552 552 _hg_cmd_cat() {
553 553 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
554 554 '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
555 555 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
556 556 '--decode[apply any matching decode filter]' \
557 557 '*:file:_hg_files'
558 558 }
559 559
560 560 _hg_cmd_clone() {
561 561 _arguments -s -w : $_hg_global_opts $_hg_clone_opts \
562 562 '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
563 563 '(--updaterev -u)'{-u+,--updaterev}'[revision, tag or branch to check out]' \
564 564 '(--branch -b)'{-b+,--branch}'[clone only the specified branch]' \
565 565 ':source repository:_hg_remote' \
566 566 ':destination:_hg_clone_dest'
567 567 }
568 568
569 569 _hg_cmd_commit() {
570 570 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
571 571 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
572 572 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
573 573 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt' \
574 574 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
575 575 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
576 576 '--amend[amend the parent of the working dir]' \
577 577 '--close-branch[mark a branch as closed]' \
578 578 '*:file:_hg_files'
579 579 }
580 580
581 581 _hg_cmd_copy() {
582 582 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
583 583 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
584 584 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
585 585 '*:file:_hg_files'
586 586 }
587 587
588 588 _hg_cmd_diff() {
589 589 typeset -A opt_args
590 590 _arguments -s -w : $_hg_global_opts $_hg_diff_opts $_hg_ignore_space_opts \
591 591 $_hg_pat_opts $_hg_subrepos_opts \
592 592 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
593 593 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
594 594 '(--change -c)'{-c,--change}'[change made by revision]' \
595 595 '(--text -a)'{-a,--text}'[treat all files as text]' \
596 596 '--reverse[produce a diff that undoes the changes]' \
597 597 '(--unified -U)'{-U,--unified}'[number of lines of context to show]' \
598 598 '--stat[output diffstat-style summary of changes]' \
599 599 '*:file:->diff_files'
600 600
601 601 if [[ $state == 'diff_files' ]]
602 602 then
603 603 if [[ -n $opt_args[-r] ]]
604 604 then
605 605 _hg_files
606 606 else
607 607 _hg_modified
608 608 fi
609 609 fi
610 610 }
611 611
612 612 _hg_cmd_export() {
613 613 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
614 614 '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
615 615 '--switch-parent[diff against the second parent]' \
616 616 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
617 617 '*:revision:_hg_labels'
618 618 }
619 619
620 620 _hg_cmd_forget() {
621 621 _arguments -s -w : $_hg_global_opts \
622 622 '*:file:_hg_files'
623 623 }
624 624
625 625 _hg_cmd_graft() {
626 626 _arguments -s -w : $_hg_global_opts $_hg_dryrun_opts \
627 627 $_hg_date_user_opts $_hg_mergetool_opts \
628 628 '(--continue -c)'{-c,--continue}'[resume interrupted graft]' \
629 629 '(--edit -e)'{-e,--edit}'[invoke editor on commit messages]' \
630 630 '--log[append graft info to log message]' \
631 631 '*:revision:_hg_labels'
632 632 }
633 633
634 634 _hg_cmd_grep() {
635 635 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
636 636 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
637 637 '--all[print all revisions with matches]' \
638 638 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
639 639 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
640 640 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
641 641 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
642 642 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
643 643 '(--user -u)'{-u,--user}'[print user who committed change]' \
644 644 '(--date -d)'{-d,--date}'[print date of a changeset]' \
645 645 '1:search pattern:' \
646 646 '*:files:_hg_files'
647 647 }
648 648
649 649 _hg_cmd_heads() {
650 650 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
651 651 '(--topo -t)'{-t,--topo}'[show topological heads only]' \
652 652 '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \
653 653 '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_labels'
654 654 }
655 655
656 656 _hg_cmd_help() {
657 657 _arguments -s -w : $_hg_global_opts \
658 658 '(--extension -e)'{-e,--extension}'[show only help for extensions]' \
659 659 '(--command -c)'{-c,--command}'[show only help for commands]' \
660 660 '(--keyword -k)'{-k+,--keyword}'[show topics matching keyword]' \
661 661 '*:mercurial help topic:_hg_help_topics'
662 662 }
663 663
664 664 _hg_cmd_identify() {
665 665 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
666 666 '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_labels' \
667 667 '(--num -n)'{-n+,--num}'[show local revision number]' \
668 668 '(--id -i)'{-i+,--id}'[show global revision id]' \
669 669 '(--branch -b)'{-b+,--branch}'[show branch]' \
670 670 '(--bookmark -B)'{-B+,--bookmark}'[show bookmarks]' \
671 671 '(--tags -t)'{-t+,--tags}'[show tags]'
672 672 }
673 673
674 674 _hg_cmd_import() {
675 675 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
676 676 '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
677 677 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
678 678 '--bypass[apply patch without touching the working directory]' \
679 679 '--no-commit[do not commit, just update the working directory]' \
680 680 '--exact[apply patch to the nodes from which it was generated]' \
681 681 '--import-branch[use any branch information in patch (implied by --exact)]' \
682 682 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
683 683 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
684 684 '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
685 685 '*:patch:_files'
686 686 }
687 687
688 688 _hg_cmd_incoming() {
689 689 _arguments -s -w : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
690 690 $_hg_subrepos_opts \
691 691 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
692 692 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
693 693 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
694 694 '--bundle[file to store the bundles into]:bundle file:_files' \
695 695 ':source:_hg_remote'
696 696 }
697 697
698 698 _hg_cmd_init() {
699 699 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
700 700 ':dir:_files -/'
701 701 }
702 702
703 703 _hg_cmd_locate() {
704 704 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
705 705 '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_labels' \
706 706 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
707 707 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
708 708 '*:search pattern:_hg_files'
709 709 }
710 710
711 711 _hg_cmd_log() {
712 712 _arguments -s -w : $_hg_log_opts $_hg_pat_opts \
713 713 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
714 714 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
715 715 '(--copies -C)'{-C,--copies}'[show copied files]' \
716 716 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
717 717 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
718 718 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
719 719 '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_labels' \
720 720 '(--graph -G)'{-G+,--graph}'[show the revision DAG]' \
721 721 '(--branch -b)'{-b+,--branch}'[show changesets within the given named branch]:branch:_hg_branches' \
722 722 '(--user -u)'{-u+,--user}'[revisions committed by user]:user:' \
723 723 '(--date -d)'{-d+,--date}'[show revisions matching date spec]:date:' \
724 724 '*:files:_hg_files'
725 725 }
726 726
727 727 _hg_cmd_manifest() {
728 728 _arguments -s -w : $_hg_global_opts \
729 729 '--all[list files from all revisions]' \
730 730 '(--rev -r)'{-r+,--rev}'[revision to display]:revision:_hg_labels' \
731 731 ':revision:_hg_labels'
732 732 }
733 733
734 734 _hg_cmd_merge() {
735 735 _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts \
736 736 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
737 737 '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
738 738 '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
739 739 ':revision:_hg_mergerevs'
740 740 }
741 741
742 742 _hg_cmd_outgoing() {
743 743 _arguments -s -w : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
744 744 $_hg_subrepos_opts \
745 745 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
746 746 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
747 747 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
748 748 ':destination:_hg_remote'
749 749 }
750 750
751 751 _hg_cmd_parents() {
752 752 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
753 753 '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_labels' \
754 754 ':last modified file:_hg_files'
755 755 }
756 756
757 757 _hg_cmd_paths() {
758 758 _arguments -s -w : $_hg_global_opts \
759 759 ':path:_hg_paths'
760 760 }
761 761
762 762 _hg_cmd_phase() {
763 763 _arguments -s -w : $_hg_global_opts \
764 764 '(--public -p)'{-p,--public}'[set changeset phase to public]' \
765 765 '(--draft -d)'{-d,--draft}'[set changeset phase to draft]' \
766 766 '(--secret -s)'{-s,--secret}'[set changeset phase to secret]' \
767 767 '(--force -f)'{-f,--force}'[allow to move boundary backward]' \
768 768 '(--rev -r)'{-r+,--rev}'[target revision]:revision:_hg_labels' \
769 769 ':revision:_hg_labels'
770 770 }
771 771
772 772 _hg_cmd_pull() {
773 773 _arguments -s -w : $_hg_global_opts $_hg_branch_bmark_opts $_hg_remote_opts \
774 774 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
775 775 '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
776 776 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
777 777 ':source:_hg_remote'
778 778 }
779 779
780 780 _hg_cmd_push() {
781 781 _arguments -s -w : $_hg_global_opts $_hg_branch_bmark_opts $_hg_remote_opts \
782 782 '(--force -f)'{-f,--force}'[force push]' \
783 783 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_labels' \
784 784 '--new-branch[allow pushing a new branch]' \
785 785 ':destination:_hg_remote'
786 786 }
787 787
788 788 _hg_cmd_remove() {
789 789 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
790 790 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
791 791 '(--force -f)'{-f,--force}'[remove file even if modified]' \
792 792 '*:file:_hg_files'
793 793 }
794 794
795 795 _hg_cmd_rename() {
796 796 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
797 797 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
798 798 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
799 799 '*:file:_hg_files'
800 800 }
801 801
802 802 _hg_cmd_resolve() {
803 803 local context state line
804 804 typeset -A opt_args
805 805
806 806 _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
807 807 '(--all -a)'{-a,--all}'[select all unresolved files]' \
808 808 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
809 809 '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
810 810 '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
811 811 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
812 812 '*:file:_hg_unresolved'
813 813
814 814 if [[ $state == 'resolve_files' ]]
815 815 then
816 816 _alternative 'files:resolved files:_hg_resolved' \
817 817 'files:unresolved files:_hg_unresolved'
818 818 fi
819 819 }
820 820
821 821 _hg_cmd_revert() {
822 822 local context state line
823 823 typeset -A opt_args
824 824
825 825 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
826 826 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
827 827 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_labels' \
828 828 '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
829 829 '(--date -d)'{-d+,--date}'[tipmost revision matching date]:date code:' \
830 830 '*:file:->diff_files'
831 831
832 832 if [[ $state == 'diff_files' ]]
833 833 then
834 834 if [[ -n $opt_args[-r] ]]
835 835 then
836 836 _hg_files
837 837 else
838 838 typeset -a status_files
839 839 _hg_status mard
840 840 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files
841 841 fi
842 842 fi
843 843 }
844 844
845 845 _hg_cmd_rollback() {
846 846 _arguments -s -w : $_hg_global_opts $_hg_dryrun_opts \
847 847 '(--force -f)'{-f,--force}'[ignore safety measures]' \
848 848 }
849 849
850 850 _hg_cmd_serve() {
851 851 _arguments -s -w : $_hg_global_opts \
852 852 '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
853 853 '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
854 854 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
855 855 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
856 856 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
857 857 '--prefix[prefix path to serve from]:directory:_files' \
858 858 '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
859 859 '--web-conf[name of the hgweb config file]:webconf_file:_files' \
860 860 '--pid-file[name of file to write process ID to]:pid_file:_files' \
861 861 '--cmdserver[cmdserver mode]:mode:' \
862 862 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
863 863 '--style[web template style]:style' \
864 864 '--stdio[for remote clients]' \
865 865 '--certificate[certificate file]:cert_file:_files' \
866 866 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
867 867 }
868 868
869 869 _hg_cmd_showconfig() {
870 870 _arguments -s -w : $_hg_global_opts \
871 871 '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
872 872 ':config item:_hg_config'
873 873 }
874 874
875 875 _hg_cmd_status() {
876 876 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
877 877 '(--all -A)'{-A,--all}'[show status of all files]' \
878 878 '(--modified -m)'{-m,--modified}'[show only modified files]' \
879 879 '(--added -a)'{-a,--added}'[show only added files]' \
880 880 '(--removed -r)'{-r,--removed}'[show only removed files]' \
881 881 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
882 882 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
883 883 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
884 884 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
885 885 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
886 886 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
887 887 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
888 888 '--rev[show difference from revision]:revision:_hg_labels' \
889 889 '--change[list the changed files of a revision]:revision:_hg_labels' \
890 890 '*:files:_files'
891 891 }
892 892
893 893 _hg_cmd_summary() {
894 894 _arguments -s -w : $_hg_global_opts \
895 895 '--remote[check for push and pull]'
896 896 }
897 897
898 898 _hg_cmd_tag() {
899 899 _arguments -s -w : $_hg_global_opts \
900 900 '(--local -l)'{-l,--local}'[make the tag local]' \
901 901 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
902 902 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
903 903 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
904 904 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_labels' \
905 905 '(--force -f)'{-f,--force}'[force tag]' \
906 906 '--remove[remove a tag]' \
907 907 '(--edit -e)'{-e,--edit}'[edit commit message]' \
908 908 ':tag name:'
909 909 }
910 910
911 911 _hg_cmd_tip() {
912 912 _arguments -s -w : $_hg_global_opts $_hg_gitlike_opts $_hg_style_opts \
913 913 '(--patch -p)'{-p,--patch}'[show patch]'
914 914 }
915 915
916 916 _hg_cmd_unbundle() {
917 917 _arguments -s -w : $_hg_global_opts \
918 918 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
919 919 ':files:_files'
920 920 }
921 921
922 922 _hg_cmd_update() {
923 923 _arguments -s -w : $_hg_global_opts \
924 924 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
925 925 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
926 926 '(--check -c)'{-c,--check}'[update across branches if no uncommitted changes]' \
927 927 '(--date -d)'{-d+,--date}'[tipmost revision matching date]' \
928 928 ':revision:_hg_labels'
929 929 }
930 930
931 931 ## extensions ##
932 932
933 933 # HGK
934 934 _hg_cmd_view() {
935 935 _arguments -s -w : $_hg_global_opts \
936 936 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
937 937 ':revision range:_hg_tags'
938 938 }
939 939
940 940 # MQ
941 941 _hg_qseries() {
942 942 typeset -a patches
943 943 patches=(${(f)"$(_hg_cmd qseries)"})
944 944 (( $#patches )) && _describe -t hg-patches 'patches' patches
945 945 }
946 946
947 947 _hg_qapplied() {
948 948 typeset -a patches
949 949 patches=(${(f)"$(_hg_cmd qapplied)"})
950 950 if (( $#patches ))
951 951 then
952 952 patches+=(qbase qtip)
953 953 _describe -t hg-applied-patches 'applied patches' patches
954 954 fi
955 955 }
956 956
957 957 _hg_qunapplied() {
958 958 typeset -a patches
959 959 patches=(${(f)"$(_hg_cmd qunapplied)"})
960 960 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
961 961 }
962 962
963 963 # unapplied, including guarded patches
964 964 _hg_qdeletable() {
965 965 typeset -a unapplied
966 966 unapplied=(${(f)"$(_hg_cmd qseries)"})
967 967 for p in $(_hg_cmd qapplied)
968 968 do
969 969 unapplied=(${unapplied:#$p})
970 970 done
971 971
972 972 (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
973 973 }
974 974
975 975 _hg_qguards() {
976 976 typeset -a guards
977 977 local guard
978 978 compset -P "+|-"
979 979 _hg_cmd qselect -s | while read guard
980 980 do
981 981 guards+=(${guard#(+|-)})
982 982 done
983 983 (( $#guards )) && _describe -t hg-guards 'guards' guards
984 984 }
985 985
986 986 _hg_qseries_opts=(
987 987 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
988 988
989 989 _hg_cmd_qapplied() {
990 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
990 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
991 '(--last -1)'{-1,--last}'[show only the preceding applied patch]' \
992 '*:patch:_hg_qapplied'
993 }
994
995 _hg_cmd_qclone() {
996 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_clone_opts \
997 '(--patches -p)'{-p+,--patches}'[location of source patch repository]' \
998 ':source repository:_hg_remote' \
999 ':destination:_hg_clone_dest'
991 1000 }
992 1001
993 1002 _hg_cmd_qdelete() {
994 1003 _arguments -s -w : $_hg_global_opts \
995 1004 '(--keep -k)'{-k,--keep}'[keep patch file]' \
996 1005 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
997 1006 '*:unapplied patch:_hg_qdeletable'
998 1007 }
999 1008
1000 1009 _hg_cmd_qdiff() {
1001 1010 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
1002 1011 $_hg_ignore_space_opts \
1003 1012 '*:pattern:_hg_files'
1004 1013 }
1005 1014
1006 1015 _hg_cmd_qfinish() {
1007 1016 _arguments -s -w : $_hg_global_opts \
1008 1017 '(--applied -a)'{-a,--applied}'[finish all applied patches]' \
1009 1018 '*:patch:_hg_qapplied'
1010 1019 }
1011 1020
1012 1021 _hg_cmd_qfold() {
1013 1022 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
1014 1023 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
1024 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
1025 '--no-backup[do not save backup copies of files]' \
1015 1026 '*:unapplied patch:_hg_qunapplied'
1016 1027 }
1017 1028
1018 1029 _hg_cmd_qgoto() {
1019 1030 _arguments -s -w : $_hg_global_opts \
1020 1031 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
1032 '--keep-changes[tolerate non-conflicting local changes]' \
1021 1033 ':patch:_hg_qseries'
1022 1034 }
1023 1035
1024 1036 _hg_cmd_qguard() {
1025 1037 _arguments -s -w : $_hg_global_opts \
1026 1038 '(--list -l)'{-l,--list}'[list all patches and guards]' \
1027 1039 '(--none -n)'{-n,--none}'[drop all guards]' \
1028 1040 ':patch:_hg_qseries' \
1029 1041 '*:guards:_hg_qguards'
1030 1042 }
1031 1043
1032 1044 _hg_cmd_qheader() {
1033 1045 _arguments -s -w : $_hg_global_opts \
1034 1046 ':patch:_hg_qseries'
1035 1047 }
1036 1048
1037 1049 _hg_cmd_qimport() {
1038 1050 _arguments -s -w : $_hg_global_opts $_hg_gitlike_opts \
1039 1051 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
1040 1052 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
1041 1053 '(--force -f)'{-f,--force}'[overwrite existing files]' \
1042 1054 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
1055 '(--push -P)'{-P,--push}'[qpush after importing]' \
1043 1056 '*:patch:_files'
1044 1057 }
1045 1058
1046 1059 _hg_cmd_qnew() {
1047 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
1048 $_hg_date_user_opts $_hg_gitlike_opts \
1049 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
1060 _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_date_user_opts $_hg_gitlike_opts \
1050 1061 ':patch:'
1051 1062 }
1052 1063
1053 1064 _hg_cmd_qnext() {
1054 1065 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
1055 1066 }
1056 1067
1057 1068 _hg_cmd_qpop() {
1058 1069 _arguments -s -w : $_hg_global_opts \
1059 1070 '(--all -a :)'{-a,--all}'[pop all patches]' \
1060 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
1061 1071 '(--force -f)'{-f,--force}'[forget any local changes]' \
1072 '--keep-changes[tolerate non-conflicting local changes]' \
1073 '--no-backup[do not save backup copies of files]' \
1062 1074 ':patch:_hg_qapplied'
1063 1075 }
1064 1076
1065 1077 _hg_cmd_qprev() {
1066 1078 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
1067 1079 }
1068 1080
1069 1081 _hg_cmd_qpush() {
1070 1082 _arguments -s -w : $_hg_global_opts \
1071 1083 '(--all -a :)'{-a,--all}'[apply all patches]' \
1072 1084 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
1073 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
1074 '(--name -n)'{-n+,--name}'[merge queue name]:' \
1075 1085 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
1076 1086 '(--exact -e)'{-e,--exact}'[apply the target patch to its recorded parent]' \
1077 1087 '--move[reorder patch series and apply only the patch]' \
1088 '--keep-changes[tolerate non-conflicting local changes]' \
1089 '--no-backup[do not save backup copies of files]' \
1078 1090 ':patch:_hg_qunapplied'
1079 1091 }
1080 1092
1081 1093 _hg_cmd_qrefresh() {
1082 1094 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts $_hg_gitlike_opts \
1083 '(--git -g)'{-g,--git}'[use git extended diff format]' \
1084 1095 '(--short -s)'{-s,--short}'[short refresh]' \
1085 1096 '*:files:_hg_files'
1086 1097 }
1087 1098
1088 1099 _hg_cmd_qrename() {
1089 1100 _arguments -s -w : $_hg_global_opts \
1090 ':patch:_hg_qseries' \
1101 ':patch:_hg_qunapplied' \
1091 1102 ':destination:'
1092 1103 }
1093 1104
1094 1105 _hg_cmd_qselect() {
1095 1106 _arguments -s -w : $_hg_global_opts \
1096 1107 '(--none -n :)'{-n,--none}'[disable all guards]' \
1097 1108 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
1098 1109 '--pop[pop to before first guarded applied patch]' \
1099 1110 '--reapply[pop and reapply patches]' \
1100 1111 '*:guards:_hg_qguards'
1101 1112 }
1102 1113
1103 1114 _hg_cmd_qseries() {
1104 1115 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
1105 1116 '(--missing -m)'{-m,--missing}'[print patches not in series]'
1106 1117 }
1107 1118
1108 1119 _hg_cmd_qunapplied() {
1109 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
1120 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
1121 '(--first -1)'{-1,--first}'[show only the first patch]'
1110 1122 }
1111 1123
1112 1124 _hg_cmd_qtop() {
1113 1125 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
1114 1126 }
1115 1127
1116 1128 _hg_cmd_strip() {
1117 1129 _arguments -s -w : $_hg_global_opts \
1118 '(--force -f)'{-f,--force}'[force multi-head removal]' \
1119 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
1120 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
1130 '(--force -f)'{-f,--force}'[force removal, discard uncommitted changes, no backup]' \
1131 '(--no-backup -n)'{-n,--no-backup}'[no backups]' \
1132 '(--keep -k)'{-k,--keep}'[do not modify working copy during strip]' \
1133 '(--bookmark -B)'{-B+,--bookmark}'[remove revs only reachable from given bookmark]:bookmark:_hg_bookmarks' \
1134 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
1121 1135 ':revision:_hg_labels'
1122 1136 }
1123 1137
1124 1138 # Patchbomb
1125 1139 _hg_cmd_email() {
1126 1140 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_gitlike_opts \
1127 1141 '--plain[omit hg patch header]' \
1128 1142 '--body[send patches as inline message text (default)]' \
1129 1143 '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
1130 1144 '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
1131 1145 '--bundlename[name of the bundle attachment file (default: bundle)]:' \
1132 1146 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
1133 1147 '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
1134 1148 '*--base[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
1135 1149 '--intro[send an introduction email for a single patch]' \
1136 1150 '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
1137 1151 '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
1138 1152 '*--bcc[email addresses of blind carbon copy recipients]:email:' \
1139 1153 '*'{-c+,--cc}'[email addresses of copy recipients]:email:' \
1140 1154 '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
1141 1155 '--date[use the given date as the sending date]:date:' \
1142 1156 '--desc[use the given file as the series description]:files:_files' \
1143 1157 '(--from -f)'{-f,--from}'[email address of sender]:email:' \
1144 1158 '(--test -n)'{-n,--test}'[print messages that would be sent]' \
1145 1159 '(--mbox -m)'{-m,--mbox}'[write messages to mbox file instead of sending them]:file:' \
1146 1160 '*--reply-to[email addresses replies should be sent to]:email:' \
1147 1161 '(--subject -s)'{-s,--subject}'[subject of first message (intro or single patch)]:subject:' \
1148 1162 '--in-reply-to[message identifier to reply to]:msgid:' \
1149 1163 '*--flag[flags to add in subject prefixes]:flag:' \
1150 1164 '*'{-t,--to}'[email addresses of recipients]:email:' \
1151 1165 ':revision:_hg_revrange'
1152 1166 }
1153 1167
1154 1168 # Rebase
1155 1169 _hg_cmd_rebase() {
1156 1170 _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_mergetool_opts \
1157 1171 '*'{-r,--rev}'[rebase these revisions]:revision:_hg_revrange' \
1158 1172 '(--source -s)'{-s,--source}'[rebase from the specified changeset]:revision:_hg_labels' \
1159 1173 '(--base -b)'{-b,--base}'[rebase from the base of the specified changeset]:revision:_hg_labels' \
1160 1174 '(--dest -d)'{-d,--dest}'[rebase onto the specified changeset]' \
1161 1175 '--collapse[collapse the rebased changeset]' \
1162 1176 '--keep[keep original changeset]' \
1163 1177 '--keepbranches[keep original branch name]' \
1164 1178 '(--continue -c)'{-c,--continue}'[continue an interrupted rebase]' \
1165 1179 '(--abort -a)'{-a,--abort}'[abort an interrupted rebase]' \
1166 1180 }
1167 1181
1168 1182 # Record
1169 1183 _hg_cmd_record() {
1170 1184 _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_pat_opts \
1171 1185 $_hg_ignore_space_opts $_hg_subrepos_opts \
1172 1186 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
1173 1187 '--close-branch[mark a branch as closed, hiding it from the branch list]' \
1174 1188 '--amend[amend the parent of the working dir]' \
1175 1189 '(--date -d)'{-d+,--date}'[record the specified date as commit date]:date:' \
1176 1190 '(--user -u)'{-u+,--user}'[record the specified user as committer]:user:'
1177 1191 }
1178 1192
1179 1193 _hg_cmd_qrecord() {
1180 1194 _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_date_user_opts $_hg_gitlike_opts \
1181 1195 $_hg_pat_opts $_hg_ignore_space_opts $_hg_subrepos_opts
1182 1196 }
1183 1197
1184 1198 # Convert
1185 1199 _hg_cmd_convert() {
1186 1200 _arguments -s -w : $_hg_global_opts \
1187 1201 '(--source-type -s)'{-s,--source-type}'[source repository type]' \
1188 1202 '(--dest-type -d)'{-d,--dest-type}'[destination repository type]' \
1189 1203 '(--rev -r)'{-r+,--rev}'[import up to target revision]:revision:' \
1190 1204 '(--authormap -A)'{-A+,--authormap}'[remap usernames using this file]:file:_files' \
1191 1205 '--filemap[remap file names using contents of file]:file:_files' \
1192 1206 '--splicemap[splice synthesized history into place]:file:_files' \
1193 1207 '--branchmap[change branch names while converting]:file:_files' \
1194 1208 '--branchsort[try to sort changesets by branches]' \
1195 1209 '--datesort[try to sort changesets by date]' \
1196 1210 '--sourcesort[preserve source changesets order]'
1197 1211 }
1198 1212
1199 1213 # Graphlog
1200 1214 _hg_cmd_glog() {
1201 1215 _hg_cmd_log $@
1202 1216 }
1203 1217
1204 1218 # Purge
1205 1219 _hg_cmd_purge() {
1206 1220 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
1207 1221 '(--abort-on-err -a)'{-a,--abort-on-err}'[abort if an error occurs]' \
1208 1222 '--all[purge ignored files too]' \
1209 1223 '(--print -p)'{-p,--print}'[print filenames instead of deleting them]' \
1210 1224 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs (implies -p/--print)]'
1211 1225 }
1212 1226
1213 1227 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now