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