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