##// END OF EJS Templates
zsh completion: add support for qfinish
Augie Fackler -
r15645:88a82069 default
parent child Browse files
Show More
@@ -1,1023 +1,1029 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 _hg_branches "$@"
169 }
169 }
170
170
171 _hg_tags() {
171 _hg_tags() {
172 typeset -a tags
172 typeset -a tags
173 local tag rev
173 local tag rev
174
174
175 _hg_cmd tags | while read tag
175 _hg_cmd tags | while read tag
176 do
176 do
177 tags+=(${tag/ # [0-9]#:*})
177 tags+=(${tag/ # [0-9]#:*})
178 done
178 done
179 (( $#tags )) && _describe -t tags 'tags' tags
179 (( $#tags )) && _describe -t tags 'tags' tags
180 }
180 }
181
181
182 _hg_bookmarks() {
182 _hg_bookmarks() {
183 typeset -a bookmark bookmarks
183 typeset -a bookmark bookmarks
184
184
185 _hg_cmd bookmarks | while read -A bookmark
185 _hg_cmd bookmarks | while read -A bookmark
186 do
186 do
187 if test -z ${bookmark[-1]:#[0-9]*}
187 if test -z ${bookmark[-1]:#[0-9]*}
188 then
188 then
189 bookmarks+=($bookmark[-2])
189 bookmarks+=($bookmark[-2])
190 fi
190 fi
191 done
191 done
192 (( $#bookmarks )) && _describe -t bookmarks 'bookmarks' bookmarks
192 (( $#bookmarks )) && _describe -t bookmarks 'bookmarks' bookmarks
193 }
193 }
194
194
195 _hg_branches() {
195 _hg_branches() {
196 typeset -a branches
196 typeset -a branches
197 local branch
197 local branch
198
198
199 _hg_cmd branches | while read branch
199 _hg_cmd branches | while read branch
200 do
200 do
201 branches+=(${branch/ # [0-9]#:*})
201 branches+=(${branch/ # [0-9]#:*})
202 done
202 done
203 (( $#branches )) && _describe -t branches 'branches' branches
203 (( $#branches )) && _describe -t branches 'branches' branches
204 }
204 }
205
205
206 # likely merge candidates
206 # likely merge candidates
207 _hg_mergerevs() {
207 _hg_mergerevs() {
208 typeset -a heads
208 typeset -a heads
209 local myrev
209 local myrev
210
210
211 heads=(${(f)"$(_hg_cmd heads --template '{rev}\\n')"})
211 heads=(${(f)"$(_hg_cmd heads --template '{rev}\\n')"})
212 # exclude own revision
212 # exclude own revision
213 myrev=$(_hg_cmd log -r . --template '{rev}\\n')
213 myrev=$(_hg_cmd log -r . --template '{rev}\\n')
214 heads=(${heads:#$myrev})
214 heads=(${heads:#$myrev})
215
215
216 (( $#heads )) && _describe -t heads 'heads' heads
216 (( $#heads )) && _describe -t heads 'heads' heads
217 }
217 }
218
218
219 _hg_files() {
219 _hg_files() {
220 if [[ -n "$_hg_root" ]]
220 if [[ -n "$_hg_root" ]]
221 then
221 then
222 [[ -d "$_hg_root/.hg" ]] || return
222 [[ -d "$_hg_root/.hg" ]] || return
223 case "$_hg_root" in
223 case "$_hg_root" in
224 /*)
224 /*)
225 _files -W $_hg_root
225 _files -W $_hg_root
226 ;;
226 ;;
227 *)
227 *)
228 _files -W $PWD/$_hg_root
228 _files -W $PWD/$_hg_root
229 ;;
229 ;;
230 esac
230 esac
231 else
231 else
232 _files
232 _files
233 fi
233 fi
234 }
234 }
235
235
236 _hg_status() {
236 _hg_status() {
237 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
237 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
238 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
238 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
239 }
239 }
240
240
241 _hg_unknown() {
241 _hg_unknown() {
242 typeset -a status_files
242 typeset -a status_files
243 _hg_status u
243 _hg_status u
244 _wanted files expl 'unknown files' _multi_parts / status_files
244 _wanted files expl 'unknown files' _multi_parts / status_files
245 }
245 }
246
246
247 _hg_missing() {
247 _hg_missing() {
248 typeset -a status_files
248 typeset -a status_files
249 _hg_status d
249 _hg_status d
250 _wanted files expl 'missing files' _multi_parts / status_files
250 _wanted files expl 'missing files' _multi_parts / status_files
251 }
251 }
252
252
253 _hg_modified() {
253 _hg_modified() {
254 typeset -a status_files
254 typeset -a status_files
255 _hg_status m
255 _hg_status m
256 _wanted files expl 'modified files' _multi_parts / status_files
256 _wanted files expl 'modified files' _multi_parts / status_files
257 }
257 }
258
258
259 _hg_resolve() {
259 _hg_resolve() {
260 local rstate rpath
260 local rstate rpath
261
261
262 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
262 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
263
263
264 _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
264 _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
265 do
265 do
266 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
266 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
267 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
267 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
268 done
268 done
269 }
269 }
270
270
271 _hg_resolved() {
271 _hg_resolved() {
272 typeset -a resolved_files unresolved_files
272 typeset -a resolved_files unresolved_files
273 _hg_resolve
273 _hg_resolve
274 _wanted files expl 'resolved files' _multi_parts / resolved_files
274 _wanted files expl 'resolved files' _multi_parts / resolved_files
275 }
275 }
276
276
277 _hg_unresolved() {
277 _hg_unresolved() {
278 typeset -a resolved_files unresolved_files
278 typeset -a resolved_files unresolved_files
279 _hg_resolve
279 _hg_resolve
280 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
280 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
281 }
281 }
282
282
283 _hg_config() {
283 _hg_config() {
284 typeset -a items
284 typeset -a items
285 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
285 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
286 (( $#items )) && _describe -t config 'config item' items
286 (( $#items )) && _describe -t config 'config item' items
287 }
287 }
288
288
289 _hg_addremove() {
289 _hg_addremove() {
290 _alternative 'files:unknown files:_hg_unknown' \
290 _alternative 'files:unknown files:_hg_unknown' \
291 'files:missing files:_hg_missing'
291 'files:missing files:_hg_missing'
292 }
292 }
293
293
294 _hg_ssh_urls() {
294 _hg_ssh_urls() {
295 if [[ -prefix */ ]]
295 if [[ -prefix */ ]]
296 then
296 then
297 if zstyle -T ":completion:${curcontext}:files" remote-access
297 if zstyle -T ":completion:${curcontext}:files" remote-access
298 then
298 then
299 local host=${PREFIX%%/*}
299 local host=${PREFIX%%/*}
300 typeset -a remdirs
300 typeset -a remdirs
301 compset -p $(( $#host + 1 ))
301 compset -p $(( $#host + 1 ))
302 local rempath=${(M)PREFIX##*/}
302 local rempath=${(M)PREFIX##*/}
303 local cacheid="hg:${host}-${rempath//\//_}"
303 local cacheid="hg:${host}-${rempath//\//_}"
304 cacheid=${cacheid%[-_]}
304 cacheid=${cacheid%[-_]}
305 compset -P '*/'
305 compset -P '*/'
306 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
306 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
307 then
307 then
308 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}")"}##*/}%/})
309 _store_cache "$cacheid" remdirs
309 _store_cache "$cacheid" remdirs
310 fi
310 fi
311 _describe -t directories 'remote directory' remdirs -S/
311 _describe -t directories 'remote directory' remdirs -S/
312 else
312 else
313 _message 'remote directory'
313 _message 'remote directory'
314 fi
314 fi
315 else
315 else
316 if compset -P '*@'
316 if compset -P '*@'
317 then
317 then
318 _hosts -S/
318 _hosts -S/
319 else
319 else
320 _alternative 'hosts:remote host name:_hosts -S/' \
320 _alternative 'hosts:remote host name:_hosts -S/' \
321 'users:user:_users -S@'
321 'users:user:_users -S@'
322 fi
322 fi
323 fi
323 fi
324 }
324 }
325
325
326 _hg_urls() {
326 _hg_urls() {
327 if compset -P bundle://
327 if compset -P bundle://
328 then
328 then
329 _files
329 _files
330 elif compset -P ssh://
330 elif compset -P ssh://
331 then
331 then
332 _hg_ssh_urls
332 _hg_ssh_urls
333 elif [[ -prefix *: ]]
333 elif [[ -prefix *: ]]
334 then
334 then
335 _urls
335 _urls
336 else
336 else
337 local expl
337 local expl
338 compset -S '[^:]*'
338 compset -S '[^:]*'
339 _wanted url-schemas expl 'URL schema' compadd -S '' - \
339 _wanted url-schemas expl 'URL schema' compadd -S '' - \
340 http:// https:// ssh:// bundle://
340 http:// https:// ssh:// bundle://
341 fi
341 fi
342 }
342 }
343
343
344 _hg_paths() {
344 _hg_paths() {
345 typeset -a paths pnames
345 typeset -a paths pnames
346 _hg_cmd paths | while read -A pnames
346 _hg_cmd paths | while read -A pnames
347 do
347 do
348 paths+=($pnames[1])
348 paths+=($pnames[1])
349 done
349 done
350 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
350 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
351 }
351 }
352
352
353 _hg_remote() {
353 _hg_remote() {
354 _alternative 'path-aliases:repository alias:_hg_paths' \
354 _alternative 'path-aliases:repository alias:_hg_paths' \
355 'directories:directory:_files -/' \
355 'directories:directory:_files -/' \
356 'urls:URL:_hg_urls'
356 'urls:URL:_hg_urls'
357 }
357 }
358
358
359 _hg_clone_dest() {
359 _hg_clone_dest() {
360 _alternative 'directories:directory:_files -/' \
360 _alternative 'directories:directory:_files -/' \
361 'urls:URL:_hg_urls'
361 'urls:URL:_hg_urls'
362 }
362 }
363
363
364 # Common options
364 # Common options
365 _hg_global_opts=(
365 _hg_global_opts=(
366 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
366 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
367 '--cwd[change working directory]:new working directory:_files -/'
367 '--cwd[change working directory]:new working directory:_files -/'
368 '(--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]'
369 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
369 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
370 '*--config[set/override config option]:defined config items:_hg_config'
370 '*--config[set/override config option]:defined config items:_hg_config'
371 '(--quiet -q)'{-q,--quiet}'[suppress output]'
371 '(--quiet -q)'{-q,--quiet}'[suppress output]'
372 '(--help -h)'{-h,--help}'[display help and exit]'
372 '(--help -h)'{-h,--help}'[display help and exit]'
373 '--debug[debug mode]'
373 '--debug[debug mode]'
374 '--debugger[start debugger]'
374 '--debugger[start debugger]'
375 '--encoding[set the charset encoding]'
375 '--encoding[set the charset encoding]'
376 '--encodingmode[set the charset encoding mode]'
376 '--encodingmode[set the charset encoding mode]'
377 '--lsprof[print improved command execution profile]'
377 '--lsprof[print improved command execution profile]'
378 '--traceback[print traceback on exception]'
378 '--traceback[print traceback on exception]'
379 '--time[time how long the command takes]'
379 '--time[time how long the command takes]'
380 '--profile[profile]'
380 '--profile[profile]'
381 '--version[output version information and exit]'
381 '--version[output version information and exit]'
382 )
382 )
383
383
384 _hg_pat_opts=(
384 _hg_pat_opts=(
385 '*'{-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) -/'
386 '*'{-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) -/')
387
387
388 _hg_diff_opts=(
388 _hg_diff_opts=(
389 '(--text -a)'{-a,--text}'[treat all files as text]'
389 '(--text -a)'{-a,--text}'[treat all files as text]'
390 '(--git -g)'{-g,--git}'[use git extended diff format]'
390 '(--git -g)'{-g,--git}'[use git extended diff format]'
391 "--nodates[omit dates from diff headers]")
391 "--nodates[omit dates from diff headers]")
392
392
393 _hg_dryrun_opts=(
393 _hg_dryrun_opts=(
394 '(--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]')
395
395
396 _hg_style_opts=(
396 _hg_style_opts=(
397 '--style[display using template map file]:'
397 '--style[display using template map file]:'
398 '--template[display with template]:')
398 '--template[display with template]:')
399
399
400 _hg_commit_opts=(
400 _hg_commit_opts=(
401 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
401 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
402 '(-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:'
403 '(-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')
404
404
405 _hg_remote_opts=(
405 _hg_remote_opts=(
406 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
406 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
407 '--remotecmd[specify hg command to run on the remote side]:')
407 '--remotecmd[specify hg command to run on the remote side]:')
408
408
409 _hg_cmd() {
409 _hg_cmd() {
410 _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
411 }
411 }
412
412
413 _hg_cmd_add() {
413 _hg_cmd_add() {
414 _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 \
415 '*:unknown files:_hg_unknown'
415 '*:unknown files:_hg_unknown'
416 }
416 }
417
417
418 _hg_cmd_addremove() {
418 _hg_cmd_addremove() {
419 _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 \
420 '(--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)]:' \
421 '*:unknown or missing files:_hg_addremove'
421 '*:unknown or missing files:_hg_addremove'
422 }
422 }
423
423
424 _hg_cmd_annotate() {
424 _hg_cmd_annotate() {
425 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
425 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
426 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_labels' \
426 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_labels' \
427 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
427 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
428 '(--text -a)'{-a,--text}'[treat all files as text]' \
428 '(--text -a)'{-a,--text}'[treat all files as text]' \
429 '(--user -u)'{-u,--user}'[list the author]' \
429 '(--user -u)'{-u,--user}'[list the author]' \
430 '(--date -d)'{-d,--date}'[list the date]' \
430 '(--date -d)'{-d,--date}'[list the date]' \
431 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
431 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
432 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
432 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
433 '*:files:_hg_files'
433 '*:files:_hg_files'
434 }
434 }
435
435
436 _hg_cmd_archive() {
436 _hg_cmd_archive() {
437 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
437 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
438 '--no-decode[do not pass files through decoders]' \
438 '--no-decode[do not pass files through decoders]' \
439 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
439 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
440 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_labels' \
440 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_labels' \
441 '(--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)' \
442 '*:destination:_files'
442 '*:destination:_files'
443 }
443 }
444
444
445 _hg_cmd_backout() {
445 _hg_cmd_backout() {
446 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
446 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
447 '--merge[merge with old dirstate parent after backout]' \
447 '--merge[merge with old dirstate parent after backout]' \
448 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
448 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
449 '--parent[parent to choose when backing out merge]' \
449 '--parent[parent to choose when backing out merge]' \
450 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
450 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
451 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
451 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
452 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
452 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
453 '(--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'
454 }
454 }
455
455
456 _hg_cmd_bisect() {
456 _hg_cmd_bisect() {
457 _arguments -s -w : $_hg_global_opts \
457 _arguments -s -w : $_hg_global_opts \
458 '(-)'{-r,--reset}'[reset bisect state]' \
458 '(-)'{-r,--reset}'[reset bisect state]' \
459 '(--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 \
460 '(--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 \
461 '(--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]' \
462 '(--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 \
463 '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
463 '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
464 }
464 }
465
465
466 _hg_cmd_bookmarks() {
466 _hg_cmd_bookmarks() {
467 _arguments -s -w : $_hg_global_opts \
467 _arguments -s -w : $_hg_global_opts \
468 '(--force -f)'{-f,--force}'[force]' \
468 '(--force -f)'{-f,--force}'[force]' \
469 '(--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' \
470 '(--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]' \
471 '(--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' \
472 ':bookmark:_hg_bookmarks'
472 ':bookmark:_hg_bookmarks'
473 }
473 }
474
474
475 _hg_cmd_branch() {
475 _hg_cmd_branch() {
476 _arguments -s -w : $_hg_global_opts \
476 _arguments -s -w : $_hg_global_opts \
477 '(--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]' \
478 '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
478 '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
479 }
479 }
480
480
481 _hg_cmd_branches() {
481 _hg_cmd_branches() {
482 _arguments -s -w : $_hg_global_opts \
482 _arguments -s -w : $_hg_global_opts \
483 '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]'
483 '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]'
484 }
484 }
485
485
486 _hg_cmd_bundle() {
486 _hg_cmd_bundle() {
487 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
487 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
488 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
488 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
489 '(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' \
490 ':output file:_files' \
490 ':output file:_files' \
491 ':destination repository:_files -/'
491 ':destination repository:_files -/'
492 }
492 }
493
493
494 _hg_cmd_cat() {
494 _hg_cmd_cat() {
495 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
495 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
496 '(--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:' \
497 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
497 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
498 '*:file:_hg_files'
498 '*:file:_hg_files'
499 }
499 }
500
500
501 _hg_cmd_clone() {
501 _hg_cmd_clone() {
502 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
502 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
503 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
503 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
504 '(--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]:' \
505 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
505 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
506 ':source repository:_hg_remote' \
506 ':source repository:_hg_remote' \
507 ':destination:_hg_clone_dest'
507 ':destination:_hg_clone_dest'
508 }
508 }
509
509
510 _hg_cmd_commit() {
510 _hg_cmd_commit() {
511 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
511 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
512 '(--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]' \
513 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
513 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
514 '(--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' \
515 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
515 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
516 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
516 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
517 '*:file:_hg_files'
517 '*:file:_hg_files'
518 }
518 }
519
519
520 _hg_cmd_copy() {
520 _hg_cmd_copy() {
521 _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 \
522 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
522 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
523 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
523 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
524 '*:file:_hg_files'
524 '*:file:_hg_files'
525 }
525 }
526
526
527 _hg_cmd_diff() {
527 _hg_cmd_diff() {
528 typeset -A opt_args
528 typeset -A opt_args
529 _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 \
530 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
530 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
531 '(--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]' \
532 '(--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]' \
533 '(--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]' \
534 '(--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]' \
535 '*:file:->diff_files'
535 '*:file:->diff_files'
536
536
537 if [[ $state == 'diff_files' ]]
537 if [[ $state == 'diff_files' ]]
538 then
538 then
539 if [[ -n $opt_args[-r] ]]
539 if [[ -n $opt_args[-r] ]]
540 then
540 then
541 _hg_files
541 _hg_files
542 else
542 else
543 _hg_modified
543 _hg_modified
544 fi
544 fi
545 fi
545 fi
546 }
546 }
547
547
548 _hg_cmd_export() {
548 _hg_cmd_export() {
549 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
549 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
550 '(--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:' \
551 '--switch-parent[diff against the second parent]' \
551 '--switch-parent[diff against the second parent]' \
552 '*:revision:_hg_labels'
552 '*:revision:_hg_labels'
553 }
553 }
554
554
555 _hg_cmd_grep() {
555 _hg_cmd_grep() {
556 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
556 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
557 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
557 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
558 '--all[print all revisions with matches]' \
558 '--all[print all revisions with matches]' \
559 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
559 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
560 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
560 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
561 '(--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]' \
562 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
562 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
563 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
563 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
564 '(--user -u)'{-u,--user}'[print user who committed change]' \
564 '(--user -u)'{-u,--user}'[print user who committed change]' \
565 '1:search pattern:' \
565 '1:search pattern:' \
566 '*:files:_hg_files'
566 '*:files:_hg_files'
567 }
567 }
568
568
569 _hg_cmd_heads() {
569 _hg_cmd_heads() {
570 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
570 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
571 '(--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'
572 }
572 }
573
573
574 _hg_cmd_help() {
574 _hg_cmd_help() {
575 _arguments -s -w : $_hg_global_opts \
575 _arguments -s -w : $_hg_global_opts \
576 '*:mercurial command:_hg_commands'
576 '*:mercurial command:_hg_commands'
577 }
577 }
578
578
579 _hg_cmd_identify() {
579 _hg_cmd_identify() {
580 _arguments -s -w : $_hg_global_opts \
580 _arguments -s -w : $_hg_global_opts \
581 '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_labels' \
581 '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_labels' \
582 '(--num -n)'{-n+,--num}'[show local revision number]' \
582 '(--num -n)'{-n+,--num}'[show local revision number]' \
583 '(--id -i)'{-i+,--id}'[show global revision id]' \
583 '(--id -i)'{-i+,--id}'[show global revision id]' \
584 '(--branch -b)'{-b+,--branch}'[show branch]' \
584 '(--branch -b)'{-b+,--branch}'[show branch]' \
585 '(--tags -t)'{-t+,--tags}'[show tags]'
585 '(--tags -t)'{-t+,--tags}'[show tags]'
586 }
586 }
587
587
588 _hg_cmd_import() {
588 _hg_cmd_import() {
589 _arguments -s -w : $_hg_global_opts \
589 _arguments -s -w : $_hg_global_opts \
590 '(--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:' \
591 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
591 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
592 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
592 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
593 '*:patch:_files'
593 '*:patch:_files'
594 }
594 }
595
595
596 _hg_cmd_incoming() {
596 _hg_cmd_incoming() {
597 _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 \
598 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
598 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
599 '(--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]' \
600 '(--patch -p)'{-p,--patch}'[show patch]' \
600 '(--patch -p)'{-p,--patch}'[show patch]' \
601 '(--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' \
602 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
602 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
603 '--bundle[file to store the bundles into]:bundle file:_files' \
603 '--bundle[file to store the bundles into]:bundle file:_files' \
604 ':source:_hg_remote'
604 ':source:_hg_remote'
605 }
605 }
606
606
607 _hg_cmd_init() {
607 _hg_cmd_init() {
608 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
608 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
609 ':dir:_files -/'
609 ':dir:_files -/'
610 }
610 }
611
611
612 _hg_cmd_locate() {
612 _hg_cmd_locate() {
613 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
613 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
614 '(--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' \
615 '(--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]' \
616 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
616 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
617 '*:search pattern:_hg_files'
617 '*:search pattern:_hg_files'
618 }
618 }
619
619
620 _hg_cmd_log() {
620 _hg_cmd_log() {
621 _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 \
622 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
622 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
623 '(-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]' \
624 '(--copies -C)'{-C,--copies}'[show copied files]' \
624 '(--copies -C)'{-C,--copies}'[show copied files]' \
625 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
625 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
626 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
626 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
627 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
627 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
628 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
628 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
629 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
629 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
630 '(--patch -p)'{-p,--patch}'[show patch]' \
630 '(--patch -p)'{-p,--patch}'[show patch]' \
631 '(--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' \
632 '(--branch -b)'{-b+,--branch}'[show changesets within the given named branch]:branch:_hg_branches' \
633 '*:files:_hg_files'
633 '*:files:_hg_files'
634 }
634 }
635
635
636 _hg_cmd_manifest() {
636 _hg_cmd_manifest() {
637 _arguments -s -w : $_hg_global_opts \
637 _arguments -s -w : $_hg_global_opts \
638 ':revision:_hg_labels'
638 ':revision:_hg_labels'
639 }
639 }
640
640
641 _hg_cmd_merge() {
641 _hg_cmd_merge() {
642 _arguments -s -w : $_hg_global_opts \
642 _arguments -s -w : $_hg_global_opts \
643 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
643 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
644 '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
644 '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
645 '(--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)]' \
646 ':revision:_hg_mergerevs'
646 ':revision:_hg_mergerevs'
647 }
647 }
648
648
649 _hg_cmd_outgoing() {
649 _hg_cmd_outgoing() {
650 _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 \
651 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
651 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
652 '(--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]' \
653 '(--patch -p)'{-p,--patch}'[show patch]' \
653 '(--patch -p)'{-p,--patch}'[show patch]' \
654 '(--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]' \
655 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
655 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
656 ':destination:_hg_remote'
656 ':destination:_hg_remote'
657 }
657 }
658
658
659 _hg_cmd_parents() {
659 _hg_cmd_parents() {
660 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
660 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
661 '(--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' \
662 ':last modified file:_hg_files'
662 ':last modified file:_hg_files'
663 }
663 }
664
664
665 _hg_cmd_paths() {
665 _hg_cmd_paths() {
666 _arguments -s -w : $_hg_global_opts \
666 _arguments -s -w : $_hg_global_opts \
667 ':path:_hg_paths'
667 ':path:_hg_paths'
668 }
668 }
669
669
670 _hg_cmd_pull() {
670 _hg_cmd_pull() {
671 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
671 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
672 '(--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]' \
673 '(--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]' \
674 '(--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:' \
675 ':source:_hg_remote'
675 ':source:_hg_remote'
676 }
676 }
677
677
678 _hg_cmd_push() {
678 _hg_cmd_push() {
679 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
679 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
680 '(--force -f)'{-f,--force}'[force push]' \
680 '(--force -f)'{-f,--force}'[force push]' \
681 '(--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' \
682 ':destination:_hg_remote'
682 ':destination:_hg_remote'
683 }
683 }
684
684
685 _hg_cmd_remove() {
685 _hg_cmd_remove() {
686 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
686 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
687 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
687 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
688 '(--force -f)'{-f,--force}'[remove file even if modified]' \
688 '(--force -f)'{-f,--force}'[remove file even if modified]' \
689 '*:file:_hg_files'
689 '*:file:_hg_files'
690 }
690 }
691
691
692 _hg_cmd_rename() {
692 _hg_cmd_rename() {
693 _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 \
694 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
694 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
695 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
695 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
696 '*:file:_hg_files'
696 '*:file:_hg_files'
697 }
697 }
698
698
699 _hg_cmd_resolve() {
699 _hg_cmd_resolve() {
700 local context state line
700 local context state line
701 typeset -A opt_args
701 typeset -A opt_args
702
702
703 _arguments -s -w : $_hg_global_opts \
703 _arguments -s -w : $_hg_global_opts \
704 '(--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' \
705 '(--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' \
706 '(--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' \
707 '*:file:_hg_unresolved'
707 '*:file:_hg_unresolved'
708
708
709 if [[ $state == 'resolve_files' ]]
709 if [[ $state == 'resolve_files' ]]
710 then
710 then
711 _alternative 'files:resolved files:_hg_resolved' \
711 _alternative 'files:resolved files:_hg_resolved' \
712 'files:unresolved files:_hg_unresolved'
712 'files:unresolved files:_hg_unresolved'
713 fi
713 fi
714 }
714 }
715
715
716 _hg_cmd_revert() {
716 _hg_cmd_revert() {
717 local context state line
717 local context state line
718 typeset -A opt_args
718 typeset -A opt_args
719
719
720 _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 \
721 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
721 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
722 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_labels' \
722 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_labels' \
723 '--no-backup[do not save backup copies of files]' \
723 '--no-backup[do not save backup copies of files]' \
724 '*:file:->diff_files'
724 '*:file:->diff_files'
725
725
726 if [[ $state == 'diff_files' ]]
726 if [[ $state == 'diff_files' ]]
727 then
727 then
728 if [[ -n $opt_args[-r] ]]
728 if [[ -n $opt_args[-r] ]]
729 then
729 then
730 _hg_files
730 _hg_files
731 else
731 else
732 typeset -a status_files
732 typeset -a status_files
733 _hg_status mard
733 _hg_status mard
734 _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
735 fi
735 fi
736 fi
736 fi
737 }
737 }
738
738
739 _hg_cmd_serve() {
739 _hg_cmd_serve() {
740 _arguments -s -w : $_hg_global_opts \
740 _arguments -s -w : $_hg_global_opts \
741 '(--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' \
742 '(--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' \
743 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
743 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
744 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
744 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
745 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
745 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
746 '(--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:' \
747 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
747 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
748 '--style[web template style]:style' \
748 '--style[web template style]:style' \
749 '--stdio[for remote clients]' \
749 '--stdio[for remote clients]' \
750 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
750 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
751 }
751 }
752
752
753 _hg_cmd_showconfig() {
753 _hg_cmd_showconfig() {
754 _arguments -s -w : $_hg_global_opts \
754 _arguments -s -w : $_hg_global_opts \
755 '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
755 '(--untrusted -u)'{-u+,--untrusted}'[show untrusted configuration options]' \
756 ':config item:_hg_config'
756 ':config item:_hg_config'
757 }
757 }
758
758
759 _hg_cmd_status() {
759 _hg_cmd_status() {
760 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
760 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
761 '(--all -A)'{-A,--all}'[show status of all files]' \
761 '(--all -A)'{-A,--all}'[show status of all files]' \
762 '(--modified -m)'{-m,--modified}'[show only modified files]' \
762 '(--modified -m)'{-m,--modified}'[show only modified files]' \
763 '(--added -a)'{-a,--added}'[show only added files]' \
763 '(--added -a)'{-a,--added}'[show only added files]' \
764 '(--removed -r)'{-r,--removed}'[show only removed files]' \
764 '(--removed -r)'{-r,--removed}'[show only removed files]' \
765 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
765 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
766 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
766 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
767 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
767 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
768 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
768 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
769 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
769 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
770 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
770 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
771 '(--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]' \
772 '--rev[show difference from revision]:revision:_hg_labels' \
772 '--rev[show difference from revision]:revision:_hg_labels' \
773 '*:files:_files'
773 '*:files:_files'
774 }
774 }
775
775
776 _hg_cmd_summary() {
776 _hg_cmd_summary() {
777 _arguments -s -w : $_hg_global_opts \
777 _arguments -s -w : $_hg_global_opts \
778 '--remote[check for push and pull]'
778 '--remote[check for push and pull]'
779 }
779 }
780
780
781 _hg_cmd_tag() {
781 _hg_cmd_tag() {
782 _arguments -s -w : $_hg_global_opts \
782 _arguments -s -w : $_hg_global_opts \
783 '(--local -l)'{-l,--local}'[make the tag local]' \
783 '(--local -l)'{-l,--local}'[make the tag local]' \
784 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
784 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
785 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
785 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
786 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
786 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
787 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_labels' \
787 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_labels' \
788 ':tag name:'
788 ':tag name:'
789 }
789 }
790
790
791 _hg_cmd_tip() {
791 _hg_cmd_tip() {
792 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
792 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
793 '(--patch -p)'{-p,--patch}'[show patch]'
793 '(--patch -p)'{-p,--patch}'[show patch]'
794 }
794 }
795
795
796 _hg_cmd_unbundle() {
796 _hg_cmd_unbundle() {
797 _arguments -s -w : $_hg_global_opts \
797 _arguments -s -w : $_hg_global_opts \
798 '(--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]' \
799 ':files:_files'
799 ':files:_files'
800 }
800 }
801
801
802 _hg_cmd_update() {
802 _hg_cmd_update() {
803 _arguments -s -w : $_hg_global_opts \
803 _arguments -s -w : $_hg_global_opts \
804 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
804 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
805 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
805 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_labels' \
806 ':revision:_hg_labels'
806 ':revision:_hg_labels'
807 }
807 }
808
808
809 ## extensions ##
809 ## extensions ##
810
810
811 # HGK
811 # HGK
812 _hg_cmd_view() {
812 _hg_cmd_view() {
813 _arguments -s -w : $_hg_global_opts \
813 _arguments -s -w : $_hg_global_opts \
814 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
814 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
815 ':revision range:_hg_tags'
815 ':revision range:_hg_tags'
816 }
816 }
817
817
818 # MQ
818 # MQ
819 _hg_qseries() {
819 _hg_qseries() {
820 typeset -a patches
820 typeset -a patches
821 patches=(${(f)"$(_hg_cmd qseries)"})
821 patches=(${(f)"$(_hg_cmd qseries)"})
822 (( $#patches )) && _describe -t hg-patches 'patches' patches
822 (( $#patches )) && _describe -t hg-patches 'patches' patches
823 }
823 }
824
824
825 _hg_qapplied() {
825 _hg_qapplied() {
826 typeset -a patches
826 typeset -a patches
827 patches=(${(f)"$(_hg_cmd qapplied)"})
827 patches=(${(f)"$(_hg_cmd qapplied)"})
828 if (( $#patches ))
828 if (( $#patches ))
829 then
829 then
830 patches+=(qbase qtip)
830 patches+=(qbase qtip)
831 _describe -t hg-applied-patches 'applied patches' patches
831 _describe -t hg-applied-patches 'applied patches' patches
832 fi
832 fi
833 }
833 }
834
834
835 _hg_qunapplied() {
835 _hg_qunapplied() {
836 typeset -a patches
836 typeset -a patches
837 patches=(${(f)"$(_hg_cmd qunapplied)"})
837 patches=(${(f)"$(_hg_cmd qunapplied)"})
838 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
838 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
839 }
839 }
840
840
841 # unapplied, including guarded patches
841 # unapplied, including guarded patches
842 _hg_qdeletable() {
842 _hg_qdeletable() {
843 typeset -a unapplied
843 typeset -a unapplied
844 unapplied=(${(f)"$(_hg_cmd qseries)"})
844 unapplied=(${(f)"$(_hg_cmd qseries)"})
845 for p in $(_hg_cmd qapplied)
845 for p in $(_hg_cmd qapplied)
846 do
846 do
847 unapplied=(${unapplied:#$p})
847 unapplied=(${unapplied:#$p})
848 done
848 done
849
849
850 (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
850 (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
851 }
851 }
852
852
853 _hg_qguards() {
853 _hg_qguards() {
854 typeset -a guards
854 typeset -a guards
855 local guard
855 local guard
856 compset -P "+|-"
856 compset -P "+|-"
857 _hg_cmd qselect -s | while read guard
857 _hg_cmd qselect -s | while read guard
858 do
858 do
859 guards+=(${guard#(+|-)})
859 guards+=(${guard#(+|-)})
860 done
860 done
861 (( $#guards )) && _describe -t hg-guards 'guards' guards
861 (( $#guards )) && _describe -t hg-guards 'guards' guards
862 }
862 }
863
863
864 _hg_qseries_opts=(
864 _hg_qseries_opts=(
865 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
865 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
866
866
867 _hg_cmd_qapplied() {
867 _hg_cmd_qapplied() {
868 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
868 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
869 }
869 }
870
870
871 _hg_cmd_qdelete() {
871 _hg_cmd_qdelete() {
872 _arguments -s -w : $_hg_global_opts \
872 _arguments -s -w : $_hg_global_opts \
873 '(--keep -k)'{-k,--keep}'[keep patch file]' \
873 '(--keep -k)'{-k,--keep}'[keep patch file]' \
874 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
874 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
875 '*:unapplied patch:_hg_qdeletable'
875 '*:unapplied patch:_hg_qdeletable'
876 }
876 }
877
877
878 _hg_cmd_qdiff() {
878 _hg_cmd_qdiff() {
879 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
879 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
880 '*:pattern:_hg_files'
880 '*:pattern:_hg_files'
881 }
881 }
882
882
883 _hg_cmd_qfinish() {
884 _arguments -s -w : $_hg_global_opts \
885 '(--all -a)'{-a,--all}'[finish all patches]' \
886 '*:patch:_hg_qapplied'
887 }
888
883 _hg_cmd_qfold() {
889 _hg_cmd_qfold() {
884 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
890 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
885 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
891 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
886 '*:unapplied patch:_hg_qunapplied'
892 '*:unapplied patch:_hg_qunapplied'
887 }
893 }
888
894
889 _hg_cmd_qgoto() {
895 _hg_cmd_qgoto() {
890 _arguments -s -w : $_hg_global_opts \
896 _arguments -s -w : $_hg_global_opts \
891 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
897 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
892 ':patch:_hg_qseries'
898 ':patch:_hg_qseries'
893 }
899 }
894
900
895 _hg_cmd_qguard() {
901 _hg_cmd_qguard() {
896 _arguments -s -w : $_hg_global_opts \
902 _arguments -s -w : $_hg_global_opts \
897 '(--list -l)'{-l,--list}'[list all patches and guards]' \
903 '(--list -l)'{-l,--list}'[list all patches and guards]' \
898 '(--none -n)'{-n,--none}'[drop all guards]' \
904 '(--none -n)'{-n,--none}'[drop all guards]' \
899 ':patch:_hg_qseries' \
905 ':patch:_hg_qseries' \
900 '*:guards:_hg_qguards'
906 '*:guards:_hg_qguards'
901 }
907 }
902
908
903 _hg_cmd_qheader() {
909 _hg_cmd_qheader() {
904 _arguments -s -w : $_hg_global_opts \
910 _arguments -s -w : $_hg_global_opts \
905 ':patch:_hg_qseries'
911 ':patch:_hg_qseries'
906 }
912 }
907
913
908 _hg_cmd_qimport() {
914 _hg_cmd_qimport() {
909 _arguments -s -w : $_hg_global_opts \
915 _arguments -s -w : $_hg_global_opts \
910 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
916 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
911 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
917 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
912 '(--force -f)'{-f,--force}'[overwrite existing files]' \
918 '(--force -f)'{-f,--force}'[overwrite existing files]' \
913 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
919 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
914 '*:patch:_files'
920 '*:patch:_files'
915 }
921 }
916
922
917 _hg_cmd_qnew() {
923 _hg_cmd_qnew() {
918 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
924 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
919 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
925 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
920 ':patch:'
926 ':patch:'
921 }
927 }
922
928
923 _hg_cmd_qnext() {
929 _hg_cmd_qnext() {
924 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
930 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
925 }
931 }
926
932
927 _hg_cmd_qpop() {
933 _hg_cmd_qpop() {
928 _arguments -s -w : $_hg_global_opts \
934 _arguments -s -w : $_hg_global_opts \
929 '(--all -a :)'{-a,--all}'[pop all patches]' \
935 '(--all -a :)'{-a,--all}'[pop all patches]' \
930 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
936 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
931 '(--force -f)'{-f,--force}'[forget any local changes]' \
937 '(--force -f)'{-f,--force}'[forget any local changes]' \
932 ':patch:_hg_qapplied'
938 ':patch:_hg_qapplied'
933 }
939 }
934
940
935 _hg_cmd_qprev() {
941 _hg_cmd_qprev() {
936 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
942 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
937 }
943 }
938
944
939 _hg_cmd_qpush() {
945 _hg_cmd_qpush() {
940 _arguments -s -w : $_hg_global_opts \
946 _arguments -s -w : $_hg_global_opts \
941 '(--all -a :)'{-a,--all}'[apply all patches]' \
947 '(--all -a :)'{-a,--all}'[apply all patches]' \
942 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
948 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
943 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
949 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
944 '(--name -n)'{-n+,--name}'[merge queue name]:' \
950 '(--name -n)'{-n+,--name}'[merge queue name]:' \
945 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
951 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
946 '--move[reorder patch series and apply only the patch]' \
952 '--move[reorder patch series and apply only the patch]' \
947 ':patch:_hg_qunapplied'
953 ':patch:_hg_qunapplied'
948 }
954 }
949
955
950 _hg_cmd_qrefresh() {
956 _hg_cmd_qrefresh() {
951 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
957 _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
952 '(--git -g)'{-g,--git}'[use git extended diff format]' \
958 '(--git -g)'{-g,--git}'[use git extended diff format]' \
953 '(--short -s)'{-s,--short}'[short refresh]' \
959 '(--short -s)'{-s,--short}'[short refresh]' \
954 '*:files:_hg_files'
960 '*:files:_hg_files'
955 }
961 }
956
962
957 _hg_cmd_qrename() {
963 _hg_cmd_qrename() {
958 _arguments -s -w : $_hg_global_opts \
964 _arguments -s -w : $_hg_global_opts \
959 ':patch:_hg_qseries' \
965 ':patch:_hg_qseries' \
960 ':destination:'
966 ':destination:'
961 }
967 }
962
968
963 _hg_cmd_qselect() {
969 _hg_cmd_qselect() {
964 _arguments -s -w : $_hg_global_opts \
970 _arguments -s -w : $_hg_global_opts \
965 '(--none -n :)'{-n,--none}'[disable all guards]' \
971 '(--none -n :)'{-n,--none}'[disable all guards]' \
966 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
972 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
967 '--pop[pop to before first guarded applied patch]' \
973 '--pop[pop to before first guarded applied patch]' \
968 '--reapply[pop and reapply patches]' \
974 '--reapply[pop and reapply patches]' \
969 '*:guards:_hg_qguards'
975 '*:guards:_hg_qguards'
970 }
976 }
971
977
972 _hg_cmd_qseries() {
978 _hg_cmd_qseries() {
973 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
979 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
974 '(--missing -m)'{-m,--missing}'[print patches not in series]'
980 '(--missing -m)'{-m,--missing}'[print patches not in series]'
975 }
981 }
976
982
977 _hg_cmd_qunapplied() {
983 _hg_cmd_qunapplied() {
978 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
984 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
979 }
985 }
980
986
981 _hg_cmd_qtop() {
987 _hg_cmd_qtop() {
982 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
988 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
983 }
989 }
984
990
985 _hg_cmd_strip() {
991 _hg_cmd_strip() {
986 _arguments -s -w : $_hg_global_opts \
992 _arguments -s -w : $_hg_global_opts \
987 '(--force -f)'{-f,--force}'[force multi-head removal]' \
993 '(--force -f)'{-f,--force}'[force multi-head removal]' \
988 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
994 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
989 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
995 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
990 ':revision:_hg_labels'
996 ':revision:_hg_labels'
991 }
997 }
992
998
993 # Patchbomb
999 # Patchbomb
994 _hg_cmd_email() {
1000 _hg_cmd_email() {
995 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
1001 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
996 '(--git -g)'{-g,--git}'[use git extended diff format]' \
1002 '(--git -g)'{-g,--git}'[use git extended diff format]' \
997 '--plain[omit hg patch header]' \
1003 '--plain[omit hg patch header]' \
998 '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
1004 '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
999 '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
1005 '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
1000 '--bundlename[name of the bundle attachment file (default: bundle)]:' \
1006 '--bundlename[name of the bundle attachment file (default: bundle)]:' \
1001 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
1007 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
1002 '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
1008 '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
1003 '*--base[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
1009 '*--base[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
1004 '--intro[send an introduction email for a single patch]' \
1010 '--intro[send an introduction email for a single patch]' \
1005 '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
1011 '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
1006 '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
1012 '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
1007 '*--bcc[email addresses of blind carbon copy recipients]:email:' \
1013 '*--bcc[email addresses of blind carbon copy recipients]:email:' \
1008 '*'{-c+,--cc}'[email addresses of copy recipients]:email:' \
1014 '*'{-c+,--cc}'[email addresses of copy recipients]:email:' \
1009 '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
1015 '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
1010 '--date[use the given date as the sending date]:date:' \
1016 '--date[use the given date as the sending date]:date:' \
1011 '--desc[use the given file as the series description]:files:_files' \
1017 '--desc[use the given file as the series description]:files:_files' \
1012 '(--from -f)'{-f,--from}'[email address of sender]:email:' \
1018 '(--from -f)'{-f,--from}'[email address of sender]:email:' \
1013 '(--test -n)'{-n,--test}'[print messages that would be sent]' \
1019 '(--test -n)'{-n,--test}'[print messages that would be sent]' \
1014 '(--mbox -m)'{-m,--mbox}'[write messages to mbox file instead of sending them]:file:' \
1020 '(--mbox -m)'{-m,--mbox}'[write messages to mbox file instead of sending them]:file:' \
1015 '*--reply-to[email addresses replies should be sent to]:email:' \
1021 '*--reply-to[email addresses replies should be sent to]:email:' \
1016 '(--subject -s)'{-s,--subject}'[subject of first message (intro or single patch)]:subject:' \
1022 '(--subject -s)'{-s,--subject}'[subject of first message (intro or single patch)]:subject:' \
1017 '--in-reply-to[message identifier to reply to]:msgid:' \
1023 '--in-reply-to[message identifier to reply to]:msgid:' \
1018 '*--flag[flags to add in subject prefixes]:flag:' \
1024 '*--flag[flags to add in subject prefixes]:flag:' \
1019 '*'{-t,--to}'[email addresses of recipients]:email:' \
1025 '*'{-t,--to}'[email addresses of recipients]:email:' \
1020 ':revision:_hg_revrange'
1026 ':revision:_hg_revrange'
1021 }
1027 }
1022
1028
1023 _hg "$@"
1029 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now