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