##// END OF EJS Templates
zsh: fix completions with relative paths...
Steve Borho -
r3817:45a751d7 default
parent child Browse files
Show More
@@ -1,788 +1,788 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 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 . 2>/dev/null)"})
181 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX 2>/dev/null)"})
182 182 }
183 183
184 184 _hg_unknown() {
185 185 typeset -a status_files
186 186 _hg_status u
187 187 _wanted files expl 'unknown files' _multi_parts / status_files
188 188 }
189 189
190 190 _hg_missing() {
191 191 typeset -a status_files
192 192 _hg_status d
193 193 _wanted files expl 'missing files' _multi_parts / status_files
194 194 }
195 195
196 196 _hg_modified() {
197 197 typeset -a status_files
198 198 _hg_status m
199 199 _wanted files expl 'modified files' _multi_parts / status_files
200 200 }
201 201
202 202 _hg_addremove() {
203 203 _alternative 'files:unknown files:_hg_unknown' \
204 204 'files:missing files:_hg_missing'
205 205 }
206 206
207 207 _hg_ssh_urls() {
208 208 if [[ -prefix */ ]]
209 209 then
210 210 if zstyle -T ":completion:${curcontext}:files" remote-access
211 211 then
212 212 local host=${PREFIX%%/*}
213 213 typeset -a remdirs
214 214 compset -p $(( $#host + 1 ))
215 215 local rempath=${(M)PREFIX##*/}
216 216 local cacheid="hg:${host}-${rempath//\//_}"
217 217 cacheid=${cacheid%[-_]}
218 218 compset -P '*/'
219 219 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
220 220 then
221 221 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}" 2> /dev/null)"}##*/}%/})
222 222 _store_cache "$cacheid" remdirs
223 223 fi
224 224 _describe -t directories 'remote directory' remdirs -S/
225 225 else
226 226 _message 'remote directory'
227 227 fi
228 228 else
229 229 if compset -P '*@'
230 230 then
231 231 _hosts -S/
232 232 else
233 233 _alternative 'hosts:remote host name:_hosts -S/' \
234 234 'users:user:_users -S@'
235 235 fi
236 236 fi
237 237 }
238 238
239 239 _hg_urls() {
240 240 if compset -P bundle://
241 241 then
242 242 _files
243 243 elif compset -P ssh://
244 244 then
245 245 _hg_ssh_urls
246 246 elif [[ -prefix *: ]]
247 247 then
248 248 _urls
249 249 else
250 250 local expl
251 251 compset -S '[^:]*'
252 252 _wanted url-schemas expl 'URL schema' compadd -S '' - \
253 253 http:// https:// ssh:// bundle://
254 254 fi
255 255 }
256 256
257 257 _hg_paths() {
258 258 typeset -a paths pnames
259 259 _hg_cmd paths 2> /dev/null | while read -A pnames
260 260 do
261 261 paths+=($pnames[1])
262 262 done
263 263 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
264 264 }
265 265
266 266 _hg_remote() {
267 267 _alternative 'path-aliases:repository alias:_hg_paths' \
268 268 'directories:directory:_files -/' \
269 269 'urls:URL:_hg_urls'
270 270 }
271 271
272 272 _hg_clone_dest() {
273 273 _alternative 'directories:directory:_files -/' \
274 274 'urls:URL:_hg_urls'
275 275 }
276 276
277 277 # Common options
278 278 _hg_global_opts=(
279 279 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
280 280 '--cwd[change working directory]:new working directory:_files -/'
281 281 '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
282 282 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
283 283 '(--quiet -q)'{-q,--quiet}'[suppress output]'
284 284 '(--help -h)'{-h,--help}'[display help and exit]'
285 285 '--debug[debug mode]'
286 286 '--debugger[start debugger]'
287 287 '--traceback[print traceback on exception]'
288 288 '--time[time how long the command takes]'
289 289 '--profile[profile]'
290 290 '--version[output version information and exit]'
291 291 )
292 292
293 293 _hg_pat_opts=(
294 294 '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
295 295 '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
296 296
297 297 _hg_diff_opts=(
298 298 '(--text -a)'{-a,--text}'[treat all files as text]'
299 299 '(--git -g)'{-g,--git}'[use git extended diff format]'
300 300 "--nodates[don't include dates in diff headers]")
301 301
302 302 _hg_dryrun_opts=(
303 303 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
304 304
305 305 _hg_style_opts=(
306 306 '--style[display using template map file]:'
307 307 '--template[display with template]:')
308 308
309 309 _hg_commit_opts=(
310 310 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
311 311 '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use <text> as commit message]:message:'
312 312 '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from <file>]:log file:_files')
313 313
314 314 _hg_remote_opts=(
315 315 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
316 316 '--remotecmd[specify hg command to run on the remote side]:')
317 317
318 318 _hg_cmd() {
319 319 _call_program hg hg "$_hg_cmd_globals[@]" "$@"
320 320 }
321 321
322 322 _hg_cmd_add() {
323 323 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
324 324 '*:unknown files:_hg_unknown'
325 325 }
326 326
327 327 _hg_cmd_addremove() {
328 328 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
329 329 '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
330 330 '*:unknown or missing files:_hg_addremove'
331 331 }
332 332
333 333 _hg_cmd_annotate() {
334 334 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
335 335 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_tags' \
336 336 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
337 337 '(--text -a)'{-a,--text}'[treat all files as text]' \
338 338 '(--user -u)'{-u,--user}'[list the author]' \
339 339 '(--date -d)'{-d,--date}'[list the date]' \
340 340 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
341 341 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
342 342 '*:files:_hg_files'
343 343 }
344 344
345 345 _hg_cmd_archive() {
346 346 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
347 347 '--no-decode[do not pass files through decoders]' \
348 348 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
349 349 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_tags' \
350 350 '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
351 351 '*:destination:_files'
352 352 }
353 353
354 354 _hg_cmd_bundle() {
355 355 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
356 356 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
357 357 '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_tags' \
358 358 ':output file:_files' \
359 359 ':destination repository:_files -/'
360 360 }
361 361
362 362 _hg_cmd_cat() {
363 363 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
364 364 '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
365 365 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
366 366 '*:file:_hg_files'
367 367 }
368 368
369 369 _hg_cmd_clone() {
370 370 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
371 371 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
372 372 '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
373 373 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
374 374 ':source repository:_hg_remote' \
375 375 ':destination:_hg_clone_dest'
376 376 }
377 377
378 378 _hg_cmd_commit() {
379 379 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
380 380 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
381 381 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
382 382 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_file -g \*.txt' \
383 383 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
384 384 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
385 385 '*:file:_hg_files'
386 386 }
387 387
388 388 _hg_cmd_copy() {
389 389 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
390 390 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
391 391 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
392 392 '*:file:_hg_files'
393 393 }
394 394
395 395 _hg_cmd_diff() {
396 396 typeset -A opt_args
397 397 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
398 398 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
399 399 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
400 400 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
401 401 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
402 402 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \
403 403 '*:file:->diff_files'
404 404
405 405 if [[ $state == 'diff_files' ]]
406 406 then
407 407 if [[ -n $opt_args[-r] ]]
408 408 then
409 409 _hg_files
410 410 else
411 411 _hg_modified
412 412 fi
413 413 fi
414 414 }
415 415
416 416 _hg_cmd_export() {
417 417 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
418 418 '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
419 419 '--switch-parent[diff against the second parent]' \
420 420 '*:revision:_hg_tags'
421 421 }
422 422
423 423 _hg_cmd_grep() {
424 424 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
425 425 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
426 426 '--all[print all revisions with matches]' \
427 427 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
428 428 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
429 429 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
430 430 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
431 431 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
432 432 '(--user -u)'{-u,--user}'[print user who committed change]' \
433 433 '*:search pattern:_hg_files'
434 434 }
435 435
436 436 _hg_cmd_heads() {
437 437 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
438 438 '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_tags'
439 439 }
440 440
441 441 _hg_cmd_help() {
442 442 _arguments -s -w : $_hg_global_opts \
443 443 '*:mercurial command:_hg_commands'
444 444 }
445 445
446 446 _hg_cmd_import() {
447 447 _arguments -s -w : $_hg_global_opts \
448 448 '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
449 449 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
450 450 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
451 451 '*:patch:_files'
452 452 }
453 453
454 454 _hg_cmd_incoming() {
455 455 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
456 456 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
457 457 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
458 458 '(--patch -p)'{-p,--patch}'[show patch]' \
459 459 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]' \
460 460 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
461 461 '--bundle[file to store the bundles into]:bundle file:_files' \
462 462 ':source:_hg_remote'
463 463 }
464 464
465 465 _hg_cmd_init() {
466 466 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
467 467 ':dir:_files -/'
468 468 }
469 469
470 470 _hg_cmd_locate() {
471 471 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
472 472 '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_tags' \
473 473 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
474 474 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
475 475 '*:search pattern:_hg_files'
476 476 }
477 477
478 478 _hg_cmd_log() {
479 479 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
480 480 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
481 481 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
482 482 '(--copies -C)'{-C,--copies}'[show copied files]' \
483 483 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
484 484 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
485 485 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
486 486 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
487 487 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
488 488 '(--patch -p)'{-p,--patch}'[show patch]' \
489 489 '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_tags' \
490 490 '*:files:_hg_files'
491 491 }
492 492
493 493 _hg_cmd_manifest() {
494 494 _arguments -s -w : $_hg_global_opts \
495 495 ':revision:_hg_tags'
496 496 }
497 497
498 498 _hg_cmd_outgoing() {
499 499 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
500 500 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
501 501 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
502 502 '(--patch -p)'{-p,--patch}'[show patch]' \
503 503 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
504 504 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
505 505 ':destination:_hg_remote'
506 506 }
507 507
508 508 _hg_cmd_parents() {
509 509 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
510 510 '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_tags' \
511 511 ':revision:_hg_tags'
512 512 }
513 513
514 514 _hg_cmd_paths() {
515 515 _arguments -s -w : $_hg_global_opts \
516 516 ':path:_hg_paths'
517 517 }
518 518
519 519 _hg_cmd_pull() {
520 520 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
521 521 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
522 522 '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
523 523 ':source:_hg_remote'
524 524 }
525 525
526 526 _hg_cmd_push() {
527 527 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
528 528 '(--force -f)'{-f,--force}'[force push]' \
529 529 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
530 530 ':destination:_hg_remote'
531 531 }
532 532
533 533 _hg_cmd_remove() {
534 534 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
535 535 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
536 536 '(--force -f)'{-f,--force}'[remove file even if modified]' \
537 537 '*:file:_hg_files'
538 538 }
539 539
540 540 _hg_cmd_rename() {
541 541 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
542 542 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
543 543 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
544 544 '*:file:_hg_files'
545 545 }
546 546
547 547 _hg_cmd_revert() {
548 548 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
549 549 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
550 550 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_tags' \
551 551 '--no-backup[do not save backup copies of files]' \
552 552 '*:file:->diff_files'
553 553
554 554 if [[ $state == 'diff_files' ]]
555 555 then
556 556 if [[ -n $opt_args[-r] ]]
557 557 then
558 558 _hg_files
559 559 else
560 560 typeset -a status_files
561 561 _hg_status mard
562 562 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files
563 563 fi
564 564 fi
565 565 }
566 566
567 567 _hg_cmd_serve() {
568 568 _arguments -s -w : $_hg_global_opts \
569 569 '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
570 570 '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
571 571 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
572 572 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
573 573 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
574 574 '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
575 575 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
576 576 '--style[web template style]:style' \
577 577 '--stdio[for remote clients]' \
578 578 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
579 579 }
580 580
581 581 _hg_cmd_status() {
582 582 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
583 583 '(--all -A)'{-A,--all}'[show status of all files]' \
584 584 '(--modified -m)'{-m,--modified}'[show only modified files]' \
585 585 '(--added -a)'{-a,--added}'[show only added files]' \
586 586 '(--removed -r)'{-r,--removed}'[show only removed files]' \
587 587 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
588 588 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
589 589 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
590 590 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
591 591 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
592 592 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
593 593 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
594 594 '--rev[show difference from revision]:revision:_hg_tags' \
595 595 '*:files:_files'
596 596 }
597 597
598 598 _hg_cmd_tag() {
599 599 _arguments -s -w : $_hg_global_opts \
600 600 '(--local -l)'{-l,--local}'[make the tag local]' \
601 601 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
602 602 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
603 603 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
604 604 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_tags' \
605 605 ':tag name:'
606 606 }
607 607
608 608 _hg_cmd_tip() {
609 609 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
610 610 '(--patch -p)'{-p,--patch}'[show patch]'
611 611 }
612 612
613 613 _hg_cmd_unbundle() {
614 614 _arguments -s -w : $_hg_global_opts \
615 615 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
616 616 ':files:_files'
617 617 }
618 618
619 619 _hg_cmd_update() {
620 620 _arguments -s -w : $_hg_global_opts \
621 621 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
622 622 ':revision:_hg_tags'
623 623 }
624 624
625 625 # HGK
626 626 _hg_cmd_view() {
627 627 _arguments -s -w : $_hg_global_opts \
628 628 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
629 629 ':revision range:_hg_tags'
630 630 }
631 631
632 632 # MQ
633 633 _hg_qseries() {
634 634 typeset -a patches
635 635 patches=($(_hg_cmd qseries 2>/dev/null))
636 636 (( $#patches )) && _describe -t hg-patches 'patches' patches
637 637 }
638 638
639 639 _hg_qapplied() {
640 640 typeset -a patches
641 641 patches=($(_hg_cmd qapplied 2>/dev/null))
642 642 if (( $#patches ))
643 643 then
644 644 patches+=(qbase qtip)
645 645 _describe -t hg-applied-patches 'applied patches' patches
646 646 fi
647 647 }
648 648
649 649 _hg_qunapplied() {
650 650 typeset -a patches
651 651 patches=($(_hg_cmd qunapplied 2>/dev/null))
652 652 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
653 653 }
654 654
655 655 _hg_qguards() {
656 656 typeset -a guards
657 657 local guard
658 658 compset -P "+|-"
659 659 _hg_cmd qselect -s 2>/dev/null | while read guard
660 660 do
661 661 guards+=(${guard#(+|-)})
662 662 done
663 663 (( $#guards )) && _describe -t hg-guards 'guards' guards
664 664 }
665 665
666 666 _hg_qseries_opts=(
667 667 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
668 668
669 669 _hg_cmd_qapplied() {
670 670 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
671 671 }
672 672
673 673 _hg_cmd_qdelete() {
674 674 _arguments -s -w : $_hg_global_opts \
675 675 '(--keep -k)'{-k,--keep}'[keep patch file]' \
676 676 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
677 677 '*:unapplied patch:_hg_qunapplied'
678 678 }
679 679
680 680 _hg_cmd_qdiff() {
681 681 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
682 682 '*:pattern:_hg_files'
683 683 }
684 684
685 685 _hg_cmd_qfold() {
686 686 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
687 687 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
688 688 '*:unapplied patch:_hg_qunapplied'
689 689 }
690 690
691 691 _hg_cmd_qguard() {
692 692 _arguments -s -w : $_hg_global_opts \
693 693 '(--list -l)'{-l,--list}'[list all patches and guards]' \
694 694 '(--none -n)'{-n,--none}'[drop all guards]' \
695 695 ':patch:_hg_qseries' \
696 696 '*:guards:_hg_qguards'
697 697 }
698 698
699 699 _hg_cmd_qheader() {
700 700 _arguments -s -w : $_hg_global_opts \
701 701 ':patch:_hg_qseries'
702 702 }
703 703
704 704 _hg_cmd_qimport() {
705 705 _arguments -s -w : $_hg_global_opts \
706 706 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
707 707 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
708 708 '(--force -f)'{-f,--force}'[overwrite existing files]' \
709 709 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
710 710 '*:patch:_files'
711 711 }
712 712
713 713 _hg_cmd_qnew() {
714 714 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
715 715 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
716 716 ':patch:'
717 717 }
718 718
719 719 _hg_cmd_qnext() {
720 720 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
721 721 }
722 722
723 723 _hg_cmd_qpop() {
724 724 _arguments -s -w : $_hg_global_opts \
725 725 '(--all -a :)'{-a,--all}'[pop all patches]' \
726 726 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
727 727 '(--force -f)'{-f,--force}'[forget any local changes]' \
728 728 ':patch:_hg_qapplied'
729 729 }
730 730
731 731 _hg_cmd_qprev() {
732 732 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
733 733 }
734 734
735 735 _hg_cmd_qpush() {
736 736 _arguments -s -w : $_hg_global_opts \
737 737 '(--all -a :)'{-a,--all}'[apply all patches]' \
738 738 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
739 739 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
740 740 '(--name -n)'{-n+,--name}'[merge queue name]:' \
741 741 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
742 742 ':patch:_hg_qunapplied'
743 743 }
744 744
745 745 _hg_cmd_qrefresh() {
746 746 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
747 747 '(--git -g)'{-g,--git}'[use git extended diff format]' \
748 748 '(--short -s)'{-s,--short}'[short refresh]' \
749 749 '*:files:_hg_files'
750 750 }
751 751
752 752 _hg_cmd_qrename() {
753 753 _arguments -s -w : $_hg_global_opts \
754 754 ':patch:_hg_qseries' \
755 755 ':destination:'
756 756 }
757 757
758 758 _hg_cmd_qselect() {
759 759 _arguments -s -w : $_hg_global_opts \
760 760 '(--none -n :)'{-n,--none}'[disable all guards]' \
761 761 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
762 762 '--pop[pop to before first guarded applied patch]' \
763 763 '--reapply[pop and reapply patches]' \
764 764 '*:guards:_hg_qguards'
765 765 }
766 766
767 767 _hg_cmd_qseries() {
768 768 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
769 769 '(--missing -m)'{-m,--missing}'[print patches not in series]'
770 770 }
771 771
772 772 _hg_cmd_qunapplied() {
773 773 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
774 774 }
775 775
776 776 _hg_cmd_qtop() {
777 777 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
778 778 }
779 779
780 780 _hg_cmd_strip() {
781 781 _arguments -s -w : $_hg_global_opts \
782 782 '(--force -f)'{-f,--force}'[force multi-head removal]' \
783 783 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
784 784 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
785 785 ':revision:_hg_tags'
786 786 }
787 787
788 788 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now