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