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