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