##// END OF EJS Templates
contrib: some support for named branches in zsh_completion (issue2988)...
Ben Hockey -
r15100:a051f8a6 default
parent child Browse files
Show More
@@ -1,1010 +1,1023 b''
1 #compdef hg
1 #compdef hg
2
2
3 # Zsh completion script for mercurial. Rename this file to _hg and copy
3 # Zsh completion script for mercurial. Rename this file to _hg and copy
4 # it into your zsh function path (/usr/share/zsh/site-functions for
4 # it into your zsh function path (/usr/share/zsh/site-functions for
5 # instance)
5 # instance)
6 #
6 #
7 # If you do not want to install it globally, you can copy it somewhere
7 # If you do not want to install it globally, you can copy it somewhere
8 # else and add that directory to $fpath. This must be done before
8 # else and add that directory to $fpath. This must be done before
9 # compinit is called. If the file is copied to ~/.zsh.d, your ~/.zshrc
9 # compinit is called. If the file is copied to ~/.zsh.d, your ~/.zshrc
10 # file could look like this:
10 # file could look like this:
11 #
11 #
12 # fpath=("$HOME/.zsh.d" $fpath)
12 # fpath=("$HOME/.zsh.d" $fpath)
13 # autoload -U compinit
13 # autoload -U compinit
14 # compinit
14 # compinit
15 #
15 #
16 # Copyright (C) 2005, 2006 Steve Borho <steve@borho.org>
16 # Copyright (C) 2005, 2006 Steve Borho <steve@borho.org>
17 # Copyright (C) 2006-10 Brendan Cully <brendan@kublai.com>
17 # Copyright (C) 2006-10 Brendan Cully <brendan@kublai.com>
18 #
18 #
19 # Permission is hereby granted, without written agreement and without
19 # Permission is hereby granted, without written agreement and without
20 # licence or royalty fees, to use, copy, modify, and distribute this
20 # licence or royalty fees, to use, copy, modify, and distribute this
21 # software and to distribute modified versions of this software for any
21 # software and to distribute modified versions of this software for any
22 # purpose, provided that the above copyright notice and the following
22 # purpose, provided that the above copyright notice and the following
23 # two paragraphs appear in all copies of this software.
23 # two paragraphs appear in all copies of this software.
24 #
24 #
25 # In no event shall the authors be liable to any party for direct,
25 # In no event shall the authors be liable to any party for direct,
26 # indirect, special, incidental, or consequential damages arising out of
26 # indirect, special, incidental, or consequential damages arising out of
27 # the use of this software and its documentation, even if the authors
27 # the use of this software and its documentation, even if the authors
28 # have been advised of the possibility of such damage.
28 # have been advised of the possibility of such damage.
29 #
29 #
30 # The authors specifically disclaim any warranties, including, but not
30 # The authors specifically disclaim any warranties, including, but not
31 # limited to, the implied warranties of merchantability and fitness for
31 # limited to, the implied warranties of merchantability and fitness for
32 # a particular purpose. The software provided hereunder is on an "as
32 # a particular purpose. The software provided hereunder is on an "as
33 # is" basis, and the authors have no obligation to provide maintenance,
33 # is" basis, and the authors have no obligation to provide maintenance,
34 # support, updates, enhancements, or modifications.
34 # support, updates, enhancements, or modifications.
35
35
36 emulate -LR zsh
36 emulate -LR zsh
37 setopt extendedglob
37 setopt extendedglob
38
38
39 local curcontext="$curcontext" state line
39 local curcontext="$curcontext" state line
40 typeset -A _hg_cmd_globals
40 typeset -A _hg_cmd_globals
41
41
42 _hg() {
42 _hg() {
43 local cmd _hg_root
43 local cmd _hg_root
44 integer i=2
44 integer i=2
45 _hg_cmd_globals=()
45 _hg_cmd_globals=()
46
46
47 while (( i < $#words ))
47 while (( i < $#words ))
48 do
48 do
49 case "$words[$i]" in
49 case "$words[$i]" in
50 -R|--repository)
50 -R|--repository)
51 eval _hg_root="$words[$i+1]"
51 eval _hg_root="$words[$i+1]"
52 _hg_cmd_globals+=("$words[$i]" "$_hg_root")
52 _hg_cmd_globals+=("$words[$i]" "$_hg_root")
53 (( i += 2 ))
53 (( i += 2 ))
54 continue
54 continue
55 ;;
55 ;;
56 -R*)
56 -R*)
57 _hg_cmd_globals+="$words[$i]"
57 _hg_cmd_globals+="$words[$i]"
58 eval _hg_root="${words[$i]#-R}"
58 eval _hg_root="${words[$i]#-R}"
59 (( i++ ))
59 (( i++ ))
60 continue
60 continue
61 ;;
61 ;;
62 --cwd|--config)
62 --cwd|--config)
63 # pass along arguments to hg completer
63 # pass along arguments to hg completer
64 _hg_cmd_globals+=("$words[$i]" "$words[$i+1]")
64 _hg_cmd_globals+=("$words[$i]" "$words[$i+1]")
65 (( i += 2 ))
65 (( i += 2 ))
66 continue
66 continue
67 ;;
67 ;;
68 -*)
68 -*)
69 # skip option
69 # skip option
70 (( i++ ))
70 (( i++ ))
71 continue
71 continue
72 ;;
72 ;;
73 esac
73 esac
74 if [[ -z "$cmd" ]]
74 if [[ -z "$cmd" ]]
75 then
75 then
76 cmd="$words[$i]"
76 cmd="$words[$i]"
77 words[$i]=()
77 words[$i]=()
78 (( CURRENT-- ))
78 (( CURRENT-- ))
79 fi
79 fi
80 (( i++ ))
80 (( i++ ))
81 done
81 done
82
82
83 if [[ -z "$cmd" ]]
83 if [[ -z "$cmd" ]]
84 then
84 then
85 _arguments -s -w : $_hg_global_opts \
85 _arguments -s -w : $_hg_global_opts \
86 ':mercurial command:_hg_commands'
86 ':mercurial command:_hg_commands'
87 return
87 return
88 fi
88 fi
89
89
90 # resolve abbreviations and aliases
90 # resolve abbreviations and aliases
91 if ! (( $+functions[_hg_cmd_${cmd}] ))
91 if ! (( $+functions[_hg_cmd_${cmd}] ))
92 then
92 then
93 local cmdexp
93 local cmdexp
94 (( $#_hg_cmd_list )) || _hg_get_commands
94 (( $#_hg_cmd_list )) || _hg_get_commands
95
95
96 cmdexp=$_hg_cmd_list[(r)${cmd}*]
96 cmdexp=$_hg_cmd_list[(r)${cmd}*]
97 if [[ $cmdexp == $_hg_cmd_list[(R)${cmd}*] ]]
97 if [[ $cmdexp == $_hg_cmd_list[(R)${cmd}*] ]]
98 then
98 then
99 # might be nice to rewrite the command line with the expansion
99 # might be nice to rewrite the command line with the expansion
100 cmd="$cmdexp"
100 cmd="$cmdexp"
101 fi
101 fi
102 if [[ -n $_hg_alias_list[$cmd] ]]
102 if [[ -n $_hg_alias_list[$cmd] ]]
103 then
103 then
104 cmd=$_hg_alias_list[$cmd]
104 cmd=$_hg_alias_list[$cmd]
105 fi
105 fi
106 fi
106 fi
107
107
108 curcontext="${curcontext%:*:*}:hg-${cmd}:"
108 curcontext="${curcontext%:*:*}:hg-${cmd}:"
109
109
110 zstyle -s ":completion:$curcontext:" cache-policy update_policy
110 zstyle -s ":completion:$curcontext:" cache-policy update_policy
111
111
112 if [[ -z "$update_policy" ]]
112 if [[ -z "$update_policy" ]]
113 then
113 then
114 zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy
114 zstyle ":completion:$curcontext:" cache-policy _hg_cache_policy
115 fi
115 fi
116
116
117 if (( $+functions[_hg_cmd_${cmd}] ))
117 if (( $+functions[_hg_cmd_${cmd}] ))
118 then
118 then
119 _hg_cmd_${cmd}
119 _hg_cmd_${cmd}
120 else
120 else
121 # complete unknown commands normally
121 # complete unknown commands normally
122 _arguments -s -w : $_hg_global_opts \
122 _arguments -s -w : $_hg_global_opts \
123 '*:files:_hg_files'
123 '*:files:_hg_files'
124 fi
124 fi
125 }
125 }
126
126
127 _hg_cache_policy() {
127 _hg_cache_policy() {
128 typeset -a old
128 typeset -a old
129
129
130 # cache for a minute
130 # cache for a minute
131 old=( "$1"(mm+10) )
131 old=( "$1"(mm+10) )
132 (( $#old )) && return 0
132 (( $#old )) && return 0
133
133
134 return 1
134 return 1
135 }
135 }
136
136
137 _hg_get_commands() {
137 _hg_get_commands() {
138 typeset -ga _hg_cmd_list
138 typeset -ga _hg_cmd_list
139 typeset -gA _hg_alias_list
139 typeset -gA _hg_alias_list
140 local hline cmd cmdalias
140 local hline cmd cmdalias
141
141
142 _call_program hg hg debugcomplete -v | while read -A hline
142 _call_program hg hg debugcomplete -v | while read -A hline
143 do
143 do
144 cmd=$hline[1]
144 cmd=$hline[1]
145 _hg_cmd_list+=($cmd)
145 _hg_cmd_list+=($cmd)
146
146
147 for cmdalias in $hline[2,-1]
147 for cmdalias in $hline[2,-1]
148 do
148 do
149 _hg_cmd_list+=($cmdalias)
149 _hg_cmd_list+=($cmdalias)
150 _hg_alias_list+=($cmdalias $cmd)
150 _hg_alias_list+=($cmdalias $cmd)
151 done
151 done
152 done
152 done
153 }
153 }
154
154
155 _hg_commands() {
155 _hg_commands() {
156 (( $#_hg_cmd_list )) || _hg_get_commands
156 (( $#_hg_cmd_list )) || _hg_get_commands
157 _describe -t commands 'mercurial command' _hg_cmd_list
157 _describe -t commands 'mercurial command' _hg_cmd_list
158 }
158 }
159
159
160 _hg_revrange() {
160 _hg_revrange() {
161 compset -P 1 '*:'
161 compset -P 1 '*:'
162 _hg_labels "$@"
162 _hg_labels "$@"
163 }
163 }
164
164
165 _hg_labels() {
165 _hg_labels() {
166 _hg_tags "$@"
166 _hg_tags "$@"
167 _hg_bookmarks "$@"
167 _hg_bookmarks "$@"
168 _hg_branches "$@"
168 }
169 }
169
170
170 _hg_tags() {
171 _hg_tags() {
171 typeset -a tags
172 typeset -a tags
172 local tag rev
173 local tag rev
173
174
174 _hg_cmd tags | while read tag
175 _hg_cmd tags | while read tag
175 do
176 do
176 tags+=(${tag/ # [0-9]#:*})
177 tags+=(${tag/ # [0-9]#:*})
177 done
178 done
178 (( $#tags )) && _describe -t tags 'tags' tags
179 (( $#tags )) && _describe -t tags 'tags' tags
179 }
180 }
180
181
181 _hg_bookmarks() {
182 _hg_bookmarks() {
182 typeset -a bookmark bookmarks
183 typeset -a bookmark bookmarks
183
184
184 _hg_cmd bookmarks | while read -A bookmark
185 _hg_cmd bookmarks | while read -A bookmark
185 do
186 do
186 if test -z ${bookmark[-1]:#[0-9]*}
187 if test -z ${bookmark[-1]:#[0-9]*}
187 then
188 then
188 bookmarks+=($bookmark[-2])
189 bookmarks+=($bookmark[-2])
189 fi
190 fi
190 done
191 done
191 (( $#bookmarks )) && _describe -t bookmarks 'bookmarks' bookmarks
192 (( $#bookmarks )) && _describe -t bookmarks 'bookmarks' bookmarks
192 }
193 }
193
194
195 _hg_branches() {
196 typeset -a branches
197 local branch
198
199 _hg_cmd branches | while read branch
200 do
201 branches+=(${branch/ # [0-9]#:*})
202 done
203 (( $#branches )) && _describe -t branches 'branches' branches
204 }
205
194 # likely merge candidates
206 # likely merge candidates
195 _hg_mergerevs() {
207 _hg_mergerevs() {
196 typeset -a heads
208 typeset -a heads
197 local myrev
209 local myrev
198
210
199 heads=(${(f)"$(_hg_cmd heads --template '{rev}\\n')"})
211 heads=(${(f)"$(_hg_cmd heads --template '{rev}\\n')"})
200 # exclude own revision
212 # exclude own revision
201 myrev=$(_hg_cmd log -r . --template '{rev}\\n')
213 myrev=$(_hg_cmd log -r . --template '{rev}\\n')
202 heads=(${heads:#$myrev})
214 heads=(${heads:#$myrev})
203
215
204 (( $#heads )) && _describe -t heads 'heads' heads
216 (( $#heads )) && _describe -t heads 'heads' heads
205 }
217 }
206
218
207 _hg_files() {
219 _hg_files() {
208 if [[ -n "$_hg_root" ]]
220 if [[ -n "$_hg_root" ]]
209 then
221 then
210 [[ -d "$_hg_root/.hg" ]] || return
222 [[ -d "$_hg_root/.hg" ]] || return
211 case "$_hg_root" in
223 case "$_hg_root" in
212 /*)
224 /*)
213 _files -W $_hg_root
225 _files -W $_hg_root
214 ;;
226 ;;
215 *)
227 *)
216 _files -W $PWD/$_hg_root
228 _files -W $PWD/$_hg_root
217 ;;
229 ;;
218 esac
230 esac
219 else
231 else
220 _files
232 _files
221 fi
233 fi
222 }
234 }
223
235
224 _hg_status() {
236 _hg_status() {
225 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
237 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
226 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
238 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
227 }
239 }
228
240
229 _hg_unknown() {
241 _hg_unknown() {
230 typeset -a status_files
242 typeset -a status_files
231 _hg_status u
243 _hg_status u
232 _wanted files expl 'unknown files' _multi_parts / status_files
244 _wanted files expl 'unknown files' _multi_parts / status_files
233 }
245 }
234
246
235 _hg_missing() {
247 _hg_missing() {
236 typeset -a status_files
248 typeset -a status_files
237 _hg_status d
249 _hg_status d
238 _wanted files expl 'missing files' _multi_parts / status_files
250 _wanted files expl 'missing files' _multi_parts / status_files
239 }
251 }
240
252
241 _hg_modified() {
253 _hg_modified() {
242 typeset -a status_files
254 typeset -a status_files
243 _hg_status m
255 _hg_status m
244 _wanted files expl 'modified files' _multi_parts / status_files
256 _wanted files expl 'modified files' _multi_parts / status_files
245 }
257 }
246
258
247 _hg_resolve() {
259 _hg_resolve() {
248 local rstate rpath
260 local rstate rpath
249
261
250 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
262 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
251
263
252 _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
264 _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
253 do
265 do
254 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
266 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
255 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
267 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
256 done
268 done
257 }
269 }
258
270
259 _hg_resolved() {
271 _hg_resolved() {
260 typeset -a resolved_files unresolved_files
272 typeset -a resolved_files unresolved_files
261 _hg_resolve
273 _hg_resolve
262 _wanted files expl 'resolved files' _multi_parts / resolved_files
274 _wanted files expl 'resolved files' _multi_parts / resolved_files
263 }
275 }
264
276
265 _hg_unresolved() {
277 _hg_unresolved() {
266 typeset -a resolved_files unresolved_files
278 typeset -a resolved_files unresolved_files
267 _hg_resolve
279 _hg_resolve
268 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
280 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
269 }
281 }
270
282
271 _hg_config() {
283 _hg_config() {
272 typeset -a items
284 typeset -a items
273 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
285 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
274 (( $#items )) && _describe -t config 'config item' items
286 (( $#items )) && _describe -t config 'config item' items
275 }
287 }
276
288
277 _hg_addremove() {
289 _hg_addremove() {
278 _alternative 'files:unknown files:_hg_unknown' \
290 _alternative 'files:unknown files:_hg_unknown' \
279 'files:missing files:_hg_missing'
291 'files:missing files:_hg_missing'
280 }
292 }
281
293
282 _hg_ssh_urls() {
294 _hg_ssh_urls() {
283 if [[ -prefix */ ]]
295 if [[ -prefix */ ]]
284 then
296 then
285 if zstyle -T ":completion:${curcontext}:files" remote-access
297 if zstyle -T ":completion:${curcontext}:files" remote-access
286 then
298 then
287 local host=${PREFIX%%/*}
299 local host=${PREFIX%%/*}
288 typeset -a remdirs
300 typeset -a remdirs
289 compset -p $(( $#host + 1 ))
301 compset -p $(( $#host + 1 ))
290 local rempath=${(M)PREFIX##*/}
302 local rempath=${(M)PREFIX##*/}
291 local cacheid="hg:${host}-${rempath//\//_}"
303 local cacheid="hg:${host}-${rempath//\//_}"
292 cacheid=${cacheid%[-_]}
304 cacheid=${cacheid%[-_]}
293 compset -P '*/'
305 compset -P '*/'
294 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
306 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
295 then
307 then
296 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}")"}##*/}%/})
308 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}")"}##*/}%/})
297 _store_cache "$cacheid" remdirs
309 _store_cache "$cacheid" remdirs
298 fi
310 fi
299 _describe -t directories 'remote directory' remdirs -S/
311 _describe -t directories 'remote directory' remdirs -S/
300 else
312 else
301 _message 'remote directory'
313 _message 'remote directory'
302 fi
314 fi
303 else
315 else
304 if compset -P '*@'
316 if compset -P '*@'
305 then
317 then
306 _hosts -S/
318 _hosts -S/
307 else
319 else
308 _alternative 'hosts:remote host name:_hosts -S/' \
320 _alternative 'hosts:remote host name:_hosts -S/' \
309 'users:user:_users -S@'
321 'users:user:_users -S@'
310 fi
322 fi
311 fi
323 fi
312 }
324 }
313
325
314 _hg_urls() {
326 _hg_urls() {
315 if compset -P bundle://
327 if compset -P bundle://
316 then
328 then
317 _files
329 _files
318 elif compset -P ssh://
330 elif compset -P ssh://
319 then
331 then
320 _hg_ssh_urls
332 _hg_ssh_urls
321 elif [[ -prefix *: ]]
333 elif [[ -prefix *: ]]
322 then
334 then
323 _urls
335 _urls
324 else
336 else
325 local expl
337 local expl
326 compset -S '[^:]*'
338 compset -S '[^:]*'
327 _wanted url-schemas expl 'URL schema' compadd -S '' - \
339 _wanted url-schemas expl 'URL schema' compadd -S '' - \
328 http:// https:// ssh:// bundle://
340 http:// https:// ssh:// bundle://
329 fi
341 fi
330 }
342 }
331
343
332 _hg_paths() {
344 _hg_paths() {
333 typeset -a paths pnames
345 typeset -a paths pnames
334 _hg_cmd paths | while read -A pnames
346 _hg_cmd paths | while read -A pnames
335 do
347 do
336 paths+=($pnames[1])
348 paths+=($pnames[1])
337 done
349 done
338 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
350 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
339 }
351 }
340
352
341 _hg_remote() {
353 _hg_remote() {
342 _alternative 'path-aliases:repository alias:_hg_paths' \
354 _alternative 'path-aliases:repository alias:_hg_paths' \
343 'directories:directory:_files -/' \
355 'directories:directory:_files -/' \
344 'urls:URL:_hg_urls'
356 'urls:URL:_hg_urls'
345 }
357 }
346
358
347 _hg_clone_dest() {
359 _hg_clone_dest() {
348 _alternative 'directories:directory:_files -/' \
360 _alternative 'directories:directory:_files -/' \
349 'urls:URL:_hg_urls'
361 'urls:URL:_hg_urls'
350 }
362 }
351
363
352 # Common options
364 # Common options
353 _hg_global_opts=(
365 _hg_global_opts=(
354 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
366 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
355 '--cwd[change working directory]:new working directory:_files -/'
367 '--cwd[change working directory]:new working directory:_files -/'
356 '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
368 '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
357 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
369 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
358 '*--config[set/override config option]:defined config items:_hg_config'
370 '*--config[set/override config option]:defined config items:_hg_config'
359 '(--quiet -q)'{-q,--quiet}'[suppress output]'
371 '(--quiet -q)'{-q,--quiet}'[suppress output]'
360 '(--help -h)'{-h,--help}'[display help and exit]'
372 '(--help -h)'{-h,--help}'[display help and exit]'
361 '--debug[debug mode]'
373 '--debug[debug mode]'
362 '--debugger[start debugger]'
374 '--debugger[start debugger]'
363 '--encoding[set the charset encoding]'
375 '--encoding[set the charset encoding]'
364 '--encodingmode[set the charset encoding mode]'
376 '--encodingmode[set the charset encoding mode]'
365 '--lsprof[print improved command execution profile]'
377 '--lsprof[print improved command execution profile]'
366 '--traceback[print traceback on exception]'
378 '--traceback[print traceback on exception]'
367 '--time[time how long the command takes]'
379 '--time[time how long the command takes]'
368 '--profile[profile]'
380 '--profile[profile]'
369 '--version[output version information and exit]'
381 '--version[output version information and exit]'
370 )
382 )
371
383
372 _hg_pat_opts=(
384 _hg_pat_opts=(
373 '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
385 '*'{-I+,--include}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
374 '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
386 '*'{-X+,--exclude}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
375
387
376 _hg_diff_opts=(
388 _hg_diff_opts=(
377 '(--text -a)'{-a,--text}'[treat all files as text]'
389 '(--text -a)'{-a,--text}'[treat all files as text]'
378 '(--git -g)'{-g,--git}'[use git extended diff format]'
390 '(--git -g)'{-g,--git}'[use git extended diff format]'
379 "--nodates[omit dates from diff headers]")
391 "--nodates[omit dates from diff headers]")
380
392
381 _hg_dryrun_opts=(
393 _hg_dryrun_opts=(
382 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
394 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
383
395
384 _hg_style_opts=(
396 _hg_style_opts=(
385 '--style[display using template map file]:'
397 '--style[display using template map file]:'
386 '--template[display with template]:')
398 '--template[display with template]:')
387
399
388 _hg_commit_opts=(
400 _hg_commit_opts=(
389 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
401 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
390 '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use <text> as commit message]:message:'
402 '(-e --edit -l --logfile --message -m)'{-m+,--message}'[use <text> as commit message]:message:'
391 '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from <file>]:log file:_files')
403 '(-e --edit -m --message --logfile -l)'{-l+,--logfile}'[read the commit message from <file>]:log file:_files')
392
404
393 _hg_remote_opts=(
405 _hg_remote_opts=(
394 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
406 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
395 '--remotecmd[specify hg command to run on the remote side]:')
407 '--remotecmd[specify hg command to run on the remote side]:')
396
408
397 _hg_cmd() {
409 _hg_cmd() {
398 _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null
410 _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null
399 }
411 }
400
412
401 _hg_cmd_add() {
413 _hg_cmd_add() {
402 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
414 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
403 '*:unknown files:_hg_unknown'
415 '*:unknown files:_hg_unknown'
404 }
416 }
405
417
406 _hg_cmd_addremove() {
418 _hg_cmd_addremove() {
407 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
419 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
408 '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
420 '(--similarity -s)'{-s+,--similarity}'[guess renamed files by similarity (0<=s<=100)]:' \
409 '*:unknown or missing files:_hg_addremove'
421 '*:unknown or missing files:_hg_addremove'
410 }
422 }
411
423
412 _hg_cmd_annotate() {
424 _hg_cmd_annotate() {
413 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
425 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
414 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_labels' \
426 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_labels' \
415 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
427 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
416 '(--text -a)'{-a,--text}'[treat all files as text]' \
428 '(--text -a)'{-a,--text}'[treat all files as text]' \
417 '(--user -u)'{-u,--user}'[list the author]' \
429 '(--user -u)'{-u,--user}'[list the author]' \
418 '(--date -d)'{-d,--date}'[list the date]' \
430 '(--date -d)'{-d,--date}'[list the date]' \
419 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
431 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
420 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
432 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
421 '*:files:_hg_files'
433 '*:files:_hg_files'
422 }
434 }
423
435
424 _hg_cmd_archive() {
436 _hg_cmd_archive() {
425 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
437 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
426 '--no-decode[do not pass files through decoders]' \
438 '--no-decode[do not pass files through decoders]' \
427 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
439 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
428 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_labels' \
440 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_labels' \
429 '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
441 '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
430 '*:destination:_files'
442 '*:destination:_files'
431 }
443 }
432
444
433 _hg_cmd_backout() {
445 _hg_cmd_backout() {
434 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
446 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
435 '--merge[merge with old dirstate parent after backout]' \
447 '--merge[merge with old dirstate parent after backout]' \
436 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
448 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
437 '--parent[parent to choose when backing out merge]' \
449 '--parent[parent to choose when backing out merge]' \
438 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
450 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
439 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
451 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
440 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
452 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
441 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt'
453 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt'
442 }
454 }
443
455
444 _hg_cmd_bisect() {
456 _hg_cmd_bisect() {
445 _arguments -s -w : $_hg_global_opts \
457 _arguments -s -w : $_hg_global_opts \
446 '(-)'{-r,--reset}'[reset bisect state]' \
458 '(-)'{-r,--reset}'[reset bisect state]' \
447 '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_labels \
459 '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_labels \
448 '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_labels \
460 '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_labels \
449 '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
461 '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
450 '(--command -c --noupdate -U)'{-c+,--command}'[use command to check changeset state]':commands:_command_names \
462 '(--command -c --noupdate -U)'{-c+,--command}'[use command to check changeset state]':commands:_command_names \
451 '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
463 '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
452 }
464 }
453
465
454 _hg_cmd_bookmarks() {
466 _hg_cmd_bookmarks() {
455 _arguments -s -w : $_hg_global_opts \
467 _arguments -s -w : $_hg_global_opts \
456 '(--force -f)'{-f,--force}'[force]' \
468 '(--force -f)'{-f,--force}'[force]' \
457 '(--rev -r --delete -d --rename -m)'{-r+,--rev}'[revision]:revision:_hg_labels' \
469 '(--rev -r --delete -d --rename -m)'{-r+,--rev}'[revision]:revision:_hg_labels' \
458 '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
470 '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
459 '(--rev -r --delete -d --rename -m)'{-m+,--rename}'[rename a given bookmark]:bookmark:_hg_bookmarks' \
471 '(--rev -r --delete -d --rename -m)'{-m+,--rename}'[rename a given bookmark]:bookmark:_hg_bookmarks' \
460 ':bookmark:_hg_bookmarks'
472 ':bookmark:_hg_bookmarks'
461 }
473 }
462
474
463 _hg_cmd_branch() {
475 _hg_cmd_branch() {
464 _arguments -s -w : $_hg_global_opts \
476 _arguments -s -w : $_hg_global_opts \
465 '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
477 '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
466 '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
478 '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
467 }
479 }
468
480
469 _hg_cmd_branches() {
481 _hg_cmd_branches() {
470 _arguments -s -w : $_hg_global_opts \
482 _arguments -s -w : $_hg_global_opts \
471 '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]'
483 '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]'
472 }
484 }
473
485
474 _hg_cmd_bundle() {
486 _hg_cmd_bundle() {
475 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
487 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
476 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
488 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
477 '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_labels' \
489 '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_labels' \
478 ':output file:_files' \
490 ':output file:_files' \
479 ':destination repository:_files -/'
491 ':destination repository:_files -/'
480 }
492 }
481
493
482 _hg_cmd_cat() {
494 _hg_cmd_cat() {
483 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
495 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
484 '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
496 '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
485 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
497 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
486 '*:file:_hg_files'
498 '*:file:_hg_files'
487 }
499 }
488
500
489 _hg_cmd_clone() {
501 _hg_cmd_clone() {
490 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
502 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
491 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
503 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
492 '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
504 '(--rev -r)'{-r+,--rev}'[a changeset you would like to have after cloning]:' \
493 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
505 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
494 ':source repository:_hg_remote' \
506 ':source repository:_hg_remote' \
495 ':destination:_hg_clone_dest'
507 ':destination:_hg_clone_dest'
496 }
508 }
497
509
498 _hg_cmd_commit() {
510 _hg_cmd_commit() {
499 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
511 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
500 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
512 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
501 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
513 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
502 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt' \
514 '(--logfile -l)'{-l+,--logfile}'[read commit message from <file>]:log file:_files -g \*.txt' \
503 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
515 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
504 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
516 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
505 '*:file:_hg_files'
517 '*:file:_hg_files'
506 }
518 }
507
519
508 _hg_cmd_copy() {
520 _hg_cmd_copy() {
509 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
521 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
510 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
522 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
511 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
523 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
512 '*:file:_hg_files'
524 '*:file:_hg_files'
513 }
525 }
514
526
515 _hg_cmd_diff() {
527 _hg_cmd_diff() {
516 typeset -A opt_args
528 typeset -A opt_args
517 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
529 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
518 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
530 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
519 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
531 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
520 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
532 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
521 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
533 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
522 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \
534 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \
523 '*:file:->diff_files'
535 '*:file:->diff_files'
524
536
525 if [[ $state == 'diff_files' ]]
537 if [[ $state == 'diff_files' ]]
526 then
538 then
527 if [[ -n $opt_args[-r] ]]
539 if [[ -n $opt_args[-r] ]]
528 then
540 then
529 _hg_files
541 _hg_files
530 else
542 else
531 _hg_modified
543 _hg_modified
532 fi
544 fi
533 fi
545 fi
534 }
546 }
535
547
536 _hg_cmd_export() {
548 _hg_cmd_export() {
537 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
549 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
538 '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
550 '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
539 '--switch-parent[diff against the second parent]' \
551 '--switch-parent[diff against the second parent]' \
540 '*:revision:_hg_labels'
552 '*:revision:_hg_labels'
541 }
553 }
542
554
543 _hg_cmd_grep() {
555 _hg_cmd_grep() {
544 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
556 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
545 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
557 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
546 '--all[print all revisions with matches]' \
558 '--all[print all revisions with matches]' \
547 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
559 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
548 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
560 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
549 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
561 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
550 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
562 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
551 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
563 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
552 '(--user -u)'{-u,--user}'[print user who committed change]' \
564 '(--user -u)'{-u,--user}'[print user who committed change]' \
553 '1:search pattern:' \
565 '1:search pattern:' \
554 '*:files:_hg_files'
566 '*:files:_hg_files'
555 }
567 }
556
568
557 _hg_cmd_heads() {
569 _hg_cmd_heads() {
558 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
570 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
559 '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_labels'
571 '(--rev -r)'{-r+,--rev}'[show only heads which are descendants of rev]:revision:_hg_labels'
560 }
572 }
561
573
562 _hg_cmd_help() {
574 _hg_cmd_help() {
563 _arguments -s -w : $_hg_global_opts \
575 _arguments -s -w : $_hg_global_opts \
564 '*:mercurial command:_hg_commands'
576 '*:mercurial command:_hg_commands'
565 }
577 }
566
578
567 _hg_cmd_identify() {
579 _hg_cmd_identify() {
568 _arguments -s -w : $_hg_global_opts \
580 _arguments -s -w : $_hg_global_opts \
569 '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_labels' \
581 '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_labels' \
570 '(--num -n)'{-n+,--num}'[show local revision number]' \
582 '(--num -n)'{-n+,--num}'[show local revision number]' \
571 '(--id -i)'{-i+,--id}'[show global revision id]' \
583 '(--id -i)'{-i+,--id}'[show global revision id]' \
572 '(--branch -b)'{-b+,--branch}'[show branch]' \
584 '(--branch -b)'{-b+,--branch}'[show branch]' \
573 '(--tags -t)'{-t+,--tags}'[show tags]'
585 '(--tags -t)'{-t+,--tags}'[show tags]'
574 }
586 }
575
587
576 _hg_cmd_import() {
588 _hg_cmd_import() {
577 _arguments -s -w : $_hg_global_opts \
589 _arguments -s -w : $_hg_global_opts \
578 '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
590 '(--strip -p)'{-p+,--strip}'[directory strip option for patch (default: 1)]:count:' \
579 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
591 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
580 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
592 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
581 '*:patch:_files'
593 '*:patch:_files'
582 }
594 }
583
595
584 _hg_cmd_incoming() {
596 _hg_cmd_incoming() {
585 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
597 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
586 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
598 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
587 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
599 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
588 '(--patch -p)'{-p,--patch}'[show patch]' \
600 '(--patch -p)'{-p,--patch}'[show patch]' \
589 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
601 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
590 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
602 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
591 '--bundle[file to store the bundles into]:bundle file:_files' \
603 '--bundle[file to store the bundles into]:bundle file:_files' \
592 ':source:_hg_remote'
604 ':source:_hg_remote'
593 }
605 }
594
606
595 _hg_cmd_init() {
607 _hg_cmd_init() {
596 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
608 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
597 ':dir:_files -/'
609 ':dir:_files -/'
598 }
610 }
599
611
600 _hg_cmd_locate() {
612 _hg_cmd_locate() {
601 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
613 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
602 '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_labels' \
614 '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_labels' \
603 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
615 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
604 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
616 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
605 '*:search pattern:_hg_files'
617 '*:search pattern:_hg_files'
606 }
618 }
607
619
608 _hg_cmd_log() {
620 _hg_cmd_log() {
609 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
621 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
610 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
622 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
611 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
623 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
612 '(--copies -C)'{-C,--copies}'[show copied files]' \
624 '(--copies -C)'{-C,--copies}'[show copied files]' \
613 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
625 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
614 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
626 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
615 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
627 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
616 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
628 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
617 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
629 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
618 '(--patch -p)'{-p,--patch}'[show patch]' \
630 '(--patch -p)'{-p,--patch}'[show patch]' \
619 '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_labels' \
631 '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_labels' \
632 '(--branch -b)'{-b+,--branch}'[show changesets within the given named branch]:branch:_hg_branches' \
620 '*:files:_hg_files'
633 '*:files:_hg_files'
621 }
634 }
622
635
623 _hg_cmd_manifest() {
636 _hg_cmd_manifest() {
624 _arguments -s -w : $_hg_global_opts \
637 _arguments -s -w : $_hg_global_opts \
625 ':revision:_hg_labels'
638 ':revision:_hg_labels'
626 }
639 }
627
640
628 _hg_cmd_merge() {
641 _hg_cmd_merge() {
629 _arguments -s -w : $_hg_global_opts \
642 _arguments -s -w : $_hg_global_opts \
630 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
643 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
631 '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
644 '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
632 '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
645 '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
633 ':revision:_hg_mergerevs'
646 ':revision:_hg_mergerevs'
634 }
647 }
635
648
636 _hg_cmd_outgoing() {
649 _hg_cmd_outgoing() {
637 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
650 _arguments -s -w : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
638 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
651 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
639 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
652 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
640 '(--patch -p)'{-p,--patch}'[show patch]' \
653 '(--patch -p)'{-p,--patch}'[show patch]' \
641 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
654 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]' \
642 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
655 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
643 ':destination:_hg_remote'
656 ':destination:_hg_remote'
644 }
657 }
645
658
646 _hg_cmd_parents() {
659 _hg_cmd_parents() {
647 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
660 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
648 '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_labels' \
661 '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_labels' \
649 ':last modified file:_hg_files'
662 ':last modified file:_hg_files'
650 }
663 }
651
664
652 _hg_cmd_paths() {
665 _hg_cmd_paths() {
653 _arguments -s -w : $_hg_global_opts \
666 _arguments -s -w : $_hg_global_opts \
654 ':path:_hg_paths'
667 ':path:_hg_paths'
655 }
668 }
656
669
657 _hg_cmd_pull() {
670 _hg_cmd_pull() {
658 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
671 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
659 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
672 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
660 '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
673 '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
661 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
674 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
662 ':source:_hg_remote'
675 ':source:_hg_remote'
663 }
676 }
664
677
665 _hg_cmd_push() {
678 _hg_cmd_push() {
666 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
679 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
667 '(--force -f)'{-f,--force}'[force push]' \
680 '(--force -f)'{-f,--force}'[force push]' \
668 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_labels' \
681 '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_labels' \
669 ':destination:_hg_remote'
682 ':destination:_hg_remote'
670 }
683 }
671
684
672 _hg_cmd_remove() {
685 _hg_cmd_remove() {
673 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
686 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
674 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
687 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
675 '(--force -f)'{-f,--force}'[remove file even if modified]' \
688 '(--force -f)'{-f,--force}'[remove file even if modified]' \
676 '*:file:_hg_files'
689 '*:file:_hg_files'
677 }
690 }
678
691
679 _hg_cmd_rename() {
692 _hg_cmd_rename() {
680 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
693 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
681 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
694 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
682 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
695 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
683 '*:file:_hg_files'
696 '*:file:_hg_files'
684 }
697 }
685
698
686 _hg_cmd_resolve() {
699 _hg_cmd_resolve() {
687 local context state line
700 local context state line
688 typeset -A opt_args
701 typeset -A opt_args
689
702
690 _arguments -s -w : $_hg_global_opts \
703 _arguments -s -w : $_hg_global_opts \
691 '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
704 '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
692 '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
705 '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
693 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
706 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
694 '*:file:_hg_unresolved'
707 '*:file:_hg_unresolved'
695
708
696 if [[ $state == 'resolve_files' ]]
709 if [[ $state == 'resolve_files' ]]
697 then
710 then
698 _alternative 'files:resolved files:_hg_resolved' \
711 _alternative 'files:resolved files:_hg_resolved' \
699 'files:unresolved files:_hg_unresolved'
712 'files:unresolved files:_hg_unresolved'
700 fi
713 fi
701 }
714 }
702
715
703 _hg_cmd_revert() {
716 _hg_cmd_revert() {
704 local context state line
717 local context state line
705 typeset -A opt_args
718 typeset -A opt_args
706
719
707 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
720 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
708 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
721 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
709 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_labels' \
722 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_labels' \
710 '--no-backup[do not save backup copies of files]' \
723 '--no-backup[do not save backup copies of files]' \
711 '*:file:->diff_files'
724 '*:file:->diff_files'
712
725
713 if [[ $state == 'diff_files' ]]
726 if [[ $state == 'diff_files' ]]
714 then
727 then
715 if [[ -n $opt_args[-r] ]]
728 if [[ -n $opt_args[-r] ]]
716 then
729 then
717 _hg_files
730 _hg_files
718 else
731 else
719 typeset -a status_files
732 typeset -a status_files
720 _hg_status mard
733 _hg_status mard
721 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files
734 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files
722 fi
735 fi
723 fi
736 fi
724 }
737 }
725
738
726 _hg_cmd_serve() {
739 _hg_cmd_serve() {
727 _arguments -s -w : $_hg_global_opts \
740 _arguments -s -w : $_hg_global_opts \
728 '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
741 '(--accesslog -A)'{-A+,--accesslog}'[name of access log file]:log file:_files' \
729 '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
742 '(--errorlog -E)'{-E+,--errorlog}'[name of error log file]:log file:_files' \
730 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
743 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
731 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
744 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
732 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
745 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
733 '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
746 '(--name -n)'{-n+,--name}'[name to show in web pages]:repository name:' \
734 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
747 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
735 '--style[web template style]:style' \
748 '--style[web template style]:style' \
736 '--stdio[for remote clients]' \
749 '--stdio[for remote clients]' \
737 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
750 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
738 }
751 }
739
752
740 _hg_cmd_showconfig() {
753 _hg_cmd_showconfig() {
741 _arguments -s -w : $_hg_global_opts \
754 _arguments -s -w : $_hg_global_opts \
742 '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
755 '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
743 ':config item:_hg_config'
756 ':config item:_hg_config'
744 }
757 }
745
758
746 _hg_cmd_status() {
759 _hg_cmd_status() {
747 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
760 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
748 '(--all -A)'{-A,--all}'[show status of all files]' \
761 '(--all -A)'{-A,--all}'[show status of all files]' \
749 '(--modified -m)'{-m,--modified}'[show only modified files]' \
762 '(--modified -m)'{-m,--modified}'[show only modified files]' \
750 '(--added -a)'{-a,--added}'[show only added files]' \
763 '(--added -a)'{-a,--added}'[show only added files]' \
751 '(--removed -r)'{-r,--removed}'[show only removed files]' \
764 '(--removed -r)'{-r,--removed}'[show only removed files]' \
752 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
765 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
753 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
766 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
754 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
767 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
755 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
768 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
756 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
769 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
757 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
770 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
758 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
771 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
759 '--rev[show difference from revision]:revision:_hg_labels' \
772 '--rev[show difference from revision]:revision:_hg_labels' \
760 '*:files:_files'
773 '*:files:_files'
761 }
774 }
762
775
763 _hg_cmd_summary() {
776 _hg_cmd_summary() {
764 _arguments -s -w : $_hg_global_opts \
777 _arguments -s -w : $_hg_global_opts \
765 '--remote[check for push and pull]'
778 '--remote[check for push and pull]'
766 }
779 }
767
780
768 _hg_cmd_tag() {
781 _hg_cmd_tag() {
769 _arguments -s -w : $_hg_global_opts \
782 _arguments -s -w : $_hg_global_opts \
770 '(--local -l)'{-l,--local}'[make the tag local]' \
783 '(--local -l)'{-l,--local}'[make the tag local]' \
771 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
784 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
772 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
785 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
773 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
786 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
774 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_labels' \
787 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_labels' \
775 ':tag name:'
788 ':tag name:'
776 }
789 }
777
790
778 _hg_cmd_tip() {
791 _hg_cmd_tip() {
779 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
792 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
780 '(--patch -p)'{-p,--patch}'[show patch]'
793 '(--patch -p)'{-p,--patch}'[show patch]'
781 }
794 }
782
795
783 _hg_cmd_unbundle() {
796 _hg_cmd_unbundle() {
784 _arguments -s -w : $_hg_global_opts \
797 _arguments -s -w : $_hg_global_opts \
785 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
798 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
786 ':files:_files'
799 ':files:_files'
787 }
800 }
788
801
789 _hg_cmd_update() {
802 _hg_cmd_update() {
790 _arguments -s -w : $_hg_global_opts \
803 _arguments -s -w : $_hg_global_opts \
791 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
804 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
792 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
805 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
793 ':revision:_hg_labels'
806 ':revision:_hg_labels'
794 }
807 }
795
808
796 ## extensions ##
809 ## extensions ##
797
810
798 # HGK
811 # HGK
799 _hg_cmd_view() {
812 _hg_cmd_view() {
800 _arguments -s -w : $_hg_global_opts \
813 _arguments -s -w : $_hg_global_opts \
801 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
814 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
802 ':revision range:_hg_tags'
815 ':revision range:_hg_tags'
803 }
816 }
804
817
805 # MQ
818 # MQ
806 _hg_qseries() {
819 _hg_qseries() {
807 typeset -a patches
820 typeset -a patches
808 patches=(${(f)"$(_hg_cmd qseries)"})
821 patches=(${(f)"$(_hg_cmd qseries)"})
809 (( $#patches )) && _describe -t hg-patches 'patches' patches
822 (( $#patches )) && _describe -t hg-patches 'patches' patches
810 }
823 }
811
824
812 _hg_qapplied() {
825 _hg_qapplied() {
813 typeset -a patches
826 typeset -a patches
814 patches=(${(f)"$(_hg_cmd qapplied)"})
827 patches=(${(f)"$(_hg_cmd qapplied)"})
815 if (( $#patches ))
828 if (( $#patches ))
816 then
829 then
817 patches+=(qbase qtip)
830 patches+=(qbase qtip)
818 _describe -t hg-applied-patches 'applied patches' patches
831 _describe -t hg-applied-patches 'applied patches' patches
819 fi
832 fi
820 }
833 }
821
834
822 _hg_qunapplied() {
835 _hg_qunapplied() {
823 typeset -a patches
836 typeset -a patches
824 patches=(${(f)"$(_hg_cmd qunapplied)"})
837 patches=(${(f)"$(_hg_cmd qunapplied)"})
825 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
838 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
826 }
839 }
827
840
828 # unapplied, including guarded patches
841 # unapplied, including guarded patches
829 _hg_qdeletable() {
842 _hg_qdeletable() {
830 typeset -a unapplied
843 typeset -a unapplied
831 unapplied=(${(f)"$(_hg_cmd qseries)"})
844 unapplied=(${(f)"$(_hg_cmd qseries)"})
832 for p in $(_hg_cmd qapplied)
845 for p in $(_hg_cmd qapplied)
833 do
846 do
834 unapplied=(${unapplied:#$p})
847 unapplied=(${unapplied:#$p})
835 done
848 done
836
849
837 (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
850 (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
838 }
851 }
839
852
840 _hg_qguards() {
853 _hg_qguards() {
841 typeset -a guards
854 typeset -a guards
842 local guard
855 local guard
843 compset -P "+|-"
856 compset -P "+|-"
844 _hg_cmd qselect -s | while read guard
857 _hg_cmd qselect -s | while read guard
845 do
858 do
846 guards+=(${guard#(+|-)})
859 guards+=(${guard#(+|-)})
847 done
860 done
848 (( $#guards )) && _describe -t hg-guards 'guards' guards
861 (( $#guards )) && _describe -t hg-guards 'guards' guards
849 }
862 }
850
863
851 _hg_qseries_opts=(
864 _hg_qseries_opts=(
852 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
865 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
853
866
854 _hg_cmd_qapplied() {
867 _hg_cmd_qapplied() {
855 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
868 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
856 }
869 }
857
870
858 _hg_cmd_qdelete() {
871 _hg_cmd_qdelete() {
859 _arguments -s -w : $_hg_global_opts \
872 _arguments -s -w : $_hg_global_opts \
860 '(--keep -k)'{-k,--keep}'[keep patch file]' \
873 '(--keep -k)'{-k,--keep}'[keep patch file]' \
861 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
874 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
862 '*:unapplied patch:_hg_qdeletable'
875 '*:unapplied patch:_hg_qdeletable'
863 }
876 }
864
877
865 _hg_cmd_qdiff() {
878 _hg_cmd_qdiff() {
866 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
879 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
867 '*:pattern:_hg_files'
880 '*:pattern:_hg_files'
868 }
881 }
869
882
870 _hg_cmd_qfold() {
883 _hg_cmd_qfold() {
871 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
884 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
872 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
885 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
873 '*:unapplied patch:_hg_qunapplied'
886 '*:unapplied patch:_hg_qunapplied'
874 }
887 }
875
888
876 _hg_cmd_qgoto() {
889 _hg_cmd_qgoto() {
877 _arguments -s -w : $_hg_global_opts \
890 _arguments -s -w : $_hg_global_opts \
878 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
891 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
879 ':patch:_hg_qseries'
892 ':patch:_hg_qseries'
880 }
893 }
881
894
882 _hg_cmd_qguard() {
895 _hg_cmd_qguard() {
883 _arguments -s -w : $_hg_global_opts \
896 _arguments -s -w : $_hg_global_opts \
884 '(--list -l)'{-l,--list}'[list all patches and guards]' \
897 '(--list -l)'{-l,--list}'[list all patches and guards]' \
885 '(--none -n)'{-n,--none}'[drop all guards]' \
898 '(--none -n)'{-n,--none}'[drop all guards]' \
886 ':patch:_hg_qseries' \
899 ':patch:_hg_qseries' \
887 '*:guards:_hg_qguards'
900 '*:guards:_hg_qguards'
888 }
901 }
889
902
890 _hg_cmd_qheader() {
903 _hg_cmd_qheader() {
891 _arguments -s -w : $_hg_global_opts \
904 _arguments -s -w : $_hg_global_opts \
892 ':patch:_hg_qseries'
905 ':patch:_hg_qseries'
893 }
906 }
894
907
895 _hg_cmd_qimport() {
908 _hg_cmd_qimport() {
896 _arguments -s -w : $_hg_global_opts \
909 _arguments -s -w : $_hg_global_opts \
897 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
910 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
898 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
911 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
899 '(--force -f)'{-f,--force}'[overwrite existing files]' \
912 '(--force -f)'{-f,--force}'[overwrite existing files]' \
900 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
913 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
901 '*:patch:_files'
914 '*:patch:_files'
902 }
915 }
903
916
904 _hg_cmd_qnew() {
917 _hg_cmd_qnew() {
905 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
918 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
906 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
919 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
907 ':patch:'
920 ':patch:'
908 }
921 }
909
922
910 _hg_cmd_qnext() {
923 _hg_cmd_qnext() {
911 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
924 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
912 }
925 }
913
926
914 _hg_cmd_qpop() {
927 _hg_cmd_qpop() {
915 _arguments -s -w : $_hg_global_opts \
928 _arguments -s -w : $_hg_global_opts \
916 '(--all -a :)'{-a,--all}'[pop all patches]' \
929 '(--all -a :)'{-a,--all}'[pop all patches]' \
917 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
930 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
918 '(--force -f)'{-f,--force}'[forget any local changes]' \
931 '(--force -f)'{-f,--force}'[forget any local changes]' \
919 ':patch:_hg_qapplied'
932 ':patch:_hg_qapplied'
920 }
933 }
921
934
922 _hg_cmd_qprev() {
935 _hg_cmd_qprev() {
923 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
936 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
924 }
937 }
925
938
926 _hg_cmd_qpush() {
939 _hg_cmd_qpush() {
927 _arguments -s -w : $_hg_global_opts \
940 _arguments -s -w : $_hg_global_opts \
928 '(--all -a :)'{-a,--all}'[apply all patches]' \
941 '(--all -a :)'{-a,--all}'[apply all patches]' \
929 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
942 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
930 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
943 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
931 '(--name -n)'{-n+,--name}'[merge queue name]:' \
944 '(--name -n)'{-n+,--name}'[merge queue name]:' \
932 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
945 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
933 '--move[reorder patch series and apply only the patch]' \
946 '--move[reorder patch series and apply only the patch]' \
934 ':patch:_hg_qunapplied'
947 ':patch:_hg_qunapplied'
935 }
948 }
936
949
937 _hg_cmd_qrefresh() {
950 _hg_cmd_qrefresh() {
938 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
951 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
939 '(--git -g)'{-g,--git}'[use git extended diff format]' \
952 '(--git -g)'{-g,--git}'[use git extended diff format]' \
940 '(--short -s)'{-s,--short}'[short refresh]' \
953 '(--short -s)'{-s,--short}'[short refresh]' \
941 '*:files:_hg_files'
954 '*:files:_hg_files'
942 }
955 }
943
956
944 _hg_cmd_qrename() {
957 _hg_cmd_qrename() {
945 _arguments -s -w : $_hg_global_opts \
958 _arguments -s -w : $_hg_global_opts \
946 ':patch:_hg_qseries' \
959 ':patch:_hg_qseries' \
947 ':destination:'
960 ':destination:'
948 }
961 }
949
962
950 _hg_cmd_qselect() {
963 _hg_cmd_qselect() {
951 _arguments -s -w : $_hg_global_opts \
964 _arguments -s -w : $_hg_global_opts \
952 '(--none -n :)'{-n,--none}'[disable all guards]' \
965 '(--none -n :)'{-n,--none}'[disable all guards]' \
953 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
966 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
954 '--pop[pop to before first guarded applied patch]' \
967 '--pop[pop to before first guarded applied patch]' \
955 '--reapply[pop and reapply patches]' \
968 '--reapply[pop and reapply patches]' \
956 '*:guards:_hg_qguards'
969 '*:guards:_hg_qguards'
957 }
970 }
958
971
959 _hg_cmd_qseries() {
972 _hg_cmd_qseries() {
960 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
973 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
961 '(--missing -m)'{-m,--missing}'[print patches not in series]'
974 '(--missing -m)'{-m,--missing}'[print patches not in series]'
962 }
975 }
963
976
964 _hg_cmd_qunapplied() {
977 _hg_cmd_qunapplied() {
965 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
978 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
966 }
979 }
967
980
968 _hg_cmd_qtop() {
981 _hg_cmd_qtop() {
969 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
982 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
970 }
983 }
971
984
972 _hg_cmd_strip() {
985 _hg_cmd_strip() {
973 _arguments -s -w : $_hg_global_opts \
986 _arguments -s -w : $_hg_global_opts \
974 '(--force -f)'{-f,--force}'[force multi-head removal]' \
987 '(--force -f)'{-f,--force}'[force multi-head removal]' \
975 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
988 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
976 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
989 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
977 ':revision:_hg_labels'
990 ':revision:_hg_labels'
978 }
991 }
979
992
980 # Patchbomb
993 # Patchbomb
981 _hg_cmd_email() {
994 _hg_cmd_email() {
982 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
995 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
983 '(--git -g)'{-g,--git}'[use git extended diff format]' \
996 '(--git -g)'{-g,--git}'[use git extended diff format]' \
984 '--plain[omit hg patch header]' \
997 '--plain[omit hg patch header]' \
985 '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
998 '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
986 '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
999 '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
987 '--bundlename[name of the bundle attachment file (default: bundle)]:' \
1000 '--bundlename[name of the bundle attachment file (default: bundle)]:' \
988 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
1001 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
989 '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
1002 '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
990 '*--base[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
1003 '*--base[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
991 '--intro[send an introduction email for a single patch]' \
1004 '--intro[send an introduction email for a single patch]' \
992 '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
1005 '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
993 '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
1006 '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
994 '*--bcc[email addresses of blind carbon copy recipients]:email:' \
1007 '*--bcc[email addresses of blind carbon copy recipients]:email:' \
995 '*'{-c+,--cc}'[email addresses of copy recipients]:email:' \
1008 '*'{-c+,--cc}'[email addresses of copy recipients]:email:' \
996 '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
1009 '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
997 '--date[use the given date as the sending date]:date:' \
1010 '--date[use the given date as the sending date]:date:' \
998 '--desc[use the given file as the series description]:files:_files' \
1011 '--desc[use the given file as the series description]:files:_files' \
999 '(--from -f)'{-f,--from}'[email address of sender]:email:' \
1012 '(--from -f)'{-f,--from}'[email address of sender]:email:' \
1000 '(--test -n)'{-n,--test}'[print messages that would be sent]' \
1013 '(--test -n)'{-n,--test}'[print messages that would be sent]' \
1001 '(--mbox -m)'{-m,--mbox}'[write messages to mbox file instead of sending them]:file:' \
1014 '(--mbox -m)'{-m,--mbox}'[write messages to mbox file instead of sending them]:file:' \
1002 '*--reply-to[email addresses replies should be sent to]:email:' \
1015 '*--reply-to[email addresses replies should be sent to]:email:' \
1003 '(--subject -s)'{-s,--subject}'[subject of first message (intro or single patch)]:subject:' \
1016 '(--subject -s)'{-s,--subject}'[subject of first message (intro or single patch)]:subject:' \
1004 '--in-reply-to[message identifier to reply to]:msgid:' \
1017 '--in-reply-to[message identifier to reply to]:msgid:' \
1005 '*--flag[flags to add in subject prefixes]:flag:' \
1018 '*--flag[flags to add in subject prefixes]:flag:' \
1006 '*'{-t,--to}'[email addresses of recipients]:email:' \
1019 '*'{-t,--to}'[email addresses of recipients]:email:' \
1007 ':revision:_hg_revrange'
1020 ':revision:_hg_revrange'
1008 }
1021 }
1009
1022
1010 _hg "$@"
1023 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now