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