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