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