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