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