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