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