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