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