##// END OF EJS Templates
zsh_completion: update all options...
av6 -
r39241:362c4603 default
parent child Browse files
Show More
@@ -1,1226 +1,1251 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 -S : $_hg_global_opts \
85 _arguments -s -S : $_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 -S : $_hg_global_opts \
122 _arguments -s -S : $_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 HGPLAINEXCEPT=alias hg debugcomplete -v | while read -A hline
142 _call_program hg HGPLAINEXCEPT=alias 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 labels=("${(f)$(_hg_cmd debugnamecomplete)}")
166 labels=("${(f)$(_hg_cmd debugnamecomplete)}")
167 (( $#labels )) && _describe -t labels 'labels' labels
167 (( $#labels )) && _describe -t labels 'labels' labels
168 }
168 }
169
169
170 _hg_bookmarks() {
170 _hg_bookmarks() {
171 typeset -a bookmark bookmarks
171 typeset -a bookmark bookmarks
172
172
173 _hg_cmd bookmarks | while read -A bookmark
173 _hg_cmd bookmarks | while read -A bookmark
174 do
174 do
175 if test -z ${bookmark[-1]:#[0-9]*}
175 if test -z ${bookmark[-1]:#[0-9]*}
176 then
176 then
177 bookmarks+=($bookmark[-2])
177 bookmarks+=($bookmark[-2])
178 fi
178 fi
179 done
179 done
180 (( $#bookmarks )) && _describe -t bookmarks 'bookmarks' bookmarks
180 (( $#bookmarks )) && _describe -t bookmarks 'bookmarks' bookmarks
181 }
181 }
182
182
183 _hg_branches() {
183 _hg_branches() {
184 typeset -a branches
184 typeset -a branches
185 local branch
185 local branch
186
186
187 _hg_cmd branches | while read branch
187 _hg_cmd branches | while read branch
188 do
188 do
189 branches+=(${branch/ #[0-9]#:*})
189 branches+=(${branch/ #[0-9]#:*})
190 done
190 done
191 (( $#branches )) && _describe -t branches 'branches' branches
191 (( $#branches )) && _describe -t branches 'branches' branches
192 }
192 }
193
193
194 # likely merge candidates
194 # likely merge candidates
195 _hg_mergerevs() {
195 _hg_mergerevs() {
196 typeset -a heads
196 typeset -a heads
197 local myrev
197 local myrev
198
198
199 heads=(${(f)"$(_hg_cmd heads --template '{rev}:{branch}\\n')"})
199 heads=(${(f)"$(_hg_cmd heads --template '{rev}:{branch}\\n')"})
200 # exclude own revision
200 # exclude own revision
201 myrev=$(_hg_cmd log -r . --template '{rev}:{branch}\\n')
201 myrev=$(_hg_cmd log -r . --template '{rev}:{branch}\\n')
202 heads=(${heads:#$myrev})
202 heads=(${heads:#$myrev})
203
203
204 (( $#heads )) && _describe -t heads 'heads' heads
204 (( $#heads )) && _describe -t heads 'heads' heads
205
205
206 branches=(${(f)"$(_hg_cmd heads --template '{branch}\\n')"})
206 branches=(${(f)"$(_hg_cmd heads --template '{branch}\\n')"})
207 # exclude own revision
207 # exclude own revision
208 myrev=$(_hg_cmd log -r . --template '{branch}\\n')
208 myrev=$(_hg_cmd log -r . --template '{branch}\\n')
209 branches=(${branches:#$myrev})
209 branches=(${branches:#$myrev})
210
210
211 (( $#branches )) && _describe -t branches 'branches' branches
211 (( $#branches )) && _describe -t branches 'branches' branches
212 }
212 }
213
213
214 _hg_files() {
214 _hg_files() {
215 if [[ -n "$_hg_root" ]]
215 if [[ -n "$_hg_root" ]]
216 then
216 then
217 [[ -d "$_hg_root/.hg" ]] || return
217 [[ -d "$_hg_root/.hg" ]] || return
218 case "$_hg_root" in
218 case "$_hg_root" in
219 /*)
219 /*)
220 _files -W $_hg_root
220 _files -W $_hg_root
221 ;;
221 ;;
222 *)
222 *)
223 _files -W $PWD/$_hg_root
223 _files -W $PWD/$_hg_root
224 ;;
224 ;;
225 esac
225 esac
226 else
226 else
227 _files
227 _files
228 fi
228 fi
229 }
229 }
230
230
231 _hg_status() {
231 _hg_status() {
232 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
232 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
233 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
233 status_files=(${(ps:\0:)"$(_hg_cmd status -0n$1 ./$PREFIX)"})
234 }
234 }
235
235
236 _hg_unknown() {
236 _hg_unknown() {
237 typeset -a status_files
237 typeset -a status_files
238 _hg_status u
238 _hg_status u
239 _wanted files expl 'unknown files' _multi_parts / status_files
239 _wanted files expl 'unknown files' _multi_parts / status_files
240 }
240 }
241
241
242 _hg_missing() {
242 _hg_missing() {
243 typeset -a status_files
243 typeset -a status_files
244 _hg_status d
244 _hg_status d
245 _wanted files expl 'missing files' _multi_parts / status_files
245 _wanted files expl 'missing files' _multi_parts / status_files
246 }
246 }
247
247
248 _hg_committable() {
248 _hg_committable() {
249 typeset -a status_files
249 typeset -a status_files
250 _hg_status mar
250 _hg_status mar
251 _wanted files expl 'modified, added or removed files' _multi_parts / status_files
251 _wanted files expl 'modified, added or removed files' _multi_parts / status_files
252 }
252 }
253
253
254 _hg_resolve() {
254 _hg_resolve() {
255 local rstate rpath
255 local rstate rpath
256
256
257 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
257 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
258
258
259 _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
259 _hg_cmd resolve -l ./$PREFIX | while read rstate rpath
260 do
260 do
261 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
261 [[ $rstate == 'R' ]] && resolved_files+=($rpath)
262 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
262 [[ $rstate == 'U' ]] && unresolved_files+=($rpath)
263 done
263 done
264 }
264 }
265
265
266 _hg_resolved() {
266 _hg_resolved() {
267 typeset -a resolved_files unresolved_files
267 typeset -a resolved_files unresolved_files
268 _hg_resolve
268 _hg_resolve
269 _wanted files expl 'resolved files' _multi_parts / resolved_files
269 _wanted files expl 'resolved files' _multi_parts / resolved_files
270 }
270 }
271
271
272 _hg_unresolved() {
272 _hg_unresolved() {
273 typeset -a resolved_files unresolved_files
273 typeset -a resolved_files unresolved_files
274 _hg_resolve
274 _hg_resolve
275 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
275 _wanted files expl 'unresolved files' _multi_parts / unresolved_files
276 }
276 }
277
277
278 _hg_config() {
278 _hg_config() {
279 typeset -a items
279 typeset -a items
280 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
280 items=(${${(%f)"$(_call_program hg hg showconfig)"}%%\=*})
281 (( $#items )) && _describe -t config 'config item' items
281 (( $#items )) && _describe -t config 'config item' items
282 }
282 }
283
283
284 _hg_addremove() {
284 _hg_addremove() {
285 _alternative 'files:unknown files:_hg_unknown' \
285 _alternative 'files:unknown files:_hg_unknown' \
286 'files:missing files:_hg_missing'
286 'files:missing files:_hg_missing'
287 }
287 }
288
288
289 _hg_ssh_urls() {
289 _hg_ssh_urls() {
290 if [[ -prefix */ ]]
290 if [[ -prefix */ ]]
291 then
291 then
292 if zstyle -T ":completion:${curcontext}:files" remote-access
292 if zstyle -T ":completion:${curcontext}:files" remote-access
293 then
293 then
294 local host=${PREFIX%%/*}
294 local host=${PREFIX%%/*}
295 typeset -a remdirs
295 typeset -a remdirs
296 compset -p $(( $#host + 1 ))
296 compset -p $(( $#host + 1 ))
297 local rempath=${(M)PREFIX##*/}
297 local rempath=${(M)PREFIX##*/}
298 local cacheid="hg:${host}-${rempath//\//_}"
298 local cacheid="hg:${host}-${rempath//\//_}"
299 cacheid=${cacheid%[-_]}
299 cacheid=${cacheid%[-_]}
300 compset -P '*/'
300 compset -P '*/'
301 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
301 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
302 then
302 then
303 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}")"}##*/}%/})
303 remdirs=(${${(M)${(f)"$(_call_program files ssh -a -x $host ls -1FL "${(q)rempath}")"}##*/}%/})
304 _store_cache "$cacheid" remdirs
304 _store_cache "$cacheid" remdirs
305 fi
305 fi
306 _describe -t directories 'remote directory' remdirs -S/
306 _describe -t directories 'remote directory' remdirs -S/
307 else
307 else
308 _message 'remote directory'
308 _message 'remote directory'
309 fi
309 fi
310 else
310 else
311 if compset -P '*@'
311 if compset -P '*@'
312 then
312 then
313 _hosts -S/
313 _hosts -S/
314 else
314 else
315 _alternative 'hosts:remote host name:_hosts -S/' \
315 _alternative 'hosts:remote host name:_hosts -S/' \
316 'users:user:_users -S@'
316 'users:user:_users -S@'
317 fi
317 fi
318 fi
318 fi
319 }
319 }
320
320
321 _hg_urls() {
321 _hg_urls() {
322 if compset -P bundle://
322 if compset -P bundle://
323 then
323 then
324 _files
324 _files
325 elif compset -P ssh://
325 elif compset -P ssh://
326 then
326 then
327 _hg_ssh_urls
327 _hg_ssh_urls
328 elif [[ -prefix *: ]]
328 elif [[ -prefix *: ]]
329 then
329 then
330 _urls
330 _urls
331 else
331 else
332 local expl
332 local expl
333 compset -S '[^:]*'
333 compset -S '[^:]*'
334 _wanted url-schemas expl 'URL schema' compadd -S '' - \
334 _wanted url-schemas expl 'URL schema' compadd -S '' - \
335 http:// https:// ssh:// bundle://
335 http:// https:// ssh:// bundle://
336 fi
336 fi
337 }
337 }
338
338
339 _hg_paths() {
339 _hg_paths() {
340 typeset -a paths pnames
340 typeset -a paths pnames
341 _hg_cmd paths | while read -A pnames
341 _hg_cmd paths | while read -A pnames
342 do
342 do
343 paths+=($pnames[1])
343 paths+=($pnames[1])
344 done
344 done
345 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
345 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
346 }
346 }
347
347
348 _hg_remote() {
348 _hg_remote() {
349 _alternative 'path-aliases:repository alias:_hg_paths' \
349 _alternative 'path-aliases:repository alias:_hg_paths' \
350 'directories:directory:_files -/' \
350 'directories:directory:_files -/' \
351 'urls:URL:_hg_urls'
351 'urls:URL:_hg_urls'
352 }
352 }
353
353
354 _hg_clone_dest() {
354 _hg_clone_dest() {
355 _alternative 'directories:directory:_files -/' \
355 _alternative 'directories:directory:_files -/' \
356 'urls:URL:_hg_urls'
356 'urls:URL:_hg_urls'
357 }
357 }
358
358
359 _hg_add_help_topics=(
359 _hg_add_help_topics=(
360 config dates diffs environment extensions filesets glossary hgignore hgweb
360 config dates diffs environment extensions filesets glossary hgignore hgweb
361 merge-tools multirevs obsolescence patterns phases revisions revsets
361 merge-tools multirevs obsolescence patterns phases revisions revsets
362 subrepos templating urls
362 subrepos templating urls
363 )
363 )
364
364
365 _hg_help_topics() {
365 _hg_help_topics() {
366 local topics
366 local topics
367 (( $#_hg_cmd_list )) || _hg_get_commands
367 (( $#_hg_cmd_list )) || _hg_get_commands
368 topics=($_hg_cmd_list $_hg_add_help_topics)
368 topics=($_hg_cmd_list $_hg_add_help_topics)
369 _describe -t help_topics 'help topics' topics
369 _describe -t help_topics 'help topics' topics
370 }
370 }
371
371
372 # Common options
372 # Common options
373 _hg_global_opts=(
373 _hg_global_opts=(
374 '(--repository -R)'{-R+,--repository=}'[repository root directory]:repository:_files -/'
374 '(--repository -R)'{-R+,--repository=}'[repository root directory or name of overlay bundle file]:repository:_files -/'
375 '--cwd[change working directory]:new working directory:_files -/'
375 '--cwd=[change working directory]:new working directory:_files -/'
376 '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
376 '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, automatically pick the first choice for all prompts]'
377 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
377 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
378 '*--config[set/override config option]:defined config items:_hg_config'
378 '*--config[set/override config option]:defined config items:_hg_config'
379 '(--quiet -q)'{-q,--quiet}'[suppress output]'
379 '(--quiet -q)'{-q,--quiet}'[suppress output]'
380 '(--help -h)'{-h,--help}'[display help and exit]'
380 '(--help -h)'{-h,--help}'[display help and exit]'
381 '--debug[debug mode]'
381 '--debug[enable debugging output]'
382 '--debugger[start debugger]'
382 '--debugger[start debugger]'
383 '--encoding[set the charset encoding]'
383 '--encoding=[set the charset encoding]:encoding'
384 '--encodingmode[set the charset encoding mode]'
384 '--encodingmode=[set the charset encoding mode]:encoding mode'
385 '--lsprof[print improved command execution profile]'
385 '--traceback[always print a traceback on exception]'
386 '--traceback[print traceback on exception]'
387 '--time[time how long the command takes]'
386 '--time[time how long the command takes]'
388 '--profile[profile]'
387 '--profile[print command execution profile]'
389 '--version[output version information and exit]'
388 '--version[output version information and exit]'
389 '--hidden[consider hidden changesets]'
390 '--color=[when to colorize]:when:(true false yes no always auto never debug)'
391 '--pager=[when to paginate (default: auto)]:when:(true false yes no always auto never)'
390 )
392 )
391
393
392 _hg_pat_opts=(
394 _hg_pat_opts=(
393 '*'{-I+,--include=}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
395 '*'{-I+,--include=}'[include names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/'
394 '*'{-X+,--exclude=}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
396 '*'{-X+,--exclude=}'[exclude names matching the given patterns]:dir:_files -W $(_hg_cmd root) -/')
395
397
396 _hg_clone_opts=(
398 _hg_clone_opts=(
397 $_hg_remote_opts
399 $_hg_remote_opts
398 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]'
400 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]'
399 '--pull[use pull protocol to copy metadata]'
401 '--pull[use pull protocol to copy metadata]'
400 '--uncompressed[use uncompressed transfer (fast over LAN)]')
402 '--uncompressed[use uncompressed transfer (fast over LAN)]')
401
403
402 _hg_date_user_opts=(
404 _hg_date_user_opts=(
403 '(--currentdate -D)'{-D,--currentdate}'[record the current date as commit date]'
405 '(--currentdate -D)'{-D,--currentdate}'[record the current date as commit date]'
404 '(--currentuser -U)'{-U,--currentuser}'[record the current user as committer]'
406 '(--currentuser -U)'{-U,--currentuser}'[record the current user as committer]'
405 '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date:'
407 '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date'
406 '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user:')
408 '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user')
407
409
408 _hg_gitlike_opts=(
410 _hg_gitlike_opts=(
409 '(--git -g)'{-g,--git}'[use git extended diff format]')
411 '(--git -g)'{-g,--git}'[use git extended diff format]')
410
412
411 _hg_diff_opts=(
413 _hg_diff_opts=(
412 $_hg_gitlike_opts
414 $_hg_gitlike_opts
413 '(--text -a)'{-a,--text}'[treat all files as text]'
415 '(--text -a)'{-a,--text}'[treat all files as text]'
414 '--nodates[omit dates from diff headers]')
416 '--nodates[omit dates from diff headers]')
415
417
416 _hg_mergetool_opts=(
418 _hg_mergetool_opts=(
417 '(--tool -t)'{-t+,--tool=}'[specify merge tool]:tool:')
419 '(--tool -t)'{-t+,--tool=}'[specify merge tool]:merge tool'
420 )
418
421
419 _hg_dryrun_opts=(
422 _hg_dryrun_opts=(
420 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
423 '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
421
424
422 _hg_ignore_space_opts=(
425 _hg_ignore_space_opts=(
423 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]'
426 '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]'
424 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]'
427 '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]'
425 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]')
428 '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]'
429 '(--ignore-space-at-eol -Z)'{-Z,--ignore-space-at-eol}'[ignore changes in whitespace at EOL]'
430 )
426
431
427 _hg_template_opts=(
432 _hg_template_opts=(
428 '--template[display with template]:template'
433 '--template[display with template]:template'
429 )
434 )
430
435
431 _hg_log_opts=(
436 _hg_log_opts=(
432 $_hg_global_opts $_hg_template_opts $_hg_gitlike_opts
437 $_hg_global_opts $_hg_template_opts $_hg_gitlike_opts
433 '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:'
438 '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit'
434 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]'
439 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]'
435 '(--patch -p)'{-p,--patch}'[show patch]'
440 '(--patch -p)'{-p,--patch}'[show patch]'
436 '--stat[output diffstat-style summary of changes]'
441 '--stat[output diffstat-style summary of changes]'
442 '(--graph -G)'{-G,--graph}'[show the revision DAG]'
437 )
443 )
438
444
439 _hg_commit_opts=(
445 _hg_commit_opts=(
440 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
446 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
441 '(-e --edit -l --logfile --message -m)'{-m+,--message=}'[use <text> as commit message]:message:'
447 '(-e --edit -l --logfile --message -m)'{-m+,--message=}'[use <text> as commit message]:message'
442 '(-e --edit -m --message --logfile -l)'{-l+,--logfile=}'[read the commit message from <file>]:log file:_files')
448 '(-e --edit -m --message --logfile -l)'{-l+,--logfile=}'[read the commit message from <file>]:log file:_files')
443
449
444 _hg_remote_opts=(
450 _hg_remote_opts=(
445 '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:'
451 '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:command'
446 '--remotecmd[specify hg command to run on the remote side]:')
452 '--remotecmd=[specify hg command to run on the remote side]:remote command'
453 '--insecure[do not verify server certificate (ignoring web.cacerts config)]'
454 )
447
455
448 _hg_branch_bmark_opts=(
456 _hg_branch_bmark_opts=(
449 '(--bookmark -B)'{-B+,--bookmark=}'[specify bookmark(s)]:bookmark:_hg_bookmarks'
457 '(--bookmark -B)'{-B+,--bookmark=}'[specify bookmark(s)]:bookmark:_hg_bookmarks'
450 '(--branch -b)'{-b+,--branch=}'[specify branch(es)]:branch:_hg_branches'
458 '(--branch -b)'{-b+,--branch=}'[specify branch(es)]:branch:_hg_branches'
451 )
459 )
452
460
453 _hg_subrepos_opts=(
461 _hg_subrepos_opts=(
454 '(--subrepos -S)'{-S,--subrepos}'[recurse into subrepositories]')
462 '(--subrepos -S)'{-S,--subrepos}'[recurse into subrepositories]')
455
463
456 _hg_cmd() {
464 _hg_cmd() {
457 _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null
465 _call_program hg HGPLAIN=1 hg "$_hg_cmd_globals[@]" "$@" 2> /dev/null
458 }
466 }
459
467
460 _hg_cmd_add() {
468 _hg_cmd_add() {
461 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \
469 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \
462 '*:unknown files:_hg_unknown'
470 '*:unknown files:_hg_unknown'
463 }
471 }
464
472
465 _hg_cmd_addremove() {
473 _hg_cmd_addremove() {
466 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
474 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
467 '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:' \
475 '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \
468 '*:unknown or missing files:_hg_addremove'
476 '*:unknown or missing files:_hg_addremove'
469 }
477 }
470
478
471 _hg_cmd_annotate() {
479 _hg_cmd_annotate() {
472 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
480 _arguments -s -S : $_hg_global_opts $_hg_ignore_space_opts $_hg_pat_opts \
473 '(--rev -r)'{-r+,--rev=}'[annotate the specified revision]:revision:_hg_labels' \
481 '(--rev -r)'{-r+,--rev=}'[annotate the specified revision]:revision:_hg_labels' \
474 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
482 "--no-follow[don't follow copies and renames]" \
475 '(--text -a)'{-a,--text}'[treat all files as text]' \
483 '(--text -a)'{-a,--text}'[treat all files as text]' \
476 '(--user -u)'{-u,--user}'[list the author]' \
484 '(--user -u)'{-u,--user}'[list the author (long with -v)]' \
477 '(--date -d)'{-d,--date}'[list the date]' \
485 '(--file -f)'{-f,--file}'[list the filename]' \
486 '(--date -d)'{-d,--date}'[list the date (short with -q)]' \
478 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
487 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
479 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
488 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
489 '(--line-number -l)'{-l,--line-number}'[show line number at the first appearance]' \
480 '*:files:_hg_files'
490 '*:files:_hg_files'
481 }
491 }
482
492
483 _hg_cmd_archive() {
493 _hg_cmd_archive() {
484 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
494 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
485 '--no-decode[do not pass files through decoders]' \
495 '--no-decode[do not pass files through decoders]' \
486 '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:' \
496 '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:prefix' \
487 '(--rev -r)'{-r+,--rev=}'[revision to distribute]:revision:_hg_labels' \
497 '(--rev -r)'{-r+,--rev=}'[revision to distribute]:revision:_hg_labels' \
488 '(--type -t)'{-t+,--type=}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
498 '(--type -t)'{-t+,--type=}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
489 '*:destination:_files'
499 '*:destination:_files'
490 }
500 }
491
501
492 _hg_cmd_backout() {
502 _hg_cmd_backout() {
493 _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
503 _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
494 '--merge[merge with old dirstate parent after backout]' \
504 '--merge[merge with old dirstate parent after backout]' \
495 '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
505 '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
496 '--parent[parent to choose when backing out merge]' \
506 '--parent[parent to choose when backing out merge]' \
497 '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
507 '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \
498 '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
508 '(--rev -r 1)'{-r+,--rev=}'[revision to backout]:revision:_hg_labels' \
499 '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text:' \
509 '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text' \
500 '(--logfile -l)'{-l+,--logfile=}'[read commit message from <file>]:log file:_files'
510 '(--logfile -l)'{-l+,--logfile=}'[read commit message from <file>]:log file:_files' \
511 ':revision:_hg_labels'
501 }
512 }
502
513
503 _hg_cmd_bisect() {
514 _hg_cmd_bisect() {
504 _arguments -s -S : $_hg_global_opts \
515 _arguments -s -S : $_hg_global_opts \
505 '(-)'{-r,--reset}'[reset bisect state]' \
516 '(-)'{-r,--reset}'[reset bisect state]' \
506 '(--extend -e)'{-e,--extend}'[extend the bisect range]' \
517 '(--extend -e)'{-e,--extend}'[extend the bisect range]' \
507 '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_labels \
518 '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_labels \
508 '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_labels \
519 '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_labels \
509 '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
520 '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
510 '(--command -c --noupdate -U)'{-c+,--command=}'[use command to check changeset state]':commands:_command_names \
521 '(--command -c --noupdate -U)'{-c+,--command=}'[use command to check changeset state]':commands:_command_names \
511 '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
522 '(--command -c --noupdate -U)'{-U,--noupdate}'[do not update to target]'
512 }
523 }
513
524
514 _hg_cmd_bookmarks() {
525 _hg_cmd_bookmarks() {
515 _arguments -s -S : $_hg_global_opts \
526 _arguments -s -S : $_hg_global_opts \
516 '(--force -f)'{-f,--force}'[force]' \
527 '(--force -f)'{-f,--force}'[force]' \
517 '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \
528 '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \
518 '(--rev -r --delete -d --rename -m)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
529 '(--rev -r --delete -d --rename -m)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
519 '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
530 '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
520 '(--rev -r --delete -d --rename -m)'{-m+,--rename=}'[rename a given bookmark]:bookmark:_hg_bookmarks' \
531 '(--rev -r --delete -d --rename -m)'{-m+,--rename=}'[rename a given bookmark]:bookmark:_hg_bookmarks' \
521 ':bookmark:_hg_bookmarks'
532 ':bookmark:_hg_bookmarks'
522 }
533 }
523
534
524 _hg_cmd_branch() {
535 _hg_cmd_branch() {
525 _arguments -s -S : $_hg_global_opts \
536 _arguments -s -S : $_hg_global_opts \
526 '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
537 '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
527 '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
538 '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
528 }
539 }
529
540
530 _hg_cmd_branches() {
541 _hg_cmd_branches() {
531 _arguments -s -S : $_hg_global_opts \
542 _arguments -s -S : $_hg_global_opts \
532 '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]' \
533 '(--closed -c)'{-c,--closed}'[show normal and closed branches]'
543 '(--closed -c)'{-c,--closed}'[show normal and closed branches]'
534 }
544 }
535
545
536 _hg_cmd_bundle() {
546 _hg_cmd_bundle() {
537 _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
547 _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
538 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
548 '(--force -f)'{-f,--force}'[run even when the destination is unrelated]' \
539 '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_labels' \
549 '(2)*--base[a base changeset assumed to be available at the destination]:revision:_hg_labels' \
540 '(--branch -b)'{-b+,--branch=}'[a specific branch to bundle]:' \
550 '*'{-b+,--branch=}'[a specific branch you would like to bundle]:branch:_hg_branches' \
541 '(--rev -r)'{-r+,--rev=}'[changeset(s) to bundle]:' \
551 '*'{-r+,--rev=}'[a changeset intended to be added to the destination]:revision:_hg_labels' \
542 '--all[bundle all changesets in the repository]' \
552 '--all[bundle all changesets in the repository]' \
553 '--type[bundle compression type to use (default: bzip2)]:bundle type' \
543 ':output file:_files' \
554 ':output file:_files' \
544 ':destination repository:_files -/'
555 ':destination repository:_files -/'
545 }
556 }
546
557
547 _hg_cmd_cat() {
558 _hg_cmd_cat() {
548 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
559 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
549 '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:filespec:' \
560 '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \
550 '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
561 '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
551 '--decode[apply any matching decode filter]' \
562 '--decode[apply any matching decode filter]' \
552 '*:file:_hg_files'
563 '*:file:_hg_files'
553 }
564 }
554
565
555 _hg_cmd_clone() {
566 _hg_cmd_clone() {
556 _arguments -s -S : $_hg_global_opts $_hg_clone_opts \
567 _arguments -s -S : $_hg_global_opts $_hg_clone_opts \
557 '(--rev -r)'{-r+,--rev=}'[a changeset you would like to have after cloning]:' \
568 '*'{-r+,--rev=}'[do not clone everything, but include this changeset and its ancestors]:revision' \
558 '(--updaterev -u)'{-u+,--updaterev=}'[revision, tag or branch to check out]:' \
569 '(--updaterev -u)'{-u+,--updaterev=}'[revision, tag or branch to check out]:revision' \
559 '(--branch -b)'{-b+,--branch=}'[clone only the specified branch]:' \
570 '*'{-b+,--branch=}"[do not clone everything, but include this branch's changesets and their ancestors]:branch" \
560 ':source repository:_hg_remote' \
571 ':source repository:_hg_remote' \
561 ':destination:_hg_clone_dest'
572 ':destination:_hg_clone_dest'
562 }
573 }
563
574
564 _hg_cmd_commit() {
575 _hg_cmd_commit() {
565 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
576 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
566 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
577 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
567 '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text:' \
578 '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text' \
568 '(--logfile -l)'{-l+,--logfile=}'[read commit message from <file>]:log file:_files' \
579 '(--logfile -l)'{-l+,--logfile=}'[read commit message from <file>]:log file:_files' \
569 '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
580 '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
570 '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
581 '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \
571 '--amend[amend the parent of the working dir]' \
582 '--amend[amend the parent of the working directory]' \
572 '--close-branch[mark a branch as closed]' \
583 '--close-branch[mark a branch head as closed]' \
584 '(--interactive -i)'{-i,--interactive}'[use interactive mode]' \
585 '(--secret -s)'{-s,--secret}'[use the secret phase for committing]' \
573 '*:file:_hg_committable'
586 '*:file:_hg_committable'
574 }
587 }
575
588
576 _hg_cmd_copy() {
589 _hg_cmd_copy() {
577 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
590 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
578 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
591 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
579 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
592 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
580 '*:file:_hg_files'
593 '*:file:_hg_files'
581 }
594 }
582
595
583 _hg_cmd_diff() {
596 _hg_cmd_diff() {
584 local context state state_descr line ret=1
597 local context state state_descr line ret=1
585 typeset -A opt_args
598 typeset -A opt_args
586
599
587 _arguments -s -S : $_hg_global_opts $_hg_diff_opts $_hg_ignore_space_opts \
600 _arguments -s -S : $_hg_global_opts $_hg_diff_opts $_hg_ignore_space_opts \
588 $_hg_pat_opts $_hg_subrepos_opts \
601 $_hg_pat_opts $_hg_subrepos_opts \
589 '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \
602 '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \
603 '--noprefix[omit a/ and b/ prefixes from filenames]' \
590 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
604 '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
591 '(--change -c)'{-c+,--change=}'[change made by revision]:' \
605 '(--change -c)'{-c+,--change=}'[change made by revision]:revision:_hg_labels' \
592 '(--text -a)'{-a,--text}'[treat all files as text]' \
606 '(--text -a)'{-a,--text}'[treat all files as text]' \
593 '--reverse[produce a diff that undoes the changes]' \
607 '--reverse[produce a diff that undoes the changes]' \
594 '(--unified -U)'{-U+,--unified=}'[number of lines of context to show]:' \
608 '(--unified -U)'{-U+,--unified=}'[number of lines of context to show]:count' \
595 '--stat[output diffstat-style summary of changes]' \
609 '--stat[output diffstat-style summary of changes]' \
610 '--root=[produce diffs relative to subdirectory]:directory:_files -/' \
596 '*:file:->diff_files' && ret=0
611 '*:file:->diff_files' && ret=0
597
612
598 if [[ $state == 'diff_files' ]]
613 if [[ $state == 'diff_files' ]]
599 then
614 then
600 if [[ -n $opt_args[-r] ]]
615 if [[ -n $opt_args[-r] ]]
601 then
616 then
602 _hg_files && ret=0
617 _hg_files && ret=0
603 else
618 else
604 _hg_committable && ret=0
619 _hg_committable && ret=0
605 fi
620 fi
606 fi
621 fi
607
622
608 return ret
623 return ret
609 }
624 }
610
625
611 _hg_cmd_export() {
626 _hg_cmd_export() {
612 _arguments -s -S : $_hg_global_opts $_hg_diff_opts \
627 _arguments -s -S : $_hg_global_opts $_hg_diff_opts \
613 '(--outout -o)'{-o+,--output=}'[print output to file with formatted name]:filespec:' \
628 '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \
614 '--switch-parent[diff against the second parent]' \
629 '--switch-parent[diff against the second parent]' \
615 '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
630 '*'{-r+,--rev=}'[revisions to export]:revision:_hg_labels' \
616 '*:revision:_hg_labels'
631 '*:revision:_hg_labels'
617 }
632 }
618
633
619 _hg_cmd_forget() {
634 _hg_cmd_forget() {
620 _arguments -s -S : $_hg_global_opts \
635 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
636 '(--interactive -i)'{-i,--interactive}'[use interactive mode]' \
621 '*:file:_hg_files'
637 '*:file:_hg_files'
622 }
638 }
623
639
624 _hg_cmd_graft() {
640 _hg_cmd_graft() {
625 _arguments -s -S : $_hg_global_opts $_hg_dryrun_opts \
641 _arguments -s -S : $_hg_global_opts $_hg_dryrun_opts \
626 $_hg_date_user_opts $_hg_mergetool_opts \
642 $_hg_date_user_opts $_hg_mergetool_opts \
627 '(--continue -c)'{-c,--continue}'[resume interrupted graft]' \
643 '*'{-r+,--rev=}'[revisions to graft]:revision:_hg_labels' \
644 '(--continue -c --abort -a)'{-c,--continue}'[resume interrupted graft]' \
645 '(--continue -c --abort -a)'{-a,--abort}'[abort interrupted graft]' \
628 '(--edit -e)'{-e,--edit}'[invoke editor on commit messages]' \
646 '(--edit -e)'{-e,--edit}'[invoke editor on commit messages]' \
629 '--log[append graft info to log message]' \
647 '--log[append graft info to log message]' \
630 '*:revision:_hg_labels'
648 '*:revision:_hg_labels'
631 }
649 }
632
650
633 _hg_cmd_grep() {
651 _hg_cmd_grep() {
634 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
652 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
635 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
653 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
636 '--all[print all revisions with matches]' \
654 '--all[print all revisions with matches]' \
637 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
655 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
638 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
656 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
639 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
657 '(--files-with-matches -l)'{-l,--files-with-matches}'[print only filenames and revs that match]' \
640 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
658 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
641 '*'{-r+,--rev=}'[search in given revision range]:revision:_hg_revrange' \
659 '*'{-r+,--rev=}'[search in given revision range]:revision:_hg_revrange' \
642 '(--user -u)'{-u,--user}'[print user who committed change]' \
660 '(--user -u)'{-u,--user}'[print user who committed change]' \
643 '(--date -d)'{-d,--date}'[print date of a changeset]' \
661 '(--date -d)'{-d,--date}'[print date of a changeset]' \
644 '1:search pattern:' \
662 '1:search pattern:' \
645 '*:files:_hg_files'
663 '*:files:_hg_files'
646 }
664 }
647
665
648 _hg_cmd_heads() {
666 _hg_cmd_heads() {
649 _arguments -s -S : $_hg_global_opts $_hg_template_opts \
667 _arguments -s -S : $_hg_global_opts $_hg_template_opts \
650 '(--topo -t)'{-t,--topo}'[show topological heads only]' \
668 '(--topo -t)'{-t,--topo}'[show topological heads only]' \
651 '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \
669 '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \
652 '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_labels'
670 '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_labels'
653 }
671 }
654
672
655 _hg_cmd_help() {
673 _hg_cmd_help() {
656 _arguments -s -S : $_hg_global_opts \
674 _arguments -s -S : $_hg_global_opts \
657 '(--extension -e)'{-e,--extension}'[show only help for extensions]' \
675 '(--extension -e)'{-e,--extension}'[show only help for extensions]' \
658 '(--command -c)'{-c,--command}'[show only help for commands]' \
676 '(--command -c)'{-c,--command}'[show only help for commands]' \
659 '(--keyword -k)'{-k+,--keyword}'[show topics matching keyword]' \
677 '(--keyword -k)'{-k,--keyword}'[show topics matching keyword]' \
660 '*:mercurial help topic:_hg_help_topics'
678 '*:mercurial help topic:_hg_help_topics'
661 }
679 }
662
680
663 _hg_cmd_identify() {
681 _hg_cmd_identify() {
664 _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
682 _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
665 '(--rev -r)'{-r+,--rev=}'[identify the specified rev]:revision:_hg_labels' \
683 '(--rev -r)'{-r+,--rev=}'[identify the specified rev]:revision:_hg_labels' \
666 '(--num -n)'{-n,--num}'[show local revision number]' \
684 '(--num -n)'{-n,--num}'[show local revision number]' \
667 '(--id -i)'{-i,--id}'[show global revision id]' \
685 '(--id -i)'{-i,--id}'[show global revision id]' \
668 '(--branch -b)'{-b,--branch}'[show branch]' \
686 '(--branch -b)'{-b,--branch}'[show branch]' \
669 '(--bookmark -B)'{-B,--bookmark}'[show bookmarks]' \
687 '(--bookmarks -B)'{-B,--bookmarks}'[show bookmarks]' \
670 '(--tags -t)'{-t,--tags}'[show tags]'
688 '(--tags -t)'{-t,--tags}'[show tags]'
671 }
689 }
672
690
673 _hg_cmd_import() {
691 _hg_cmd_import() {
674 _arguments -s -S : $_hg_global_opts $_hg_commit_opts \
692 _arguments -s -S : $_hg_global_opts $_hg_commit_opts \
675 '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count:' \
693 '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count' \
676 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
694 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
677 '--bypass[apply patch without touching the working directory]' \
695 '--bypass[apply patch without touching the working directory]' \
678 '--no-commit[do not commit, just update the working directory]' \
696 '--no-commit[do not commit, just update the working directory]' \
679 '--partial[commit even if some hunks fail]' \
697 '--partial[commit even if some hunks fail]' \
680 '--exact[apply patch to the nodes from which it was generated]' \
698 '--exact[abort if patch would apply lossily]' \
681 '--import-branch[use any branch information in patch (implied by --exact)]' \
699 '--import-branch[use any branch information in patch (implied by --exact)]' \
682 '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
700 '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
683 '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
701 '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \
684 '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:' \
702 '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \
685 '*:patch:_files'
703 '*:patch:_files'
686 }
704 }
687
705
688 _hg_cmd_incoming() {
706 _hg_cmd_incoming() {
689 _arguments -s -S : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
707 _arguments -s -S : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
690 $_hg_subrepos_opts \
708 $_hg_subrepos_opts \
691 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
709 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
692 '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:_hg_labels' \
710 '*'{-r+,--rev=}'[a remote changeset intended to be added]:revision:_hg_labels' \
693 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
711 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
694 '--bundle[file to store the bundles into]:bundle file:_files' \
712 '--bundle[file to store the bundles into]:bundle file:_files' \
695 ':source:_hg_remote'
713 ':source:_hg_remote'
696 }
714 }
697
715
698 _hg_cmd_init() {
716 _hg_cmd_init() {
699 _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
717 _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
700 ':dir:_files -/'
718 ':dir:_files -/'
701 }
719 }
702
720
703 _hg_cmd_locate() {
721 _hg_cmd_locate() {
704 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
722 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
705 '(--rev -r)'{-r+,--rev=}'[search repository as it stood at revision]:revision:_hg_labels' \
723 '(--rev -r)'{-r+,--rev=}'[search repository as it stood at revision]:revision:_hg_labels' \
706 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
724 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
707 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
725 '(--fullpath -f)'{-f,--fullpath}'[print complete paths from the filesystem root]' \
708 '*:search pattern:_hg_files'
726 '*:search pattern:_hg_files'
709 }
727 }
710
728
711 _hg_cmd_log() {
729 _hg_cmd_log() {
712 _arguments -s -S : $_hg_log_opts $_hg_pat_opts \
730 _arguments -s -S : $_hg_log_opts $_hg_pat_opts \
713 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
731 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
714 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
732 '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
715 '(--copies -C)'{-C,--copies}'[show copied files]' \
733 '(--copies -C)'{-C,--copies}'[show copied files]' \
716 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
734 '*'{-k+,--keyword=}'[search for a keyword]:keyword' \
717 '*'{-r+,--rev=}'[show the specified revision or revset]:revision:_hg_revrange' \
735 '*'{-r+,--rev=}'[show the specified revision or revset]:revision:_hg_revrange' \
718 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
736 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
719 '(--prune -P)'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_labels' \
737 '*'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_labels' \
720 '(--graph -G)'{-G,--graph}'[show the revision DAG]' \
738 '*'{-b+,--branch=}'[show changesets within the given named branch]:branch:_hg_branches' \
721 '(--branch -b)'{-b+,--branch=}'[show changesets within the given named branch]:branch:_hg_branches' \
739 '*'{-u+,--user=}'[revisions committed by user]:user' \
722 '(--user -u)'{-u+,--user=}'[revisions committed by user]:user:' \
740 '(--date -d)'{-d+,--date=}'[show revisions matching date spec]:date' \
723 '(--date -d)'{-d+,--date=}'[show revisions matching date spec]:date:' \
724 '*:files:_hg_files'
741 '*:files:_hg_files'
725 }
742 }
726
743
727 _hg_cmd_manifest() {
744 _hg_cmd_manifest() {
728 _arguments -s -S : $_hg_global_opts \
745 _arguments -s -S : $_hg_global_opts \
729 '--all[list files from all revisions]' \
746 '--all[list files from all revisions]' \
730 '(--rev -r)'{-r+,--rev=}'[revision to display]:revision:_hg_labels' \
747 '(--rev -r)'{-r+,--rev=}'[revision to display]:revision:_hg_labels' \
731 ':revision:_hg_labels'
748 ':revision:_hg_labels'
732 }
749 }
733
750
734 _hg_cmd_merge() {
751 _hg_cmd_merge() {
735 _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \
752 _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \
736 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
753 '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
737 '(--rev -r 1)'{-r+,--rev=}'[revision to merge]:revision:_hg_mergerevs' \
754 '(--rev -r 1)'{-r+,--rev=}'[revision to merge]:revision:_hg_mergerevs' \
738 '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
755 '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
739 ':revision:_hg_mergerevs'
756 ':revision:_hg_mergerevs'
740 }
757 }
741
758
742 _hg_cmd_outgoing() {
759 _hg_cmd_outgoing() {
743 _arguments -s -S : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
760 _arguments -s -S : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
744 $_hg_subrepos_opts \
761 $_hg_subrepos_opts \
745 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
762 '(--force -f)'{-f,--force}'[run even when the destination is unrelated]' \
746 '*'{-r+,--rev=}'[a specific revision you would like to push]:revision:_hg_revrange' \
763 '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_revrange' \
747 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
764 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
748 ':destination:_hg_remote'
765 ':destination:_hg_remote'
749 }
766 }
750
767
751 _hg_cmd_parents() {
768 _hg_cmd_parents() {
752 _arguments -s -S : $_hg_global_opts $_hg_template_opts \
769 _arguments -s -S : $_hg_global_opts $_hg_template_opts \
753 '(--rev -r)'{-r+,--rev=}'[show parents of the specified rev]:revision:_hg_labels' \
770 '(--rev -r)'{-r+,--rev=}'[show parents of the specified rev]:revision:_hg_labels' \
754 ':last modified file:_hg_files'
771 ':last modified file:_hg_files'
755 }
772 }
756
773
757 _hg_cmd_paths() {
774 _hg_cmd_paths() {
758 _arguments -s -S : $_hg_global_opts \
775 _arguments -s -S : $_hg_global_opts \
759 ':path:_hg_paths'
776 ':path:_hg_paths'
760 }
777 }
761
778
762 _hg_cmd_phase() {
779 _hg_cmd_phase() {
763 _arguments -s -S : $_hg_global_opts \
780 _arguments -s -S : $_hg_global_opts \
764 '(--public -p)'{-p,--public}'[set changeset phase to public]' \
781 '(--public -p --draft -d --secret -s)'{-p,--public}'[set changeset phase to public]' \
765 '(--draft -d)'{-d,--draft}'[set changeset phase to draft]' \
782 '(--public -p --draft -d --secret -s)'{-d,--draft}'[set changeset phase to draft]' \
766 '(--secret -s)'{-s,--secret}'[set changeset phase to secret]' \
783 '(--public -p --draft -d --secret -s)'{-s,--secret}'[set changeset phase to secret]' \
767 '(--force -f)'{-f,--force}'[allow to move boundary backward]' \
784 '(--force -f)'{-f,--force}'[allow to move boundary backward]' \
768 '(--rev -r)'{-r+,--rev=}'[target revision]:revision:_hg_labels' \
785 '*'{-r+,--rev=}'[target revision]:revision:_hg_labels' \
769 ':revision:_hg_labels'
786 '*:revision:_hg_labels'
770 }
787 }
771
788
772 _hg_cmd_pull() {
789 _hg_cmd_pull() {
773 _arguments -s -S : $_hg_global_opts $_hg_branch_bmark_opts $_hg_remote_opts \
790 _arguments -s -S : $_hg_global_opts $_hg_branch_bmark_opts $_hg_remote_opts \
774 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
791 '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
775 '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
792 '(--update -u)'{-u,--update}'[update to new branch head if new descendants were pulled]' \
776 '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:' \
793 '*'{-r+,--rev=}'[a remote changeset intended to be added]:revision:_hg_labels' \
777 ':source:_hg_remote'
794 ':source:_hg_remote'
778 }
795 }
779
796
780 _hg_cmd_push() {
797 _hg_cmd_push() {
781 _arguments -s -S : $_hg_global_opts $_hg_branch_bmark_opts $_hg_remote_opts \
798 _arguments -s -S : $_hg_global_opts $_hg_branch_bmark_opts $_hg_remote_opts \
782 '(--force -f)'{-f,--force}'[force push]' \
799 '(--force -f)'{-f,--force}'[force push]' \
783 '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]:revision:_hg_labels' \
800 '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_labels' \
784 '--new-branch[allow pushing a new branch]' \
801 '--new-branch[allow pushing a new branch]' \
785 ':destination:_hg_remote'
802 ':destination:_hg_remote'
786 }
803 }
787
804
788 _hg_cmd_remove() {
805 _hg_cmd_remove() {
789 _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
806 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
790 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
807 '(--after -A)'{-A,--after}'[record delete for missing files]' \
791 '(--force -f)'{-f,--force}'[remove file even if modified]' \
808 '(--force -f)'{-f,--force}'[forget added files, delete modified files]' \
792 '*:file:_hg_files'
809 '*:file:_hg_files'
793 }
810 }
794
811
795 _hg_cmd_rename() {
812 _hg_cmd_rename() {
796 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
813 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
797 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
814 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
798 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
815 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
799 '*:file:_hg_files'
816 '*:file:_hg_files'
800 }
817 }
801
818
802 _hg_cmd_resolve() {
819 _hg_cmd_resolve() {
803 local context state state_descr line ret=1
820 local context state state_descr line ret=1
804 typeset -A opt_args
821 typeset -A opt_args
805
822
806 _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
823 _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
807 '(--all -a)'{-a,--all}'[select all unresolved files]' \
824 '(--all -a)'{-a,--all}'[select all unresolved files]' \
808 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
825 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
809 '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
826 '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \
810 '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
827 '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \
811 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \
828 '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[mark files as unresolved]:*:resolved files:_hg_resolved' \
812 '*:file:_hg_unresolved' && ret=0
829 '*:file:_hg_unresolved' && ret=0
813
830
814 if [[ $state == 'resolve_files' ]]
831 if [[ $state == 'resolve_files' ]]
815 then
832 then
816 _alternative 'files:resolved files:_hg_resolved' \
833 _alternative 'files:resolved files:_hg_resolved' \
817 'files:unresolved files:_hg_unresolved' && ret=0
834 'files:unresolved files:_hg_unresolved' && ret=0
818 fi
835 fi
819
836
820 return ret
837 return ret
821 }
838 }
822
839
823 _hg_cmd_revert() {
840 _hg_cmd_revert() {
824 local context state state_descr line ret=1
841 local context state state_descr line ret=1
825 typeset -A opt_args
842 typeset -A opt_args
826
843
827 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
844 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
828 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
845 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
829 '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_labels' \
846 '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_labels' \
830 '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
847 '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
831 '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date code:' \
848 '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \
849 '(--interactive -i)'{-i,--interactive}'[interactively select the changes]' \
832 '*:file:->revert_files' && ret=0
850 '*:file:->revert_files' && ret=0
833
851
834 if [[ $state == 'revert_files' ]]
852 if [[ $state == 'revert_files' ]]
835 then
853 then
836 if [[ -n $opt_args[-r] ]]
854 if [[ -n $opt_args[-r] ]]
837 then
855 then
838 _hg_files && ret=0
856 _hg_files && ret=0
839 else
857 else
840 typeset -a status_files
858 typeset -a status_files
841 _hg_status mard
859 _hg_status mard
842 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files && ret=0
860 _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files && ret=0
843 fi
861 fi
844 fi
862 fi
845
863
846 return ret
864 return ret
847 }
865 }
848
866
849 _hg_cmd_rollback() {
867 _hg_cmd_rollback() {
850 _arguments -s -S : $_hg_global_opts $_hg_dryrun_opts \
868 _arguments -s -S : $_hg_global_opts $_hg_dryrun_opts \
851 '(--force -f)'{-f,--force}'[ignore safety measures]' \
869 '(--force -f)'{-f,--force}'[ignore safety measures]' \
852 }
870 }
853
871
854 _hg_cmd_serve() {
872 _hg_cmd_serve() {
855 _arguments -s -S : $_hg_global_opts \
873 _arguments -s -S : $_hg_global_opts \
856 '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file]:log file:_files' \
874 '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file to write to]:log file:_files' \
857 '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file]:log file:_files' \
875 '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file to write to]:log file:_files' \
858 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
876 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
859 '(--port -p)'{-p+,--port=}'[listen port]:listen port:' \
877 '(--port -p)'{-p+,--port=}'[port to listen on (default: 8000)]:listen port' \
860 '(--address -a)'{-a+,--address=}'[interface address]:interface address:' \
878 '(--address -a)'{-a+,--address=}'[address to listen on (default: all interfaces)]:interface address' \
861 '--prefix[prefix path to serve from]:directory:_files' \
879 '--prefix=[prefix path to serve from (default: server root)]:directory:_files' \
862 '(--name -n)'{-n+,--name=}'[name to show in web pages]:repository name:' \
880 '(--name -n)'{-n+,--name=}'[name to show in web pages (default: working directory)]:repository name' \
863 '--web-conf[name of the hgweb config file]:webconf_file:_files' \
881 '--web-conf=[name of the hgweb config file]:config file:_files' \
864 '--pid-file[name of file to write process ID to]:pid_file:_files' \
882 '--pid-file=[name of file to write process ID to]:pid file:_files' \
865 '--cmdserver[cmdserver mode]:mode:' \
883 '--cmdserver[for remote clients]' \
866 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
884 '(--templates -t)'{-t+,--templates=}'[web template directory]:template dir:_files -/' \
867 '--style[web template style]:style' \
885 '--style=[template style to use]:style' \
868 '--stdio[for remote clients]' \
886 '--stdio[for remote clients]' \
869 '--certificate[certificate file]:cert_file:_files' \
887 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]' \
870 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
888 '--certificate=[SSL certificate file]:certificate file:_files' \
889 '--print-url[start and print only the URL]'
871 }
890 }
872
891
873 _hg_cmd_showconfig() {
892 _hg_cmd_showconfig() {
874 _arguments -s -S : $_hg_global_opts \
893 _arguments -s -S : $_hg_global_opts \
875 '(--untrusted -u)'{-u,--untrusted}'[show untrusted configuration options]' \
894 '(--untrusted -u)'{-u,--untrusted}'[show untrusted configuration options]' \
876 ':config item:_hg_config'
895 '(--edit -e)'{-e,--edit}'[edit user config]' \
896 '(--local -l --global -g)'{-l,--local}'[edit repository config]' \
897 '(--local -l --global -g)'{-g,--global}'[edit global config]' \
898 '*:config item:_hg_config'
877 }
899 }
878
900
879 _hg_cmd_status() {
901 _hg_cmd_status() {
880 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
902 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
881 '(--all -A)'{-A,--all}'[show status of all files]' \
903 '(--all -A)'{-A,--all}'[show status of all files]' \
882 '(--modified -m)'{-m,--modified}'[show only modified files]' \
904 '(--modified -m)'{-m,--modified}'[show only modified files]' \
883 '(--added -a)'{-a,--added}'[show only added files]' \
905 '(--added -a)'{-a,--added}'[show only added files]' \
884 '(--removed -r)'{-r,--removed}'[show only removed files]' \
906 '(--removed -r)'{-r,--removed}'[show only removed files]' \
885 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
907 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
886 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
908 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
887 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
909 '(--unknown -u)'{-u,--unknown}'[show only unknown (not tracked) files]' \
888 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
910 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
889 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
911 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
890 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
912 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
891 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
913 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
892 '--rev[show difference from revision]:revision:_hg_labels' \
914 '*--rev=[show difference from revision]:revision:_hg_labels' \
893 '--change[list the changed files of a revision]:revision:_hg_labels' \
915 '--change=[list the changed files of a revision]:revision:_hg_labels' \
894 '*:files:_files'
916 '*:files:_files'
895 }
917 }
896
918
897 _hg_cmd_summary() {
919 _hg_cmd_summary() {
898 _arguments -s -S : $_hg_global_opts \
920 _arguments -s -S : $_hg_global_opts \
899 '--remote[check for push and pull]'
921 '--remote[check for push and pull]'
900 }
922 }
901
923
902 _hg_cmd_tag() {
924 _hg_cmd_tag() {
903 _arguments -s -S : $_hg_global_opts \
925 _arguments -s -S : $_hg_global_opts \
904 '(--local -l)'{-l,--local}'[make the tag local]' \
926 '(--local -l)'{-l,--local}'[make the tag local]' \
905 '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message:' \
927 '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message' \
906 '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
928 '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
907 '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
929 '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \
908 '(--rev -r)'{-r+,--rev=}'[revision to tag]:revision:_hg_labels' \
930 '(--rev -r)'{-r+,--rev=}'[revision to tag]:revision:_hg_labels' \
909 '(--force -f)'{-f,--force}'[force tag]' \
931 '(--force -f)'{-f,--force}'[force tag]' \
910 '--remove[remove a tag]' \
932 '--remove[remove a tag]' \
911 '(--edit -e)'{-e,--edit}'[edit commit message]' \
933 '(--edit -e)'{-e,--edit}'[edit commit message]' \
912 ':tag name:'
934 ':tag name:'
913 }
935 }
914
936
915 _hg_cmd_tip() {
937 _hg_cmd_tip() {
916 _arguments -s -S : $_hg_global_opts $_hg_gitlike_opts $_hg_template_opts \
938 _arguments -s -S : $_hg_global_opts $_hg_gitlike_opts $_hg_template_opts \
917 '(--patch -p)'{-p,--patch}'[show patch]'
939 '(--patch -p)'{-p,--patch}'[show patch]'
918 }
940 }
919
941
920 _hg_cmd_unbundle() {
942 _hg_cmd_unbundle() {
921 _arguments -s -S : $_hg_global_opts \
943 _arguments -s -S : $_hg_global_opts \
922 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
944 '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
923 ':files:_files'
945 '*:files:_files'
924 }
946 }
925
947
926 _hg_cmd_update() {
948 _hg_cmd_update() {
927 _arguments -s -S : $_hg_global_opts \
949 _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \
928 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
950 '(--clean -C)'{-C,--clean}'[discard uncommitted changes (no backup)]' \
929 '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
951 '(--check -c)'{-c,--check}'[require clean working directory]' \
930 '(--check -c)'{-c,--check}'[update across branches if no uncommitted changes]' \
952 '(--merge -m)'{-m,--merge}'[merge uncommitted changes]' \
931 '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:' \
953 '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \
954 '(--rev -r 1)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
932 ':revision:_hg_labels'
955 ':revision:_hg_labels'
933 }
956 }
934
957
935 ## extensions ##
958 ## extensions ##
936
959
937 # HGK
960 # HGK
938 _hg_cmd_view() {
961 _hg_cmd_view() {
939 _arguments -s -S : $_hg_global_opts \
962 _arguments -s -S : $_hg_global_opts \
940 '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \
963 '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \
941 ':revision range:_hg_labels'
964 ':revision range:_hg_labels'
942 }
965 }
943
966
944 # MQ
967 # MQ
945 _hg_qseries() {
968 _hg_qseries() {
946 typeset -a patches
969 typeset -a patches
947 patches=(${(f)"$(_hg_cmd qseries)"})
970 patches=(${(f)"$(_hg_cmd qseries)"})
948 (( $#patches )) && _describe -t hg-patches 'patches' patches
971 (( $#patches )) && _describe -t hg-patches 'patches' patches
949 }
972 }
950
973
951 _hg_qapplied() {
974 _hg_qapplied() {
952 typeset -a patches
975 typeset -a patches
953 patches=(${(f)"$(_hg_cmd qapplied)"})
976 patches=(${(f)"$(_hg_cmd qapplied)"})
954 if (( $#patches ))
977 if (( $#patches ))
955 then
978 then
956 patches+=(qbase qtip)
979 patches+=(qbase qtip)
957 _describe -t hg-applied-patches 'applied patches' patches
980 _describe -t hg-applied-patches 'applied patches' patches
958 fi
981 fi
959 }
982 }
960
983
961 _hg_qunapplied() {
984 _hg_qunapplied() {
962 typeset -a patches
985 typeset -a patches
963 patches=(${(f)"$(_hg_cmd qunapplied)"})
986 patches=(${(f)"$(_hg_cmd qunapplied)"})
964 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
987 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
965 }
988 }
966
989
967 # unapplied, including guarded patches
990 # unapplied, including guarded patches
968 _hg_qdeletable() {
991 _hg_qdeletable() {
969 typeset -a unapplied
992 typeset -a unapplied
970 unapplied=(${(f)"$(_hg_cmd qseries)"})
993 unapplied=(${(f)"$(_hg_cmd qseries)"})
971 for p in $(_hg_cmd qapplied)
994 for p in $(_hg_cmd qapplied)
972 do
995 do
973 unapplied=(${unapplied:#$p})
996 unapplied=(${unapplied:#$p})
974 done
997 done
975
998
976 (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
999 (( $#unapplied )) && _describe -t hg-allunapplied-patches 'all unapplied patches' unapplied
977 }
1000 }
978
1001
979 _hg_qguards() {
1002 _hg_qguards() {
980 typeset -a guards
1003 typeset -a guards
981 local guard
1004 local guard
982 compset -P "+|-"
1005 compset -P "+|-"
983 _hg_cmd qselect -s | while read guard
1006 _hg_cmd qselect -s | while read guard
984 do
1007 do
985 guards+=(${guard#(+|-)})
1008 guards+=(${guard#(+|-)})
986 done
1009 done
987 (( $#guards )) && _describe -t hg-guards 'guards' guards
1010 (( $#guards )) && _describe -t hg-guards 'guards' guards
988 }
1011 }
989
1012
990 _hg_qseries_opts=(
1013 _hg_qseries_opts=(
991 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
1014 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
992
1015
993 _hg_cmd_qapplied() {
1016 _hg_cmd_qapplied() {
994 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \
1017 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \
995 '(--last -1)'{-1,--last}'[show only the preceding applied patch]' \
1018 '(--last -1)'{-1,--last}'[show only the preceding applied patch]' \
996 '*:patch:_hg_qapplied'
1019 '*:patch:_hg_qapplied'
997 }
1020 }
998
1021
999 _hg_cmd_qclone() {
1022 _hg_cmd_qclone() {
1000 _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_clone_opts \
1023 _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_clone_opts \
1001 '(--patches -p)'{-p+,--patches=}'[location of source patch repository]:' \
1024 '(--patches -p)'{-p+,--patches=}'[location of source patch repository]:' \
1002 ':source repository:_hg_remote' \
1025 ':source repository:_hg_remote' \
1003 ':destination:_hg_clone_dest'
1026 ':destination:_hg_clone_dest'
1004 }
1027 }
1005
1028
1006 _hg_cmd_qdelete() {
1029 _hg_cmd_qdelete() {
1007 _arguments -s -S : $_hg_global_opts \
1030 _arguments -s -S : $_hg_global_opts \
1008 '(--keep -k)'{-k,--keep}'[keep patch file]' \
1031 '(--keep -k)'{-k,--keep}'[keep patch file]' \
1009 '*'{-r+,--rev=}'[stop managing a revision]:applied patch:_hg_revrange' \
1032 '*'{-r+,--rev=}'[stop managing a revision]:applied patch:_hg_revrange' \
1010 '*:unapplied patch:_hg_qdeletable'
1033 '*:unapplied patch:_hg_qdeletable'
1011 }
1034 }
1012
1035
1013 _hg_cmd_qdiff() {
1036 _hg_cmd_qdiff() {
1014 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
1037 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
1015 $_hg_ignore_space_opts \
1038 $_hg_ignore_space_opts \
1016 '*:pattern:_hg_files'
1039 '*:pattern:_hg_files'
1017 }
1040 }
1018
1041
1019 _hg_cmd_qfinish() {
1042 _hg_cmd_qfinish() {
1020 _arguments -s -S : $_hg_global_opts \
1043 _arguments -s -S : $_hg_global_opts \
1021 '(--applied -a)'{-a,--applied}'[finish all applied patches]' \
1044 '(--applied -a)'{-a,--applied}'[finish all applied patches]' \
1022 '*:patch:_hg_qapplied'
1045 '*:patch:_hg_qapplied'
1023 }
1046 }
1024
1047
1025 _hg_cmd_qfold() {
1048 _hg_cmd_qfold() {
1026 _arguments -s -S : $_hg_global_opts $_h_commit_opts \
1049 _arguments -s -S : $_hg_global_opts $_h_commit_opts \
1027 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
1050 '(--keep -k)'{-k,--keep}'[keep folded patch files]' \
1028 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
1051 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
1029 '--no-backup[do not save backup copies of files]' \
1052 '--no-backup[do not save backup copies of files]' \
1030 '*:unapplied patch:_hg_qunapplied'
1053 '*:unapplied patch:_hg_qunapplied'
1031 }
1054 }
1032
1055
1033 _hg_cmd_qgoto() {
1056 _hg_cmd_qgoto() {
1034 _arguments -s -S : $_hg_global_opts \
1057 _arguments -s -S : $_hg_global_opts \
1035 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
1058 '(--force -f)'{-f,--force}'[overwrite any local changes]' \
1036 '--keep-changes[tolerate non-conflicting local changes]' \
1059 '--keep-changes[tolerate non-conflicting local changes]' \
1037 ':patch:_hg_qseries'
1060 ':patch:_hg_qseries'
1038 }
1061 }
1039
1062
1040 _hg_cmd_qguard() {
1063 _hg_cmd_qguard() {
1041 _arguments -s -S : $_hg_global_opts \
1064 _arguments -s -S : $_hg_global_opts \
1042 '(--list -l)'{-l,--list}'[list all patches and guards]' \
1065 '(--list -l)'{-l,--list}'[list all patches and guards]' \
1043 '(--none -n)'{-n,--none}'[drop all guards]' \
1066 '(--none -n)'{-n,--none}'[drop all guards]' \
1044 ':patch:_hg_qseries' \
1067 ':patch:_hg_qseries' \
1045 '*:guards:_hg_qguards'
1068 '*:guards:_hg_qguards'
1046 }
1069 }
1047
1070
1048 _hg_cmd_qheader() {
1071 _hg_cmd_qheader() {
1049 _arguments -s -S : $_hg_global_opts \
1072 _arguments -s -S : $_hg_global_opts \
1050 ':patch:_hg_qseries'
1073 ':patch:_hg_qseries'
1051 }
1074 }
1052
1075
1053 _hg_cmd_qimport() {
1076 _hg_cmd_qimport() {
1054 _arguments -s -S : $_hg_global_opts $_hg_gitlike_opts \
1077 _arguments -s -S : $_hg_global_opts $_hg_gitlike_opts \
1055 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
1078 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
1056 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
1079 '(--name -n 2)'{-n+,--name}'[patch file name]:name' \
1057 '(--force -f)'{-f,--force}'[overwrite existing files]' \
1080 '(--force -f)'{-f,--force}'[overwrite existing files]' \
1058 '*'{-r+,--rev=}'[place existing revisions under mq control]:revision:_hg_revrange' \
1081 '*'{-r+,--rev=}'[place existing revisions under mq control]:revision:_hg_revrange' \
1059 '(--push -P)'{-P,--push}'[qpush after importing]' \
1082 '(--push -P)'{-P,--push}'[qpush after importing]' \
1060 '*:patch:_files'
1083 '*:patch:_files'
1061 }
1084 }
1062
1085
1063 _hg_cmd_qnew() {
1086 _hg_cmd_qnew() {
1064 _arguments -s -S : $_hg_global_opts $_hg_commit_opts $_hg_date_user_opts $_hg_gitlike_opts \
1087 _arguments -s -S : $_hg_global_opts $_hg_commit_opts $_hg_date_user_opts $_hg_gitlike_opts \
1065 ':patch:'
1088 ':patch:'
1066 }
1089 }
1067
1090
1068 _hg_cmd_qnext() {
1091 _hg_cmd_qnext() {
1069 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
1092 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
1070 }
1093 }
1071
1094
1072 _hg_cmd_qpop() {
1095 _hg_cmd_qpop() {
1073 _arguments -s -S : $_hg_global_opts \
1096 _arguments -s -S : $_hg_global_opts \
1074 '(--all -a :)'{-a,--all}'[pop all patches]' \
1097 '(--all -a :)'{-a,--all}'[pop all patches]' \
1075 '(--force -f)'{-f,--force}'[forget any local changes]' \
1098 '(--force -f)'{-f,--force}'[forget any local changes]' \
1076 '--keep-changes[tolerate non-conflicting local changes]' \
1099 '--keep-changes[tolerate non-conflicting local changes]' \
1077 '--no-backup[do not save backup copies of files]' \
1100 '--no-backup[do not save backup copies of files]' \
1078 ':patch:_hg_qapplied'
1101 ':patch:_hg_qapplied'
1079 }
1102 }
1080
1103
1081 _hg_cmd_qprev() {
1104 _hg_cmd_qprev() {
1082 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
1105 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
1083 }
1106 }
1084
1107
1085 _hg_cmd_qpush() {
1108 _hg_cmd_qpush() {
1086 _arguments -s -S : $_hg_global_opts \
1109 _arguments -s -S : $_hg_global_opts \
1087 '(--all -a :)'{-a,--all}'[apply all patches]' \
1110 '(--all -a :)'{-a,--all}'[apply all patches]' \
1088 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
1111 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
1089 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
1112 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
1090 '(--exact -e)'{-e,--exact}'[apply the target patch to its recorded parent]' \
1113 '(--exact -e)'{-e,--exact}'[apply the target patch to its recorded parent]' \
1091 '--move[reorder patch series and apply only the patch]' \
1114 '--move[reorder patch series and apply only the patch]' \
1092 '--keep-changes[tolerate non-conflicting local changes]' \
1115 '--keep-changes[tolerate non-conflicting local changes]' \
1093 '--no-backup[do not save backup copies of files]' \
1116 '--no-backup[do not save backup copies of files]' \
1094 ':patch:_hg_qunapplied'
1117 ':patch:_hg_qunapplied'
1095 }
1118 }
1096
1119
1097 _hg_cmd_qrefresh() {
1120 _hg_cmd_qrefresh() {
1098 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts $_hg_gitlike_opts \
1121 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts $_hg_gitlike_opts \
1099 '(--short -s)'{-s,--short}'[short refresh]' \
1122 '(--short -s)'{-s,--short}'[short refresh]' \
1100 '*:files:_hg_files'
1123 '*:files:_hg_files'
1101 }
1124 }
1102
1125
1103 _hg_cmd_qrename() {
1126 _hg_cmd_qrename() {
1104 _arguments -s -S : $_hg_global_opts \
1127 _arguments -s -S : $_hg_global_opts \
1105 ':patch:_hg_qunapplied' \
1128 ':patch:_hg_qunapplied' \
1106 ':destination:'
1129 ':destination:'
1107 }
1130 }
1108
1131
1109 _hg_cmd_qselect() {
1132 _hg_cmd_qselect() {
1110 _arguments -s -S : $_hg_global_opts \
1133 _arguments -s -S : $_hg_global_opts \
1111 '(--none -n :)'{-n,--none}'[disable all guards]' \
1134 '(--none -n :)'{-n,--none}'[disable all guards]' \
1112 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
1135 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
1113 '--pop[pop to before first guarded applied patch]' \
1136 '--pop[pop to before first guarded applied patch]' \
1114 '--reapply[pop and reapply patches]' \
1137 '--reapply[pop and reapply patches]' \
1115 '*:guards:_hg_qguards'
1138 '*:guards:_hg_qguards'
1116 }
1139 }
1117
1140
1118 _hg_cmd_qseries() {
1141 _hg_cmd_qseries() {
1119 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \
1142 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \
1120 '(--missing -m)'{-m,--missing}'[print patches not in series]'
1143 '(--missing -m)'{-m,--missing}'[print patches not in series]'
1121 }
1144 }
1122
1145
1123 _hg_cmd_qunapplied() {
1146 _hg_cmd_qunapplied() {
1124 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \
1147 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \
1125 '(--first -1)'{-1,--first}'[show only the first patch]'
1148 '(--first -1)'{-1,--first}'[show only the first patch]'
1126 }
1149 }
1127
1150
1128 _hg_cmd_qtop() {
1151 _hg_cmd_qtop() {
1129 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
1152 _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
1130 }
1153 }
1131
1154
1132 _hg_cmd_strip() {
1155 _hg_cmd_strip() {
1133 _arguments -s -S : $_hg_global_opts \
1156 _arguments -s -S : $_hg_global_opts \
1134 '(--force -f)'{-f,--force}'[force removal, discard uncommitted changes, no backup]' \
1157 '(--force -f)'{-f,--force}'[force removal of changesets, discard uncommitted changes (no backup)]' \
1135 '(--no-backup -n)'{-n,--no-backup}'[no backups]' \
1158 '--no-backup[no backups]' \
1136 '(--keep -k)'{-k,--keep}'[do not modify working copy during strip]' \
1159 '(--keep -k)'{-k,--keep}'[do not modify working directory during strip]' \
1137 '(--bookmark -B)'{-B+,--bookmark=}'[remove revs only reachable from given bookmark]:bookmark:_hg_bookmarks' \
1160 '*'{-B+,--bookmark=}'[remove revs only reachable from given bookmark]:bookmark:_hg_bookmarks' \
1138 '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_labels' \
1161 '*'{-r+,--rev=}'[revision]:revision:_hg_labels' \
1139 ':revision:_hg_labels'
1162 '*:revision:_hg_labels'
1140 }
1163 }
1141
1164
1142 # Patchbomb
1165 # Patchbomb
1143 _hg_cmd_email() {
1166 _hg_cmd_email() {
1144 _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_gitlike_opts \
1167 _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_gitlike_opts \
1145 '--plain[omit hg patch header]' \
1168 '--plain[omit hg patch header]' \
1146 '--body[send patches as inline message text (default)]' \
1169 '--body[send patches as inline message text (default)]' \
1147 '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
1170 '(--outgoing -o)'{-o,--outgoing}'[send changes not found in the target repository]' \
1148 '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
1171 '(--bundle -b)'{-b,--bundle}'[send changes not in target as a binary bundle]' \
1149 '--bundlename[name of the bundle attachment file (default: bundle)]:' \
1172 '--bundlename[name of the bundle attachment file (default: bundle)]:' \
1150 '*'{-r+,--rev=}'[search in given revision range]:revision:_hg_revrange' \
1173 '*'{-r+,--rev=}'[search in given revision range]:revision:_hg_revrange' \
1151 '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
1174 '--force[run even when remote repository is unrelated (with -b/--bundle)]' \
1152 '*--base[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
1175 '*--base=[a base changeset to specify instead of a destination (with -b/--bundle)]:revision:_hg_labels' \
1153 '--intro[send an introduction email for a single patch]' \
1176 '--intro[send an introduction email for a single patch]' \
1154 '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
1177 '(--inline -i --attach -a)'{-a,--attach}'[send patches as attachments]' \
1155 '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
1178 '(--attach -a --inline -i)'{-i,--inline}'[send patches as inline attachments]' \
1156 '*--bcc[email addresses of blind carbon copy recipients]:email:' \
1179 '*--bcc=[email addresses of blind carbon copy recipients]:email' \
1157 '*'{-c+,--cc}'[email addresses of copy recipients]:email:' \
1180 '*'{-c+,--cc=}'[email addresses of copy recipients]:email' \
1158 '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
1181 '(--diffstat -d)'{-d,--diffstat}'[add diffstat output to messages]' \
1159 '--date[use the given date as the sending date]:date:' \
1182 '--date=[use the given date as the sending date]:date' \
1160 '--desc[use the given file as the series description]:files:_files' \
1183 '--desc=[use the given file as the series description]:files:_files' \
1161 '(--from -f)'{-f,--from}'[email address of sender]:email:' \
1184 '(--from -f)'{-f+,--from=}'[email address of sender]:email' \
1162 '(--test -n)'{-n,--test}'[print messages that would be sent]' \
1185 '(--test -n)'{-n,--test}'[print messages that would be sent]' \
1163 '(--mbox -m)'{-m,--mbox}'[write messages to mbox file instead of sending them]:file:' \
1186 '(--mbox -m)'{-m+,--mbox=}'[write messages to mbox file instead of sending them]:file:_files' \
1164 '*--reply-to[email addresses replies should be sent to]:email:' \
1187 '*--reply-to=[email addresses replies should be sent to]:email' \
1165 '(--subject -s)'{-s,--subject}'[subject of first message (intro or single patch)]:subject:' \
1188 '(--subject -s)'{-s+,--subject=}'[subject of first message (intro or single patch)]:subject' \
1166 '--in-reply-to[message identifier to reply to]:msgid:' \
1189 '--in-reply-to=[message identifier to reply to]:msgid' \
1167 '*--flag[flags to add in subject prefixes]:flag:' \
1190 '*--flag=[flags to add in subject prefixes]:flag' \
1168 '*'{-t,--to}'[email addresses of recipients]:email:' \
1191 '*'{-t+,--to=}'[email addresses of recipients]:email' \
1169 ':revision:_hg_revrange'
1192 ':revision:_hg_revrange'
1170 }
1193 }
1171
1194
1172 # Rebase
1195 # Rebase
1173 _hg_cmd_rebase() {
1196 _hg_cmd_rebase() {
1174 _arguments -s -S : $_hg_global_opts $_hg_commit_opts $_hg_mergetool_opts \
1197 _arguments -s -S : $_hg_global_opts $_hg_commit_opts $_hg_mergetool_opts \
1175 '*'{-r+,--rev=}'[rebase these revisions]:revision:_hg_revrange' \
1198 '*'{-r+,--rev=}'[rebase these revisions]:revision:_hg_revrange' \
1176 '(--source -s)'{-s+,--source=}'[rebase from the specified changeset]:revision:_hg_labels' \
1199 '(--source -s --base -b)'{-s+,--source=}'[rebase the specified changeset and descendants]:revision:_hg_labels' \
1177 '(--base -b)'{-b+,--base=}'[rebase from the base of the specified changeset]:revision:_hg_labels' \
1200 '(--source -s --base -b)'{-b+,--base=}'[rebase everything from branching point of specified changeset]:revision:_hg_labels' \
1178 '(--dest -d)'{-d+,--dest=}'[rebase onto the specified changeset]:revision:_hg_labels' \
1201 '(--dest -d)'{-d+,--dest=}'[rebase onto the specified changeset]:revision:_hg_labels' \
1179 '--collapse[collapse the rebased changeset]' \
1202 '--collapse[collapse the rebased changesets]' \
1180 '--keep[keep original changeset]' \
1203 '(--keep -k)'{-k,--keep}'[keep original changesets]' \
1181 '--keepbranches[keep original branch name]' \
1204 '--keepbranches[keep original branch names]' \
1182 '(--continue -c)'{-c,--continue}'[continue an interrupted rebase]' \
1205 '(--continue -c --abort -a)'{-c,--continue}'[continue an interrupted rebase]' \
1183 '(--abort -a)'{-a,--abort}'[abort an interrupted rebase]' \
1206 '(--continue -c --abort -a)'{-a,--abort}'[abort an interrupted rebase]' \
1184 }
1207 }
1185
1208
1186 # Record
1209 # Record
1187 _hg_cmd_record() {
1210 _hg_cmd_record() {
1188 _arguments -s -S : $_hg_global_opts $_hg_commit_opts $_hg_pat_opts \
1211 _arguments -s -S : $_hg_global_opts $_hg_commit_opts $_hg_pat_opts \
1189 $_hg_ignore_space_opts $_hg_subrepos_opts \
1212 $_hg_ignore_space_opts $_hg_subrepos_opts \
1190 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
1213 '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
1191 '--close-branch[mark a branch as closed, hiding it from the branch list]' \
1214 '--close-branch[mark a branch as closed, hiding it from the branch list]' \
1192 '--amend[amend the parent of the working dir]' \
1215 '--amend[amend the parent of the working dir]' \
1193 '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date:' \
1216 '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
1194 '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user:'
1217 '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user'
1195 }
1218 }
1196
1219
1197 _hg_cmd_qrecord() {
1220 _hg_cmd_qrecord() {
1198 _arguments -s -S : $_hg_global_opts $_hg_commit_opts $_hg_date_user_opts $_hg_gitlike_opts \
1221 _arguments -s -S : $_hg_global_opts $_hg_commit_opts $_hg_date_user_opts $_hg_gitlike_opts \
1199 $_hg_pat_opts $_hg_ignore_space_opts $_hg_subrepos_opts
1222 $_hg_pat_opts $_hg_ignore_space_opts $_hg_subrepos_opts
1200 }
1223 }
1201
1224
1202 # Convert
1225 # Convert
1203 _hg_cmd_convert() {
1226 _hg_cmd_convert() {
1204 _arguments -s -S : $_hg_global_opts \
1227 _arguments -s -S : $_hg_global_opts \
1205 '(--source-type -s)'{-s,--source-type}'[source repository type]' \
1228 '(--source-type -s)'{-s+,--source-type=}'[source repository type]:type:(hg cvs darcs git svn mtn gnuarch bzr p4)' \
1206 '(--dest-type -d)'{-d,--dest-type}'[destination repository type]' \
1229 '(--dest-type -d)'{-d+,--dest-type=}'[destination repository type]:type:(hg svn)' \
1207 '(--rev -r)'{-r+,--rev=}'[import up to target revision]:revision:' \
1230 '*'{-r+,--rev=}'[import up to target revision]:revision' \
1208 '(--authormap -A)'{-A+,--authormap=}'[remap usernames using this file]:file:_files' \
1231 '(--authormap -A)'{-A+,--authormap=}'[remap usernames using this file]:file:_files' \
1209 '--filemap[remap file names using contents of file]:file:_files' \
1232 '--filemap=[remap file names using contents of file]:file:_files' \
1210 '--splicemap[splice synthesized history into place]:file:_files' \
1233 '--full[apply filemap changes by converting all files again]' \
1211 '--branchmap[change branch names while converting]:file:_files' \
1234 '--splicemap=[splice synthesized history into place]:file:_files' \
1235 '--branchmap=[change branch names while converting]:file:_files' \
1212 '--branchsort[try to sort changesets by branches]' \
1236 '--branchsort[try to sort changesets by branches]' \
1213 '--datesort[try to sort changesets by date]' \
1237 '--datesort[try to sort changesets by date]' \
1214 '--sourcesort[preserve source changesets order]'
1238 '--sourcesort[preserve source changesets order]' \
1239 '--closesort[try to reorder closed revisions]'
1215 }
1240 }
1216
1241
1217 # Purge
1242 # Purge
1218 _hg_cmd_purge() {
1243 _hg_cmd_purge() {
1219 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
1244 _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \
1220 '(--abort-on-err -a)'{-a,--abort-on-err}'[abort if an error occurs]' \
1245 '(--abort-on-err -a)'{-a,--abort-on-err}'[abort if an error occurs]' \
1221 '--all[purge ignored files too]' \
1246 '--all[purge ignored files too]' \
1222 '(--print -p)'{-p,--print}'[print filenames instead of deleting them]' \
1247 '(--print -p)'{-p,--print}'[print filenames instead of deleting them]' \
1223 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs (implies -p/--print)]'
1248 '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs (implies -p/--print)]'
1224 }
1249 }
1225
1250
1226 _hg "$@"
1251 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now