##// END OF EJS Templates
zsh completion: add new option groups for options...
Nikolaj Sjujskij -
r17398:b290d3b1 default
parent child Browse files
Show More
@@ -1,1100 +1,1117
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 _hg_clone_opts=(
402 $_hg_remote_opts
403 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]'
404 '--pull[use pull protocol to copy metadata]'
405 '--uncompressed[use uncompressed transfer (fast over LAN)]')
406
407 _hg_date_user_opts=(
408 '(--currentdate -D)'{-D,--currentdate}'[record the current date as commit date]'
409 '(--currentuser -U)'{-U,--currentuser}'[record the current user as committer]'
410 '(--date -d)'{-d+,--date}'[record the specified date as commit date]:date:'
411 '(--user -u)'{-u+,--user}'[record the specified user as committer]:user:')
412
413 _hg_gitlike_opts=(
414 '(--git -g)'{-g,--git}'[use git extended diff format]')
415
401 416 _hg_diff_opts=(
417 $_hg_gitlike_opts
402 418 '(--text -a)'{-a,--text}'[treat all files as text]'
403 '(--git -g)'{-g,--git}'[use git extended diff format]'
404 "--nodates[omit dates from diff headers]")
419 '--nodates[omit dates from diff headers]')
420
421 _hg_mergetool_opts=(
422 '(--tool -t)'{-t+,--tool}'[specify merge tool]:tool:')
405 423
406 424 _hg_dryrun_opts=(
407 425 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
408 426
427 _hg_ignore_space_opts=(
428 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]'
429 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]'
430 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]')
431
409 432 _hg_style_opts=(
410 433 '--style[display using template map file]:'
411 434 '--template[display with template]:')
412 435
436 _hg_log_opts=(
437 $_hg_global_opts $_hg_style_opts $_hg_gitlike_opts
438 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:'
439 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]'
440 '(--patch -p)'{-p,--patch}'[show patch]'
441 '--stat[output diffstat-style summary of changes]'
442 )
443
413 444 _hg_commit_opts=(
414 445 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
415 446 '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use <text> as commit message]:message:'
416 447 '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from <file>]:log file:_files')
417 448
418 449 _hg_remote_opts=(
419 450 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
420 451 '--remotecmd[specify hg command to run on the remote side]:')
421 452
453 _hg_branch_bmark_opts=(
454 '(--bookmark -B)'{-B+,--bookmark}'[specify bookmark(s)]:bookmark:_hg_bookmarks'
455 '(--branch -b)'{-b+,--branch}'[specify branch(es)]:branch:_hg_branches'
456 )
457
422 458 _hg_cmd() {
423 459 _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null
424 460 }
425 461
426 462 _hg_cmd_add() {
427 463 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
428 464 '*:unknown files:_hg_unknown'
429 465 }
430 466
431 467 _hg_cmd_addremove() {
432 468 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
433 469 '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
434 470 '*:unknown or missing files:_hg_addremove'
435 471 }
436 472
437 473 _hg_cmd_annotate() {
438 474 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
439 475 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_labels' \
440 476 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
441 477 '(--text -a)'{-a,--text}'[treat all files as text]' \
442 478 '(--user -u)'{-u,--user}'[list the author]' \
443 479 '(--date -d)'{-d,--date}'[list the date]' \
444 480 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
445 481 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
446 482 '*:files:_hg_files'
447 483 }
448 484
449 485 _hg_cmd_archive() {
450 486 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
451 487 '--no-decode[do not pass files through decoders]' \
452 488 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
453 489 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_labels' \
454 490 '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
455 491 '*:destination:_files'
456 492 }
457 493
458 494 _hg_cmd_backout() {
459 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
495 _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
460 496 '--merge[merge with old dirstate parent after backout]' \
461 497 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
462 498 '--parent[parent to choose when backing out merge]' \
463 499 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
464 500 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
465 501 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
466 502 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt'
467 503 }
468 504
469 505 _hg_cmd_bisect() {
470 506 _arguments -s -w : $_hg_global_opts \
471 507 '(-)'{-r,--reset}'[reset bisect state]' \
472 508 '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_labels \
473 509 '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_labels \
474 510 '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
475 511 '(--command -c --noupdate -U)'{-c+,--command}'[use command to check changeset state]':commands:_command_names \
476 512 '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
477 513 }
478 514
479 515 _hg_cmd_bookmarks() {
480 516 _arguments -s -w : $_hg_global_opts \
481 517 '(--force -f)'{-f,--force}'[force]' \
482 518 '(--rev -r --delete -d --rename -m)'{-r+,--rev}'[revision]:revision:_hg_labels' \
483 519 '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
484 520 '(--rev -r --delete -d --rename -m)'{-m+,--rename}'[rename a given bookmark]:bookmark:_hg_bookmarks' \
485 521 ':bookmark:_hg_bookmarks'
486 522 }
487 523
488 524 _hg_cmd_branch() {
489 525 _arguments -s -w : $_hg_global_opts \
490 526 '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
491 527 '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
492 528 }
493 529
494 530 _hg_cmd_branches() {
495 531 _arguments -s -w : $_hg_global_opts \
496 532 '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]'
497 533 }
498 534
499 535 _hg_cmd_bundle() {
500 536 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
501 537 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
502 538 '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_labels' \
503 539 ':output file:_files' \
504 540 ':destination repository:_files -/'
505 541 }
506 542
507 543 _hg_cmd_cat() {
508 544 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
509 545 '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
510 546 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
511 547 '*:file:_hg_files'
512 548 }
513 549
514 550 _hg_cmd_clone() {
515 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
551 _arguments -s -w : $_hg_global_opts $_hg_clone_opts \
516 552 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
517 553 '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
518 554 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
519 555 ':source repository:_hg_remote' \
520 556 ':destination:_hg_clone_dest'
521 557 }
522 558
523 559 _hg_cmd_commit() {
524 560 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
525 561 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
526 562 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
527 563 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt' \
528 564 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
529 565 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
530 566 '--amend[amend the parent of the working dir]' \
531 567 '*:file:_hg_files'
532 568 }
533 569
534 570 _hg_cmd_copy() {
535 571 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
536 572 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
537 573 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
538 574 '*:file:_hg_files'
539 575 }
540 576
541 577 _hg_cmd_diff() {
542 578 typeset -A opt_args
543 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
579 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
580 $_hg_diff_opts $_hg_ignore_space_opts \
544 581 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
545 582 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
546 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
547 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
548 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \
549 583 '*:file:->diff_files'
550 584
551 585 if [[ $state == 'diff_files' ]]
552 586 then
553 587 if [[ -n $opt_args[-r] ]]
554 588 then
555 589 _hg_files
556 590 else
557 591 _hg_modified
558 592 fi
559 593 fi
560 594 }
561 595
562 596 _hg_cmd_export() {
563 597 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
564 598 '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
565 599 '--switch-parent[diff against the second parent]' \
566 600 '*:revision:_hg_labels'
567 601 }
568 602
569 603 _hg_cmd_forget() {
570 604 _arguments -s -w : $_hg_global_opts \
571 605 '*:file:_hg_files'
572 606 }
573 607
574 608 _hg_cmd_graft() {
575 _arguments -s -w : $_hg_global_opts \
609 _arguments -s -w : $_hg_global_opts $_hg_dryrun_opts \
610 $_hg_date_user_opts $_hg_mergetool_opts \
576 611 '(--continue -c)'{-c,--continue}'[resume interrupted graft]' \
577 612 '(--edit -e)'{-e,--edit}'[invoke editor on commit messages]' \
578 613 '--log[append graft info to log message]' \
579 '(--currentdate -D)'{-D,--currentdate}'[record the current date as commit date]' \
580 '(--currentuser -U)'{-U,--currentuser}'[record the current user as committer]' \
581 '(--date -d)'{-d,--date}'[record the specified date as commit date]' \
582 '(--user -u)'{-u,--user}'[record the specified user as committer]' \
583 '(--tool -t)'{-t,--tool}'[specify merge tool]' \
584 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]' \
585 614 '*:revision:_hg_labels'
586 615 }
587 616
588 617 _hg_cmd_grep() {
589 618 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
590 619 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
591 620 '--all[print all revisions with matches]' \
592 621 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
593 622 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
594 623 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
595 624 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
596 625 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
597 626 '(--user -u)'{-u,--user}'[print user who committed change]' \
598 627 '1:search pattern:' \
599 628 '*:files:_hg_files'
600 629 }
601 630
602 631 _hg_cmd_heads() {
603 632 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
604 633 '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_labels'
605 634 }
606 635
607 636 _hg_cmd_help() {
608 637 _arguments -s -w : $_hg_global_opts \
609 638 '*:mercurial help topic:_hg_help_topics'
610 639 }
611 640
612 641 _hg_cmd_identify() {
613 _arguments -s -w : $_hg_global_opts \
642 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
614 643 '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_labels' \
615 644 '(--num -n)'{-n+,--num}'[show local revision number]' \
616 645 '(--id -i)'{-i+,--id}'[show global revision id]' \
617 646 '(--branch -b)'{-b+,--branch}'[show branch]' \
618 647 '(--tags -t)'{-t+,--tags}'[show tags]'
619 648 }
620 649
621 650 _hg_cmd_import() {
622 _arguments -s -w : $_hg_global_opts \
651 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
623 652 '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
624 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
625 653 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
626 654 '--bypass[apply patch without touching the working directory]' \
627 655 '*:patch:_files'
628 656 }
629 657
630 658 _hg_cmd_incoming() {
631 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
632 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
659 _arguments -s -w : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
633 660 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
634 '(--patch -p)'{-p,--patch}'[show patch]' \
635 661 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
636 662 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
637 663 '--bundle[file to store the bundles into]:bundle file:_files' \
638 664 ':source:_hg_remote'
639 665 }
640 666
641 667 _hg_cmd_init() {
642 668 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
643 669 ':dir:_files -/'
644 670 }
645 671
646 672 _hg_cmd_locate() {
647 673 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
648 674 '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_labels' \
649 675 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
650 676 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
651 677 '*:search pattern:_hg_files'
652 678 }
653 679
654 680 _hg_cmd_log() {
655 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
681 _arguments -s -w : $_hg_log_opts $_hg_pat_opts \
656 682 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
657 683 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
658 684 '(--copies -C)'{-C,--copies}'[show copied files]' \
659 685 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
660 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
661 686 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
662 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
663 687 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
664 '(--patch -p)'{-p,--patch}'[show patch]' \
665 688 '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_labels' \
666 689 '(--branch -b)'{-b+,--branch}'[show changesets within the given named branch]:branch:_hg_branches' \
667 690 '*:files:_hg_files'
668 691 }
669 692
670 693 _hg_cmd_manifest() {
671 694 _arguments -s -w : $_hg_global_opts \
672 695 '--all[list files from all revisions]' \
673 696 ':revision:_hg_labels'
674 697 }
675 698
676 699 _hg_cmd_merge() {
677 _arguments -s -w : $_hg_global_opts \
700 _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts \
678 701 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
679 702 '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
680 703 '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
681 '(--tool -t)'{-t,--tool}'[specify merge tool]' \
682 704 ':revision:_hg_mergerevs'
683 705 }
684 706
685 707 _hg_cmd_outgoing() {
686 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
687 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
708 _arguments -s -w : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
688 709 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
689 '(--patch -p)'{-p,--patch}'[show patch]' \
690 710 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
691 711 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
692 712 ':destination:_hg_remote'
693 713 }
694 714
695 715 _hg_cmd_parents() {
696 716 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
697 717 '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_labels' \
698 718 ':last modified file:_hg_files'
699 719 }
700 720
701 721 _hg_cmd_paths() {
702 722 _arguments -s -w : $_hg_global_opts \
703 723 ':path:_hg_paths'
704 724 }
705 725
706 726 _hg_cmd_phase() {
707 727 _arguments -s -w : $_hg_global_opts \
708 728 '(--public -p)'{-p,--public}'[set changeset phase to public]' \
709 729 '(--draft -d)'{-d,--draft}'[set changeset phase to draft]' \
710 730 '(--secret -s)'{-s,--secret}'[set changeset phase to secret]' \
711 731 '(--force -f)'{-f,--force}'[allow to move boundary backward]' \
712 732 '(--rev -r)'{-r+,--rev}'[target revision]:revision:_hg_labels' \
713 733 ':revision:_hg_labels'
714 734 }
715 735
716 736 _hg_cmd_pull() {
717 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
737 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_branch_bmark_opts \
718 738 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
719 739 '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
720 740 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
721 741 ':source:_hg_remote'
722 742 }
723 743
724 744 _hg_cmd_push() {
725 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
745 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_branch_bmark_opts \
726 746 '(--force -f)'{-f,--force}'[force push]' \
727 747 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_labels' \
728 748 ':destination:_hg_remote'
729 749 }
730 750
731 751 _hg_cmd_remove() {
732 752 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
733 753 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
734 754 '(--force -f)'{-f,--force}'[remove file even if modified]' \
735 755 '*:file:_hg_files'
736 756 }
737 757
738 758 _hg_cmd_rename() {
739 759 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
740 760 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
741 761 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
742 762 '*:file:_hg_files'
743 763 }
744 764
745 765 _hg_cmd_resolve() {
746 766 local context state line
747 767 typeset -A opt_args
748 768
749 _arguments -s -w : $_hg_global_opts \
769 _arguments -s -w : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
750 770 '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
751 771 '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
752 772 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
753 773 '*:file:_hg_unresolved'
754 774
755 775 if [[ $state == 'resolve_files' ]]
756 776 then
757 777 _alternative 'files:resolved files:_hg_resolved' \
758 778 'files:unresolved files:_hg_unresolved'
759 779 fi
760 780 }
761 781
762 782 _hg_cmd_revert() {
763 783 local context state line
764 784 typeset -A opt_args
765 785
766 786 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
767 787 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
768 788 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_labels' \
769 789 '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
770 790 '*:file:->diff_files'
771 791
772 792 if [[ $state == 'diff_files' ]]
773 793 then
774 794 if [[ -n $opt_args[-r] ]]
775 795 then
776 796 _hg_files
777 797 else
778 798 typeset -a status_files
779 799 _hg_status mard
780 800 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files
781 801 fi
782 802 fi
783 803 }
784 804
785 805 _hg_cmd_rollback() {
786 806 _arguments -s -w : $_hg_global_opts $_hg_dryrun_opts \
787 807 '(--force -f)'{-f,--force}'[ignore safety measures]' \
788 808 }
789 809
790 810 _hg_cmd_serve() {
791 811 _arguments -s -w : $_hg_global_opts \
792 812 '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
793 813 '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
794 814 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
795 815 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
796 816 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
797 817 '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
798 818 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
799 819 '--style[web template style]:style' \
800 820 '--stdio[for remote clients]' \
801 821 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
802 822 }
803 823
804 824 _hg_cmd_showconfig() {
805 825 _arguments -s -w : $_hg_global_opts \
806 826 '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
807 827 ':config item:_hg_config'
808 828 }
809 829
810 830 _hg_cmd_status() {
811 831 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
812 832 '(--all -A)'{-A,--all}'[show status of all files]' \
813 833 '(--modified -m)'{-m,--modified}'[show only modified files]' \
814 834 '(--added -a)'{-a,--added}'[show only added files]' \
815 835 '(--removed -r)'{-r,--removed}'[show only removed files]' \
816 836 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
817 837 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
818 838 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
819 839 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
820 840 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
821 841 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
822 842 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
823 843 '--rev[show difference from revision]:revision:_hg_labels' \
824 844 '*:files:_files'
825 845 }
826 846
827 847 _hg_cmd_summary() {
828 848 _arguments -s -w : $_hg_global_opts \
829 849 '--remote[check for push and pull]'
830 850 }
831 851
832 852 _hg_cmd_tag() {
833 853 _arguments -s -w : $_hg_global_opts \
834 854 '(--local -l)'{-l,--local}'[make the tag local]' \
835 855 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
836 856 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
837 857 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
838 858 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_labels' \
839 859 ':tag name:'
840 860 }
841 861
842 862 _hg_cmd_tip() {
843 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
863 _arguments -s -w : $_hg_global_opts $_hg_gitlike_opts $_hg_style_opts \
844 864 '(--patch -p)'{-p,--patch}'[show patch]'
845 865 }
846 866
847 867 _hg_cmd_unbundle() {
848 868 _arguments -s -w : $_hg_global_opts \
849 869 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
850 870 ':files:_files'
851 871 }
852 872
853 873 _hg_cmd_update() {
854 874 _arguments -s -w : $_hg_global_opts \
855 875 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
856 876 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
857 877 ':revision:_hg_labels'
858 878 }
859 879
860 880 ## extensions ##
861 881
862 882 # HGK
863 883 _hg_cmd_view() {
864 884 _arguments -s -w : $_hg_global_opts \
865 885 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
866 886 ':revision range:_hg_tags'
867 887 }
868 888
869 889 # MQ
870 890 _hg_qseries() {
871 891 typeset -a patches
872 892 patches=(${(f)"$(_hg_cmd qseries)"})
873 893 (( $#patches )) && _describe -t hg-patches 'patches' patches
874 894 }
875 895
876 896 _hg_qapplied() {
877 897 typeset -a patches
878 898 patches=(${(f)"$(_hg_cmd qapplied)"})
879 899 if (( $#patches ))
880 900 then
881 901 patches+=(qbase qtip)
882 902 _describe -t hg-applied-patches 'applied patches' patches
883 903 fi
884 904 }
885 905
886 906 _hg_qunapplied() {
887 907 typeset -a patches
888 908 patches=(${(f)"$(_hg_cmd qunapplied)"})
889 909 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
890 910 }
891 911
892 912 # unapplied, including guarded patches
893 913 _hg_qdeletable() {
894 914 typeset -a unapplied
895 915 unapplied=(${(f)"$(_hg_cmd qseries)"})
896 916 for p in $(_hg_cmd qapplied)
897 917 do
898 918 unapplied=(${unapplied:#$p})
899 919 done
900 920
901 921 (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
902 922 }
903 923
904 924 _hg_qguards() {
905 925 typeset -a guards
906 926 local guard
907 927 compset -P "+|-"
908 928 _hg_cmd qselect -s | while read guard
909 929 do
910 930 guards+=(${guard#(+|-)})
911 931 done
912 932 (( $#guards )) && _describe -t hg-guards 'guards' guards
913 933 }
914 934
915 935 _hg_qseries_opts=(
916 936 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
917 937
918 938 _hg_cmd_qapplied() {
919 939 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
920 940 }
921 941
922 942 _hg_cmd_qdelete() {
923 943 _arguments -s -w : $_hg_global_opts \
924 944 '(--keep -k)'{-k,--keep}'[keep patch file]' \
925 945 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
926 946 '*:unapplied patch:_hg_qdeletable'
927 947 }
928 948
929 949 _hg_cmd_qdiff() {
930 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
950 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
951 $_hg_ignore_space_opts \
931 952 '*:pattern:_hg_files'
932 953 }
933 954
934 955 _hg_cmd_qfinish() {
935 956 _arguments -s -w : $_hg_global_opts \
936 957 '(--applied -a)'{-a,--applied}'[finish all applied patches]' \
937 958 '*:patch:_hg_qapplied'
938 959 }
939 960
940 961 _hg_cmd_qfold() {
941 962 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
942 963 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
943 964 '*:unapplied patch:_hg_qunapplied'
944 965 }
945 966
946 967 _hg_cmd_qgoto() {
947 968 _arguments -s -w : $_hg_global_opts \
948 969 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
949 970 ':patch:_hg_qseries'
950 971 }
951 972
952 973 _hg_cmd_qguard() {
953 974 _arguments -s -w : $_hg_global_opts \
954 975 '(--list -l)'{-l,--list}'[list all patches and guards]' \
955 976 '(--none -n)'{-n,--none}'[drop all guards]' \
956 977 ':patch:_hg_qseries' \
957 978 '*:guards:_hg_qguards'
958 979 }
959 980
960 981 _hg_cmd_qheader() {
961 982 _arguments -s -w : $_hg_global_opts \
962 983 ':patch:_hg_qseries'
963 984 }
964 985
965 986 _hg_cmd_qimport() {
966 _arguments -s -w : $_hg_global_opts \
987 _arguments -s -w : $_hg_global_opts $_hg_gitlike_opts \
967 988 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
968 989 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
969 990 '(--force -f)'{-f,--force}'[overwrite existing files]' \
970 991 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
971 992 '*:patch:_files'
972 993 }
973 994
974 995 _hg_cmd_qnew() {
975 996 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
997 $_hg_date_user_opts $_hg_gitlike_opts \
976 998 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
977 999 ':patch:'
978 1000 }
979 1001
980 1002 _hg_cmd_qnext() {
981 1003 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
982 1004 }
983 1005
984 1006 _hg_cmd_qpop() {
985 1007 _arguments -s -w : $_hg_global_opts \
986 1008 '(--all -a :)'{-a,--all}'[pop all patches]' \
987 1009 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
988 1010 '(--force -f)'{-f,--force}'[forget any local changes]' \
989 1011 ':patch:_hg_qapplied'
990 1012 }
991 1013
992 1014 _hg_cmd_qprev() {
993 1015 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
994 1016 }
995 1017
996 1018 _hg_cmd_qpush() {
997 1019 _arguments -s -w : $_hg_global_opts \
998 1020 '(--all -a :)'{-a,--all}'[apply all patches]' \
999 1021 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
1000 1022 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
1001 1023 '(--name -n)'{-n+,--name}'[merge queue name]:' \
1002 1024 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
1003 1025 '(--exact -e)'{-e,--exact}'[apply the target patch to its recorded parent]' \
1004 1026 '--move[reorder patch series and apply only the patch]' \
1005 1027 ':patch:_hg_qunapplied'
1006 1028 }
1007 1029
1008 1030 _hg_cmd_qrefresh() {
1009 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
1031 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts $_hg_gitlike_opts \
1010 1032 '(--git -g)'{-g,--git}'[use git extended diff format]' \
1011 1033 '(--short -s)'{-s,--short}'[short refresh]' \
1012 1034 '*:files:_hg_files'
1013 1035 }
1014 1036
1015 1037 _hg_cmd_qrename() {
1016 1038 _arguments -s -w : $_hg_global_opts \
1017 1039 ':patch:_hg_qseries' \
1018 1040 ':destination:'
1019 1041 }
1020 1042
1021 1043 _hg_cmd_qselect() {
1022 1044 _arguments -s -w : $_hg_global_opts \
1023 1045 '(--none -n :)'{-n,--none}'[disable all guards]' \
1024 1046 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
1025 1047 '--pop[pop to before first guarded applied patch]' \
1026 1048 '--reapply[pop and reapply patches]' \
1027 1049 '*:guards:_hg_qguards'
1028 1050 }
1029 1051
1030 1052 _hg_cmd_qseries() {
1031 1053 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
1032 1054 '(--missing -m)'{-m,--missing}'[print patches not in series]'
1033 1055 }
1034 1056
1035 1057 _hg_cmd_qunapplied() {
1036 1058 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
1037 1059 }
1038 1060
1039 1061 _hg_cmd_qtop() {
1040 1062 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
1041 1063 }
1042 1064
1043 1065 _hg_cmd_strip() {
1044 1066 _arguments -s -w : $_hg_global_opts \
1045 1067 '(--force -f)'{-f,--force}'[force multi-head removal]' \
1046 1068 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
1047 1069 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
1048 1070 ':revision:_hg_labels'
1049 1071 }
1050 1072
1051 1073 # Patchbomb
1052 1074 _hg_cmd_email() {
1053 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
1054 '(--git -g)'{-g,--git}'[use git extended diff format]' \
1075 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_gitlike_opts \
1055 1076 '--plain[omit hg patch header]' \
1056 1077 '--body[send patches as inline message text (default)]' \
1057 1078 '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
1058 1079 '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
1059 1080 '--bundlename[name of the bundle attachment file (default: bundle)]:' \
1060 1081 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
1061 1082 '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
1062 1083 '*--base[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
1063 1084 '--intro[send an introduction email for a single patch]' \
1064 1085 '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
1065 1086 '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
1066 1087 '*--bcc[email addresses of blind carbon copy recipients]:email:' \
1067 1088 '*'{-c+,--cc}'[email addresses of copy recipients]:email:' \
1068 1089 '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
1069 1090 '--date[use the given date as the sending date]:date:' \
1070 1091 '--desc[use the given file as the series description]:files:_files' \
1071 1092 '(--from -f)'{-f,--from}'[email address of sender]:email:' \
1072 1093 '(--test -n)'{-n,--test}'[print messages that would be sent]' \
1073 1094 '(--mbox -m)'{-m,--mbox}'[write messages to mbox file instead of sending them]:file:' \
1074 1095 '*--reply-to[email addresses replies should be sent to]:email:' \
1075 1096 '(--subject -s)'{-s,--subject}'[subject of first message (intro or single patch)]:subject:' \
1076 1097 '--in-reply-to[message identifier to reply to]:msgid:' \
1077 1098 '*--flag[flags to add in subject prefixes]:flag:' \
1078 1099 '*'{-t,--to}'[email addresses of recipients]:email:' \
1079 1100 ':revision:_hg_revrange'
1080 1101 }
1081 1102
1082 1103 # Rebase
1083 1104 _hg_cmd_rebase() {
1084 _arguments -s -w : $_hg_global_opts \
1105 _arguments -s -w : $_hg_global_opts $_hg_commit_opts $_hg_mergetool_opts \
1085 1106 '*'{-r,--rev}'[rebase these revisions]:revision:_hg_revrange' \
1086 1107 '(--source -s)'{-s,--source}'[rebase from the specified changeset]:revision:_hg_labels' \
1087 1108 '(--base -b)'{-b,--base}'[rebase from the base of the specified changeset]:revision:_hg_labels' \
1088 1109 '(--dest -d)'{-d,--dest}'[rebase onto the specified changeset]' \
1089 1110 '--collapse[collapse the rebased changeset]' \
1090 '(--message -m)'{-m+,--message}'[use <text> as collapse commit message]:text:' \
1091 '(--edit -e)'{-e,--edit}'[invoke editor on commit messages]' \
1092 '(--logfile -l)'{-l+,--logfile}'[read collapse commit message from <file>]:log file:_files -g \*.txt' \
1093 1111 '--keep[keep original changeset]' \
1094 1112 '--keepbranches[keep original branch name]' \
1095 '(--tool -t)'{-t,--tool}'[specify merge tool]' \
1096 1113 '(--continue -c)'{-c,--continue}'[continue an interrupted rebase]' \
1097 1114 '(--abort -a)'{-a,--abort}'[abort an interrupted rebase]' \
1098 1115 }
1099 1116
1100 1117 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now