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