##// END OF EJS Templates
Update zsh completion to use debugcomplete -v instead of parsing help
Brendan Cully -
r7510:21009e85 default
parent child Browse files
Show More
@@ -1,911 +1,875 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 # Copyright (C) 2005-6 Steve Borho
8 8 # Copyright (C) 2006-8 Brendan Cully <brendan@kublai.com>
9 9 #
10 10 # This is free software; you can redistribute it and/or modify it under
11 11 # the terms of the GNU General Public License as published by the Free
12 12 # Software Foundation; either version 2 of the License, or (at your
13 13 # option) any later version.
14 14
15 15 emulate -LR zsh
16 16 setopt extendedglob
17 17
18 18 local curcontext="$curcontext" state line
19 19 typeset -A _hg_cmd_globals
20 20
21 21 _hg() {
22 22 local cmd _hg_root
23 23 integer i=2
24 24 _hg_cmd_globals=()
25 25
26 26 while (( i < $#words ))
27 27 do
28 28 case "$words[$i]" in
29 29 -R|--repository)
30 30 eval _hg_root="$words[$i+1]"
31 31 _hg_cmd_globals+=("$words[$i]" "$_hg_root")
32 32 (( i += 2 ))
33 33 continue
34 34 ;;
35 35 -R*)
36 36 _hg_cmd_globals+="$words[$i]"
37 37 eval _hg_root="${words[$i]#-R}"
38 38 (( i++ ))
39 39 continue
40 40 ;;
41 41 --cwd|--config)
42 42 # pass along arguments to hg completer
43 43 _hg_cmd_globals+=("$words[$i]" "$words[$i+1]")
44 44 (( i += 2 ))
45 45 continue
46 46 ;;
47 47 -*)
48 48 # skip option
49 49 (( i++ ))
50 50 continue
51 51 ;;
52 52 esac
53 53 if [[ -z "$cmd" ]]
54 54 then
55 55 cmd="$words[$i]"
56 56 words[$i]=()
57 57 (( CURRENT-- ))
58 58 fi
59 59 (( i++ ))
60 60 done
61 61
62 62 if [[ -z "$cmd" ]]
63 63 then
64 64 _arguments -s -w : $_hg_global_opts \
65 65 ':mercurial command:_hg_commands'
66 66 return
67 67 fi
68 68
69 69 # resolve abbreviations and aliases
70 70 if ! (( $+functions[_hg_cmd_${cmd}] ))
71 71 then
72 72 local cmdexp
73 73 (( $#_hg_cmd_list )) || _hg_get_commands
74 74
75 75 cmdexp=$_hg_cmd_list[(r)${cmd}*]
76 76 if [[ $cmdexp == $_hg_cmd_list[(R)${cmd}*] ]]
77 77 then
78 78 # might be nice to rewrite the command line with the expansion
79 79 cmd="$cmdexp"
80 80 fi
81 81 if [[ -n $_hg_alias_list[$cmd] ]]
82 82 then
83 83 cmd=$_hg_alias_list[$cmd]
84 84 fi
85 85 fi
86 86
87 87 curcontext="${curcontext%:*:*}:hg-${cmd}:"
88 88
89 89 zstyle -s ":completion:$curcontext:" cache-policy update_policy
90 90
91 91 if [[ -z "$update_policy" ]]
92 92 then
93 93 zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy
94 94 fi
95 95
96 96 if (( $+functions[_hg_cmd_${cmd}] ))
97 97 then
98 98 _hg_cmd_${cmd}
99 99 else
100 100 # complete unknown commands normally
101 101 _arguments -s -w : $_hg_global_opts \
102 102 '*:files:_hg_files'
103 103 fi
104 104 }
105 105
106 106 _hg_cache_policy() {
107 107 typeset -a old
108 108
109 109 # cache for a minute
110 110 old=( "$1"(mm+10) )
111 111 (( $#old )) && return 0
112 112
113 113 return 1
114 114 }
115 115
116 116 _hg_get_commands() {
117 117 typeset -ga _hg_cmd_list
118 118 typeset -gA _hg_alias_list
119 local hline cmd cmdalias helpstate
120 local helpmode=$1
121
122 _call_program help hg --verbose help $helpmode 2>/dev/null | while read -A hline
123 do
124 if [ "$hline" = "list of commands:" ]
125 then
126 helpstate="commands"
127 continue
128 elif [ "$hline" = "enabled extensions:" ]
129 then
130 helpstate="extensions"
131 continue
132 elif [ "$hline" = "additional help topics:" ]
133 then
134 helpstate="topics"
135 continue
136 fi
119 local hline cmd cmdalias
137 120
138 if [ "$helpstate" = commands ]
139 then
140 cmd="$hline[1]"
141 case $cmd in
142 *:)
143 cmd=${cmd%:}
144 _hg_cmd_list+=($cmd)
145 ;;
146 *,)
147 cmd=${cmd%,}
148 _hg_cmd_list+=($cmd)
149 integer i=2
150 while (( i <= $#hline ))
151 do
152 cmdalias=${hline[$i]%(:|,)}
153 _hg_cmd_list+=($cmdalias)
154 _hg_alias_list+=($cmdalias $cmd)
155 (( i++ ))
156 done
157 ;;
158 esac
159 elif [ -z "$helpmode" -a "$helpstate" = extensions ]
160 then
161 cmd="$hline[1]"
162 if [ -n "$cmd" ]
163 then
164 _hg_get_commands $cmd
165 fi
166 fi
121 _call_program hg hg debugcomplete -v 2>/dev/null | while read -A hline
122 do
123 cmd=$hline[1]
124 _hg_cmd_list+=($cmd)
125
126 for cmdalias in $hline[2,-1]
127 do
128 _hg_cmd_list+=($cmdalias)
129 _hg_alias_list+=($cmdalias $cmd)
130 done
167 131 done
168 132 }
169 133
170 134 _hg_commands() {
171 135 (( $#_hg_cmd_list )) || _hg_get_commands
172 136 _describe -t commands 'mercurial command' _hg_cmd_list
173 137 }
174 138
175 139 _hg_revrange() {
176 140 compset -P 1 '*:'
177 141 _hg_tags "$@"
178 142 }
179 143
180 144 _hg_tags() {
181 145 typeset -a tags
182 146 local tag rev
183 147
184 148 _hg_cmd tags 2> /dev/null | while read tag
185 149 do
186 150 tags+=(${tag/ # [0-9]#:*})
187 151 done
188 152 (( $#tags )) && _describe -t tags 'tags' tags
189 153 }
190 154
191 155 _hg_files() {
192 156 if [[ -n "$_hg_root" ]]
193 157 then
194 158 [[ -d "$_hg_root/.hg" ]] || return
195 159 case "$_hg_root" in
196 160 /*)
197 161 _files -W $_hg_root
198 162 ;;
199 163 *)
200 164 _files -W $PWD/$_hg_root
201 165 ;;
202 166 esac
203 167 else
204 168 _files
205 169 fi
206 170 }
207 171
208 172 _hg_status() {
209 173 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
210 174 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX 2>/dev/null)"})
211 175 }
212 176
213 177 _hg_unknown() {
214 178 typeset -a status_files
215 179 _hg_status u
216 180 _wanted files expl 'unknown files' _multi_parts / status_files
217 181 }
218 182
219 183 _hg_missing() {
220 184 typeset -a status_files
221 185 _hg_status d
222 186 _wanted files expl 'missing files' _multi_parts / status_files
223 187 }
224 188
225 189 _hg_modified() {
226 190 typeset -a status_files
227 191 _hg_status m
228 192 _wanted files expl 'modified files' _multi_parts / status_files
229 193 }
230 194
231 195 _hg_resolve() {
232 196 local rstate rpah
233 197
234 198 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
235 199
236 200 _hg_cmd resolve -l ./$PREFIX 2> /dev/null | while read rstate rpath
237 201 do
238 202 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
239 203 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
240 204 done
241 205 }
242 206
243 207 _hg_resolved() {
244 208 typeset -a resolved_files unresolved_files
245 209 _hg_resolve
246 210 _wanted files expl 'resolved files' _multi_parts / resolved_files
247 211 }
248 212
249 213 _hg_unresolved() {
250 214 typeset -a resolved_files unresolved_files
251 215 _hg_resolve
252 216 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
253 217 }
254 218
255 219 _hg_config() {
256 220 typeset -a items
257 221 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
258 222 (( $#items )) && _describe -t config 'config item' items
259 223 }
260 224
261 225 _hg_addremove() {
262 226 _alternative 'files:unknown files:_hg_unknown' \
263 227 'files:missing files:_hg_missing'
264 228 }
265 229
266 230 _hg_ssh_urls() {
267 231 if [[ -prefix */ ]]
268 232 then
269 233 if zstyle -T ":completion:${curcontext}:files" remote-access
270 234 then
271 235 local host=${PREFIX%%/*}
272 236 typeset -a remdirs
273 237 compset -p $(( $#host + 1 ))
274 238 local rempath=${(M)PREFIX##*/}
275 239 local cacheid="hg:${host}-${rempath//\//_}"
276 240 cacheid=${cacheid%[-_]}
277 241 compset -P '*/'
278 242 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
279 243 then
280 244 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/})
281 245 _store_cache "$cacheid" remdirs
282 246 fi
283 247 _describe -t directories 'remote directory' remdirs -S/
284 248 else
285 249 _message 'remote directory'
286 250 fi
287 251 else
288 252 if compset -P '*@'
289 253 then
290 254 _hosts -S/
291 255 else
292 256 _alternative 'hosts:remote host name:_hosts -S/' \
293 257 'users:user:_users -S@'
294 258 fi
295 259 fi
296 260 }
297 261
298 262 _hg_urls() {
299 263 if compset -P bundle://
300 264 then
301 265 _files
302 266 elif compset -P ssh://
303 267 then
304 268 _hg_ssh_urls
305 269 elif [[ -prefix *: ]]
306 270 then
307 271 _urls
308 272 else
309 273 local expl
310 274 compset -S '[^:]*'
311 275 _wanted url-schemas expl 'URL schema' compadd -S '' - \
312 276 http:// https:// ssh:// bundle://
313 277 fi
314 278 }
315 279
316 280 _hg_paths() {
317 281 typeset -a paths pnames
318 282 _hg_cmd paths 2> /dev/null | while read -A pnames
319 283 do
320 284 paths+=($pnames[1])
321 285 done
322 286 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
323 287 }
324 288
325 289 _hg_remote() {
326 290 _alternative 'path-aliases:repository alias:_hg_paths' \
327 291 'directories:directory:_files -/' \
328 292 'urls:URL:_hg_urls'
329 293 }
330 294
331 295 _hg_clone_dest() {
332 296 _alternative 'directories:directory:_files -/' \
333 297 'urls:URL:_hg_urls'
334 298 }
335 299
336 300 # Common options
337 301 _hg_global_opts=(
338 302 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
339 303 '--cwd[change working directory]:new working directory:_files -/'
340 304 '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
341 305 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
342 306 '*--config[set/override config option]:defined config items:_hg_config'
343 307 '(--quiet -q)'{-q,--quiet}'[suppress output]'
344 308 '(--help -h)'{-h,--help}'[display help and exit]'
345 309 '--debug[debug mode]'
346 310 '--debugger[start debugger]'
347 311 '--encoding[set the charset encoding (default: UTF8)]'
348 312 '--encodingmode[set the charset encoding mode (default: strict)]'
349 313 '--lsprof[print improved command execution profile]'
350 314 '--traceback[print traceback on exception]'
351 315 '--time[time how long the command takes]'
352 316 '--profile[profile]'
353 317 '--version[output version information and exit]'
354 318 )
355 319
356 320 _hg_pat_opts=(
357 321 '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
358 322 '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
359 323
360 324 _hg_diff_opts=(
361 325 '(--text -a)'{-a,--text}'[treat all files as text]'
362 326 '(--git -g)'{-g,--git}'[use git extended diff format]'
363 327 "--nodates[don't include dates in diff headers]")
364 328
365 329 _hg_dryrun_opts=(
366 330 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
367 331
368 332 _hg_style_opts=(
369 333 '--style[display using template map file]:'
370 334 '--template[display with template]:')
371 335
372 336 _hg_commit_opts=(
373 337 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
374 338 '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use <text> as commit message]:message:'
375 339 '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from <file>]:log file:_files')
376 340
377 341 _hg_remote_opts=(
378 342 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
379 343 '--remotecmd[specify hg command to run on the remote side]:')
380 344
381 345 _hg_cmd() {
382 346 _call_program hg hg "$_hg_cmd_globals[@]" "$@"
383 347 }
384 348
385 349 _hg_cmd_add() {
386 350 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
387 351 '*:unknown files:_hg_unknown'
388 352 }
389 353
390 354 _hg_cmd_addremove() {
391 355 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
392 356 '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
393 357 '*:unknown or missing files:_hg_addremove'
394 358 }
395 359
396 360 _hg_cmd_annotate() {
397 361 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
398 362 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_tags' \
399 363 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
400 364 '(--text -a)'{-a,--text}'[treat all files as text]' \
401 365 '(--user -u)'{-u,--user}'[list the author]' \
402 366 '(--date -d)'{-d,--date}'[list the date]' \
403 367 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
404 368 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
405 369 '*:files:_hg_files'
406 370 }
407 371
408 372 _hg_cmd_archive() {
409 373 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
410 374 '--no-decode[do not pass files through decoders]' \
411 375 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
412 376 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_tags' \
413 377 '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
414 378 '*:destination:_files'
415 379 }
416 380
417 381 _hg_cmd_backout() {
418 382 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
419 383 '--merge[merge with old dirstate parent after backout]' \
420 384 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
421 385 '--parent[parent to choose when backing out merge]' \
422 386 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
423 387 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
424 388 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
425 389 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt'
426 390 }
427 391
428 392 _hg_cmd_bundle() {
429 393 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
430 394 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
431 395 '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_tags' \
432 396 ':output file:_files' \
433 397 ':destination repository:_files -/'
434 398 }
435 399
436 400 _hg_cmd_cat() {
437 401 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
438 402 '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
439 403 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
440 404 '*:file:_hg_files'
441 405 }
442 406
443 407 _hg_cmd_clone() {
444 408 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
445 409 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
446 410 '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
447 411 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
448 412 ':source repository:_hg_remote' \
449 413 ':destination:_hg_clone_dest'
450 414 }
451 415
452 416 _hg_cmd_commit() {
453 417 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
454 418 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
455 419 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
456 420 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt' \
457 421 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
458 422 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
459 423 '*:file:_hg_files'
460 424 }
461 425
462 426 _hg_cmd_copy() {
463 427 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
464 428 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
465 429 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
466 430 '*:file:_hg_files'
467 431 }
468 432
469 433 _hg_cmd_diff() {
470 434 typeset -A opt_args
471 435 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
472 436 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
473 437 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
474 438 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
475 439 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
476 440 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \
477 441 '*:file:->diff_files'
478 442
479 443 if [[ $state == 'diff_files' ]]
480 444 then
481 445 if [[ -n $opt_args[-r] ]]
482 446 then
483 447 _hg_files
484 448 else
485 449 _hg_modified
486 450 fi
487 451 fi
488 452 }
489 453
490 454 _hg_cmd_export() {
491 455 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
492 456 '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
493 457 '--switch-parent[diff against the second parent]' \
494 458 '*:revision:_hg_tags'
495 459 }
496 460
497 461 _hg_cmd_grep() {
498 462 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
499 463 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
500 464 '--all[print all revisions with matches]' \
501 465 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
502 466 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
503 467 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
504 468 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
505 469 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
506 470 '(--user -u)'{-u,--user}'[print user who committed change]' \
507 471 '1:search pattern:' \
508 472 '*:files:_hg_files'
509 473 }
510 474
511 475 _hg_cmd_heads() {
512 476 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
513 477 '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_tags'
514 478 }
515 479
516 480 _hg_cmd_help() {
517 481 _arguments -s -w : $_hg_global_opts \
518 482 '*:mercurial command:_hg_commands'
519 483 }
520 484
521 485 _hg_cmd_identify() {
522 486 _arguments -s -w : $_hg_global_opts \
523 487 '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_tags' \
524 488 '(--num -n)'{-n+,--num}'[show local revision number]' \
525 489 '(--id -i)'{-i+,--id}'[show global revision id]' \
526 490 '(--branch -b)'{-b+,--branch}'[show branch]' \
527 491 '(--tags -t)'{-t+,--tags}'[show tags]'
528 492 }
529 493
530 494 _hg_cmd_import() {
531 495 _arguments -s -w : $_hg_global_opts \
532 496 '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
533 497 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
534 498 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
535 499 '*:patch:_files'
536 500 }
537 501
538 502 _hg_cmd_incoming() {
539 503 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
540 504 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
541 505 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
542 506 '(--patch -p)'{-p,--patch}'[show patch]' \
543 507 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
544 508 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
545 509 '--bundle[file to store the bundles into]:bundle file:_files' \
546 510 ':source:_hg_remote'
547 511 }
548 512
549 513 _hg_cmd_init() {
550 514 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
551 515 ':dir:_files -/'
552 516 }
553 517
554 518 _hg_cmd_locate() {
555 519 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
556 520 '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_tags' \
557 521 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
558 522 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
559 523 '*:search pattern:_hg_files'
560 524 }
561 525
562 526 _hg_cmd_log() {
563 527 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
564 528 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
565 529 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
566 530 '(--copies -C)'{-C,--copies}'[show copied files]' \
567 531 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
568 532 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
569 533 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
570 534 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
571 535 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
572 536 '(--patch -p)'{-p,--patch}'[show patch]' \
573 537 '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_tags' \
574 538 '*:files:_hg_files'
575 539 }
576 540
577 541 _hg_cmd_manifest() {
578 542 _arguments -s -w : $_hg_global_opts \
579 543 ':revision:_hg_tags'
580 544 }
581 545
582 546 _hg_cmd_outgoing() {
583 547 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
584 548 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
585 549 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
586 550 '(--patch -p)'{-p,--patch}'[show patch]' \
587 551 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
588 552 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
589 553 ':destination:_hg_remote'
590 554 }
591 555
592 556 _hg_cmd_parents() {
593 557 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
594 558 '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_tags' \
595 559 ':last modified file:_hg_files'
596 560 }
597 561
598 562 _hg_cmd_paths() {
599 563 _arguments -s -w : $_hg_global_opts \
600 564 ':path:_hg_paths'
601 565 }
602 566
603 567 _hg_cmd_pull() {
604 568 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
605 569 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
606 570 '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
607 571 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
608 572 ':source:_hg_remote'
609 573 }
610 574
611 575 _hg_cmd_push() {
612 576 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
613 577 '(--force -f)'{-f,--force}'[force push]' \
614 578 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_tags' \
615 579 ':destination:_hg_remote'
616 580 }
617 581
618 582 _hg_cmd_remove() {
619 583 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
620 584 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
621 585 '(--force -f)'{-f,--force}'[remove file even if modified]' \
622 586 '*:file:_hg_files'
623 587 }
624 588
625 589 _hg_cmd_rename() {
626 590 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
627 591 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
628 592 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
629 593 '*:file:_hg_files'
630 594 }
631 595
632 596 _hg_cmd_resolve() {
633 597 local context state line
634 598 typeset -A opt_args
635 599
636 600 _arguments -s -w : $_hg_global_opts \
637 601 '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
638 602 '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
639 603 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
640 604 '*:file:_hg_unresolved'
641 605
642 606 if [[ $state == 'resolve_files' ]]
643 607 then
644 608 _alternative 'files:resolved files:_hg_resolved' \
645 609 'files:unresolved files:_hg_unresolved'
646 610 fi
647 611 }
648 612
649 613 _hg_cmd_revert() {
650 614 local context state line
651 615 typeset -A opt_args
652 616
653 617 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
654 618 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
655 619 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_tags' \
656 620 '--no-backup[do not save backup copies of files]' \
657 621 '*:file:->diff_files'
658 622
659 623 if [[ $state == 'diff_files' ]]
660 624 then
661 625 if [[ -n $opt_args[-r] ]]
662 626 then
663 627 _hg_files
664 628 else
665 629 typeset -a status_files
666 630 _hg_status mard
667 631 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files
668 632 fi
669 633 fi
670 634 }
671 635
672 636 _hg_cmd_serve() {
673 637 _arguments -s -w : $_hg_global_opts \
674 638 '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
675 639 '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
676 640 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
677 641 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
678 642 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
679 643 '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
680 644 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
681 645 '--style[web template style]:style' \
682 646 '--stdio[for remote clients]' \
683 647 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
684 648 }
685 649
686 650 _hg_cmd_showconfig() {
687 651 _arguments -s -w : $_hg_global_opts \
688 652 '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
689 653 ':config item:_hg_config'
690 654 }
691 655
692 656 _hg_cmd_status() {
693 657 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
694 658 '(--all -A)'{-A,--all}'[show status of all files]' \
695 659 '(--modified -m)'{-m,--modified}'[show only modified files]' \
696 660 '(--added -a)'{-a,--added}'[show only added files]' \
697 661 '(--removed -r)'{-r,--removed}'[show only removed files]' \
698 662 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
699 663 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
700 664 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
701 665 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
702 666 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
703 667 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
704 668 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
705 669 '--rev[show difference from revision]:revision:_hg_tags' \
706 670 '*:files:_files'
707 671 }
708 672
709 673 _hg_cmd_tag() {
710 674 _arguments -s -w : $_hg_global_opts \
711 675 '(--local -l)'{-l,--local}'[make the tag local]' \
712 676 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
713 677 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
714 678 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
715 679 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_tags' \
716 680 ':tag name:'
717 681 }
718 682
719 683 _hg_cmd_tip() {
720 684 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
721 685 '(--patch -p)'{-p,--patch}'[show patch]'
722 686 }
723 687
724 688 _hg_cmd_unbundle() {
725 689 _arguments -s -w : $_hg_global_opts \
726 690 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
727 691 ':files:_files'
728 692 }
729 693
730 694 _hg_cmd_update() {
731 695 _arguments -s -w : $_hg_global_opts \
732 696 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
733 697 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
734 698 ':revision:_hg_tags'
735 699 }
736 700
737 701 # bisect extension
738 702 _hg_cmd_bisect() {
739 703 _arguments -s -w : $_hg_global_opts ':evaluation:(help init reset next good bad)'
740 704 }
741 705
742 706 # HGK
743 707 _hg_cmd_view() {
744 708 _arguments -s -w : $_hg_global_opts \
745 709 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
746 710 ':revision range:_hg_tags'
747 711 }
748 712
749 713 # MQ
750 714 _hg_qseries() {
751 715 typeset -a patches
752 716 patches=(${(f)"$(_hg_cmd qseries 2>/dev/null)"})
753 717 (( $#patches )) && _describe -t hg-patches 'patches' patches
754 718 }
755 719
756 720 _hg_qapplied() {
757 721 typeset -a patches
758 722 patches=(${(f)"$(_hg_cmd qapplied 2>/dev/null)"})
759 723 if (( $#patches ))
760 724 then
761 725 patches+=(qbase qtip)
762 726 _describe -t hg-applied-patches 'applied patches' patches
763 727 fi
764 728 }
765 729
766 730 _hg_qunapplied() {
767 731 typeset -a patches
768 732 patches=(${(f)"$(_hg_cmd qunapplied 2>/dev/null)"})
769 733 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
770 734 }
771 735
772 736 _hg_qguards() {
773 737 typeset -a guards
774 738 local guard
775 739 compset -P "+|-"
776 740 _hg_cmd qselect -s 2>/dev/null | while read guard
777 741 do
778 742 guards+=(${guard#(+|-)})
779 743 done
780 744 (( $#guards )) && _describe -t hg-guards 'guards' guards
781 745 }
782 746
783 747 _hg_qseries_opts=(
784 748 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
785 749
786 750 _hg_cmd_qapplied() {
787 751 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
788 752 }
789 753
790 754 _hg_cmd_qdelete() {
791 755 _arguments -s -w : $_hg_global_opts \
792 756 '(--keep -k)'{-k,--keep}'[keep patch file]' \
793 757 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
794 758 '*:unapplied patch:_hg_qunapplied'
795 759 }
796 760
797 761 _hg_cmd_qdiff() {
798 762 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
799 763 '*:pattern:_hg_files'
800 764 }
801 765
802 766 _hg_cmd_qfold() {
803 767 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
804 768 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
805 769 '*:unapplied patch:_hg_qunapplied'
806 770 }
807 771
808 772 _hg_cmd_qgoto() {
809 773 _arguments -s -w : $_hg_global_opts \
810 774 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
811 775 ':patch:_hg_qseries'
812 776 }
813 777
814 778 _hg_cmd_qguard() {
815 779 _arguments -s -w : $_hg_global_opts \
816 780 '(--list -l)'{-l,--list}'[list all patches and guards]' \
817 781 '(--none -n)'{-n,--none}'[drop all guards]' \
818 782 ':patch:_hg_qseries' \
819 783 '*:guards:_hg_qguards'
820 784 }
821 785
822 786 _hg_cmd_qheader() {
823 787 _arguments -s -w : $_hg_global_opts \
824 788 ':patch:_hg_qseries'
825 789 }
826 790
827 791 _hg_cmd_qimport() {
828 792 _arguments -s -w : $_hg_global_opts \
829 793 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
830 794 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
831 795 '(--force -f)'{-f,--force}'[overwrite existing files]' \
832 796 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
833 797 '*:patch:_files'
834 798 }
835 799
836 800 _hg_cmd_qnew() {
837 801 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
838 802 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
839 803 ':patch:'
840 804 }
841 805
842 806 _hg_cmd_qnext() {
843 807 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
844 808 }
845 809
846 810 _hg_cmd_qpop() {
847 811 _arguments -s -w : $_hg_global_opts \
848 812 '(--all -a :)'{-a,--all}'[pop all patches]' \
849 813 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
850 814 '(--force -f)'{-f,--force}'[forget any local changes]' \
851 815 ':patch:_hg_qapplied'
852 816 }
853 817
854 818 _hg_cmd_qprev() {
855 819 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
856 820 }
857 821
858 822 _hg_cmd_qpush() {
859 823 _arguments -s -w : $_hg_global_opts \
860 824 '(--all -a :)'{-a,--all}'[apply all patches]' \
861 825 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
862 826 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
863 827 '(--name -n)'{-n+,--name}'[merge queue name]:' \
864 828 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
865 829 ':patch:_hg_qunapplied'
866 830 }
867 831
868 832 _hg_cmd_qrefresh() {
869 833 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
870 834 '(--git -g)'{-g,--git}'[use git extended diff format]' \
871 835 '(--short -s)'{-s,--short}'[short refresh]' \
872 836 '*:files:_hg_files'
873 837 }
874 838
875 839 _hg_cmd_qrename() {
876 840 _arguments -s -w : $_hg_global_opts \
877 841 ':patch:_hg_qseries' \
878 842 ':destination:'
879 843 }
880 844
881 845 _hg_cmd_qselect() {
882 846 _arguments -s -w : $_hg_global_opts \
883 847 '(--none -n :)'{-n,--none}'[disable all guards]' \
884 848 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
885 849 '--pop[pop to before first guarded applied patch]' \
886 850 '--reapply[pop and reapply patches]' \
887 851 '*:guards:_hg_qguards'
888 852 }
889 853
890 854 _hg_cmd_qseries() {
891 855 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
892 856 '(--missing -m)'{-m,--missing}'[print patches not in series]'
893 857 }
894 858
895 859 _hg_cmd_qunapplied() {
896 860 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
897 861 }
898 862
899 863 _hg_cmd_qtop() {
900 864 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
901 865 }
902 866
903 867 _hg_cmd_strip() {
904 868 _arguments -s -w : $_hg_global_opts \
905 869 '(--force -f)'{-f,--force}'[force multi-head removal]' \
906 870 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
907 871 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
908 872 ':revision:_hg_tags'
909 873 }
910 874
911 875 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now