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