##// END OF EJS Templates
Fix issue 563: error in _hg_commit in the contrib/zsh_completion script.
Henri Precheur -
r4441:2d3379c5 default
parent child Browse files
Show More
@@ -1,789 +1,789 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 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 [[ -d $PREFIX ]] || PREFIX=$PREFIX:h
182 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)"})
183 }
183 }
184
184
185 _hg_unknown() {
185 _hg_unknown() {
186 typeset -a status_files
186 typeset -a status_files
187 _hg_status u
187 _hg_status u
188 _wanted files expl 'unknown files' _multi_parts / status_files
188 _wanted files expl 'unknown files' _multi_parts / status_files
189 }
189 }
190
190
191 _hg_missing() {
191 _hg_missing() {
192 typeset -a status_files
192 typeset -a status_files
193 _hg_status d
193 _hg_status d
194 _wanted files expl 'missing files' _multi_parts / status_files
194 _wanted files expl 'missing files' _multi_parts / status_files
195 }
195 }
196
196
197 _hg_modified() {
197 _hg_modified() {
198 typeset -a status_files
198 typeset -a status_files
199 _hg_status m
199 _hg_status m
200 _wanted files expl 'modified files' _multi_parts / status_files
200 _wanted files expl 'modified files' _multi_parts / status_files
201 }
201 }
202
202
203 _hg_addremove() {
203 _hg_addremove() {
204 _alternative 'files:unknown files:_hg_unknown' \
204 _alternative 'files:unknown files:_hg_unknown' \
205 'files:missing files:_hg_missing'
205 'files:missing files:_hg_missing'
206 }
206 }
207
207
208 _hg_ssh_urls() {
208 _hg_ssh_urls() {
209 if [[ -prefix */ ]]
209 if [[ -prefix */ ]]
210 then
210 then
211 if zstyle -T ":completion:${curcontext}:files" remote-access
211 if zstyle -T ":completion:${curcontext}:files" remote-access
212 then
212 then
213 local host=${PREFIX%%/*}
213 local host=${PREFIX%%/*}
214 typeset -a remdirs
214 typeset -a remdirs
215 compset -p $(( $#host + 1 ))
215 compset -p $(( $#host + 1 ))
216 local rempath=${(M)PREFIX##*/}
216 local rempath=${(M)PREFIX##*/}
217 local cacheid="hg:${host}-${rempath//\//_}"
217 local cacheid="hg:${host}-${rempath//\//_}"
218 cacheid=${cacheid%[-_]}
218 cacheid=${cacheid%[-_]}
219 compset -P '*/'
219 compset -P '*/'
220 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
220 if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid"
221 then
221 then
222 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)"}##*/}%/})
223 _store_cache "$cacheid" remdirs
223 _store_cache "$cacheid" remdirs
224 fi
224 fi
225 _describe -t directories 'remote directory' remdirs -S/
225 _describe -t directories 'remote directory' remdirs -S/
226 else
226 else
227 _message 'remote directory'
227 _message 'remote directory'
228 fi
228 fi
229 else
229 else
230 if compset -P '*@'
230 if compset -P '*@'
231 then
231 then
232 _hosts -S/
232 _hosts -S/
233 else
233 else
234 _alternative 'hosts:remote host name:_hosts -S/' \
234 _alternative 'hosts:remote host name:_hosts -S/' \
235 'users:user:_users -S@'
235 'users:user:_users -S@'
236 fi
236 fi
237 fi
237 fi
238 }
238 }
239
239
240 _hg_urls() {
240 _hg_urls() {
241 if compset -P bundle://
241 if compset -P bundle://
242 then
242 then
243 _files
243 _files
244 elif compset -P ssh://
244 elif compset -P ssh://
245 then
245 then
246 _hg_ssh_urls
246 _hg_ssh_urls
247 elif [[ -prefix *: ]]
247 elif [[ -prefix *: ]]
248 then
248 then
249 _urls
249 _urls
250 else
250 else
251 local expl
251 local expl
252 compset -S '[^:]*'
252 compset -S '[^:]*'
253 _wanted url-schemas expl 'URL schema' compadd -S '' - \
253 _wanted url-schemas expl 'URL schema' compadd -S '' - \
254 http:// https:// ssh:// bundle://
254 http:// https:// ssh:// bundle://
255 fi
255 fi
256 }
256 }
257
257
258 _hg_paths() {
258 _hg_paths() {
259 typeset -a paths pnames
259 typeset -a paths pnames
260 _hg_cmd paths 2> /dev/null | while read -A pnames
260 _hg_cmd paths 2> /dev/null | while read -A pnames
261 do
261 do
262 paths+=($pnames[1])
262 paths+=($pnames[1])
263 done
263 done
264 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
264 (( $#paths )) && _describe -t path-aliases 'repository alias' paths
265 }
265 }
266
266
267 _hg_remote() {
267 _hg_remote() {
268 _alternative 'path-aliases:repository alias:_hg_paths' \
268 _alternative 'path-aliases:repository alias:_hg_paths' \
269 'directories:directory:_files -/' \
269 'directories:directory:_files -/' \
270 'urls:URL:_hg_urls'
270 'urls:URL:_hg_urls'
271 }
271 }
272
272
273 _hg_clone_dest() {
273 _hg_clone_dest() {
274 _alternative 'directories:directory:_files -/' \
274 _alternative 'directories:directory:_files -/' \
275 'urls:URL:_hg_urls'
275 'urls:URL:_hg_urls'
276 }
276 }
277
277
278 # Common options
278 # Common options
279 _hg_global_opts=(
279 _hg_global_opts=(
280 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
280 '(--repository -R)'{-R+,--repository}'[repository root directory]:repository:_files -/'
281 '--cwd[change working directory]:new working directory:_files -/'
281 '--cwd[change working directory]:new working directory:_files -/'
282 '(--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]'
283 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
283 '(--verbose -v)'{-v,--verbose}'[enable additional output]'
284 '(--quiet -q)'{-q,--quiet}'[suppress output]'
284 '(--quiet -q)'{-q,--quiet}'[suppress output]'
285 '(--help -h)'{-h,--help}'[display help and exit]'
285 '(--help -h)'{-h,--help}'[display help and exit]'
286 '--debug[debug mode]'
286 '--debug[debug mode]'
287 '--debugger[start debugger]'
287 '--debugger[start debugger]'
288 '--traceback[print traceback on exception]'
288 '--traceback[print traceback on exception]'
289 '--time[time how long the command takes]'
289 '--time[time how long the command takes]'
290 '--profile[profile]'
290 '--profile[profile]'
291 '--version[output version information and exit]'
291 '--version[output version information and exit]'
292 )
292 )
293
293
294 _hg_pat_opts=(
294 _hg_pat_opts=(
295 '*'{-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) -/'
296 '*'{-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) -/')
297
297
298 _hg_diff_opts=(
298 _hg_diff_opts=(
299 '(--text -a)'{-a,--text}'[treat all files as text]'
299 '(--text -a)'{-a,--text}'[treat all files as text]'
300 '(--git -g)'{-g,--git}'[use git extended diff format]'
300 '(--git -g)'{-g,--git}'[use git extended diff format]'
301 "--nodates[don't include dates in diff headers]")
301 "--nodates[don't include dates in diff headers]")
302
302
303 _hg_dryrun_opts=(
303 _hg_dryrun_opts=(
304 '(--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]')
305
305
306 _hg_style_opts=(
306 _hg_style_opts=(
307 '--style[display using template map file]:'
307 '--style[display using template map file]:'
308 '--template[display with template]:')
308 '--template[display with template]:')
309
309
310 _hg_commit_opts=(
310 _hg_commit_opts=(
311 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
311 '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
312 '(-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:'
313 '(-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')
314
314
315 _hg_remote_opts=(
315 _hg_remote_opts=(
316 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
316 '(--ssh -e)'{-e+,--ssh}'[specify ssh command to use]:'
317 '--remotecmd[specify hg command to run on the remote side]:')
317 '--remotecmd[specify hg command to run on the remote side]:')
318
318
319 _hg_cmd() {
319 _hg_cmd() {
320 _call_program hg hg "$_hg_cmd_globals[@]" "$@"
320 _call_program hg hg "$_hg_cmd_globals[@]" "$@"
321 }
321 }
322
322
323 _hg_cmd_add() {
323 _hg_cmd_add() {
324 _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 \
325 '*:unknown files:_hg_unknown'
325 '*:unknown files:_hg_unknown'
326 }
326 }
327
327
328 _hg_cmd_addremove() {
328 _hg_cmd_addremove() {
329 _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 \
330 '(--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)]:' \
331 '*:unknown or missing files:_hg_addremove'
331 '*:unknown or missing files:_hg_addremove'
332 }
332 }
333
333
334 _hg_cmd_annotate() {
334 _hg_cmd_annotate() {
335 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
335 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
336 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_tags' \
336 '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_tags' \
337 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
337 '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
338 '(--text -a)'{-a,--text}'[treat all files as text]' \
338 '(--text -a)'{-a,--text}'[treat all files as text]' \
339 '(--user -u)'{-u,--user}'[list the author]' \
339 '(--user -u)'{-u,--user}'[list the author]' \
340 '(--date -d)'{-d,--date}'[list the date]' \
340 '(--date -d)'{-d,--date}'[list the date]' \
341 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
341 '(--number -n)'{-n,--number}'[list the revision number (default)]' \
342 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
342 '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
343 '*:files:_hg_files'
343 '*:files:_hg_files'
344 }
344 }
345
345
346 _hg_cmd_archive() {
346 _hg_cmd_archive() {
347 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
347 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
348 '--no-decode[do not pass files through decoders]' \
348 '--no-decode[do not pass files through decoders]' \
349 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
349 '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \
350 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_tags' \
350 '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_tags' \
351 '(--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)' \
352 '*:destination:_files'
352 '*:destination:_files'
353 }
353 }
354
354
355 _hg_cmd_bundle() {
355 _hg_cmd_bundle() {
356 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
356 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
357 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
357 '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
358 '(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' \
359 ':output file:_files' \
359 ':output file:_files' \
360 ':destination repository:_files -/'
360 ':destination repository:_files -/'
361 }
361 }
362
362
363 _hg_cmd_cat() {
363 _hg_cmd_cat() {
364 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
364 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
365 '(--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:' \
366 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
366 '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \
367 '*:file:_hg_files'
367 '*:file:_hg_files'
368 }
368 }
369
369
370 _hg_cmd_clone() {
370 _hg_cmd_clone() {
371 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
371 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
372 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
372 '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
373 '(--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]:' \
374 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
374 '--uncompressed[use uncompressed transfer (fast over LAN)]' \
375 ':source repository:_hg_remote' \
375 ':source repository:_hg_remote' \
376 ':destination:_hg_clone_dest'
376 ':destination:_hg_clone_dest'
377 }
377 }
378
378
379 _hg_cmd_commit() {
379 _hg_cmd_commit() {
380 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
380 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
381 '(--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]' \
382 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
382 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
383 '(--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:_files -g \*.txt' \
384 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
384 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
385 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
385 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
386 '*:file:_hg_files'
386 '*:file:_hg_files'
387 }
387 }
388
388
389 _hg_cmd_copy() {
389 _hg_cmd_copy() {
390 _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 \
391 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
391 '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
392 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
392 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
393 '*:file:_hg_files'
393 '*:file:_hg_files'
394 }
394 }
395
395
396 _hg_cmd_diff() {
396 _hg_cmd_diff() {
397 typeset -A opt_args
397 typeset -A opt_args
398 _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 \
399 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
399 '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \
400 '(--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]' \
401 '(--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]' \
402 '(--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]' \
403 '(--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]' \
404 '*:file:->diff_files'
404 '*:file:->diff_files'
405
405
406 if [[ $state == 'diff_files' ]]
406 if [[ $state == 'diff_files' ]]
407 then
407 then
408 if [[ -n $opt_args[-r] ]]
408 if [[ -n $opt_args[-r] ]]
409 then
409 then
410 _hg_files
410 _hg_files
411 else
411 else
412 _hg_modified
412 _hg_modified
413 fi
413 fi
414 fi
414 fi
415 }
415 }
416
416
417 _hg_cmd_export() {
417 _hg_cmd_export() {
418 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
418 _arguments -s -w : $_hg_global_opts $_hg_diff_opts \
419 '(--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:' \
420 '--switch-parent[diff against the second parent]' \
420 '--switch-parent[diff against the second parent]' \
421 '*:revision:_hg_tags'
421 '*:revision:_hg_tags'
422 }
422 }
423
423
424 _hg_cmd_grep() {
424 _hg_cmd_grep() {
425 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
425 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
426 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
426 '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
427 '--all[print all revisions with matches]' \
427 '--all[print all revisions with matches]' \
428 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
428 '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
429 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
429 '(--ignore-case -i)'{-i,--ignore-case}'[ignore case when matching]' \
430 '(--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]' \
431 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
431 '(--line-number -n)'{-n,--line-number}'[print matching line numbers]' \
432 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
432 '*'{-r+,--rev}'[search in given revision range]:revision:_hg_revrange' \
433 '(--user -u)'{-u,--user}'[print user who committed change]' \
433 '(--user -u)'{-u,--user}'[print user who committed change]' \
434 '*:search pattern:_hg_files'
434 '*:search pattern:_hg_files'
435 }
435 }
436
436
437 _hg_cmd_heads() {
437 _hg_cmd_heads() {
438 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
438 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
439 '(--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'
440 }
440 }
441
441
442 _hg_cmd_help() {
442 _hg_cmd_help() {
443 _arguments -s -w : $_hg_global_opts \
443 _arguments -s -w : $_hg_global_opts \
444 '*:mercurial command:_hg_commands'
444 '*:mercurial command:_hg_commands'
445 }
445 }
446
446
447 _hg_cmd_import() {
447 _hg_cmd_import() {
448 _arguments -s -w : $_hg_global_opts \
448 _arguments -s -w : $_hg_global_opts \
449 '(--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:' \
450 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
450 '(--message -m)'{-m+,--message}'[use <text> as commit message]:text:' \
451 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
451 '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
452 '*:patch:_files'
452 '*:patch:_files'
453 }
453 }
454
454
455 _hg_cmd_incoming() {
455 _hg_cmd_incoming() {
456 _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 \
457 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
457 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
458 '(--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]' \
459 '(--patch -p)'{-p,--patch}'[show patch]' \
459 '(--patch -p)'{-p,--patch}'[show patch]' \
460 '(--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]' \
461 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
461 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
462 '--bundle[file to store the bundles into]:bundle file:_files' \
462 '--bundle[file to store the bundles into]:bundle file:_files' \
463 ':source:_hg_remote'
463 ':source:_hg_remote'
464 }
464 }
465
465
466 _hg_cmd_init() {
466 _hg_cmd_init() {
467 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
467 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
468 ':dir:_files -/'
468 ':dir:_files -/'
469 }
469 }
470
470
471 _hg_cmd_locate() {
471 _hg_cmd_locate() {
472 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
472 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
473 '(--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' \
474 '(--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]' \
475 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
475 '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
476 '*:search pattern:_hg_files'
476 '*:search pattern:_hg_files'
477 }
477 }
478
478
479 _hg_cmd_log() {
479 _hg_cmd_log() {
480 _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 \
481 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
481 '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
482 '(-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]' \
483 '(--copies -C)'{-C,--copies}'[show copied files]' \
483 '(--copies -C)'{-C,--copies}'[show copied files]' \
484 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
484 '(--keyword -k)'{-k+,--keyword}'[search for a keyword]:' \
485 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
485 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
486 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
486 '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
487 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
487 '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
488 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
488 '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
489 '(--patch -p)'{-p,--patch}'[show patch]' \
489 '(--patch -p)'{-p,--patch}'[show patch]' \
490 '(--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' \
491 '*:files:_hg_files'
491 '*:files:_hg_files'
492 }
492 }
493
493
494 _hg_cmd_manifest() {
494 _hg_cmd_manifest() {
495 _arguments -s -w : $_hg_global_opts \
495 _arguments -s -w : $_hg_global_opts \
496 ':revision:_hg_tags'
496 ':revision:_hg_tags'
497 }
497 }
498
498
499 _hg_cmd_outgoing() {
499 _hg_cmd_outgoing() {
500 _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 \
501 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
501 '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
502 '(--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]' \
503 '(--patch -p)'{-p,--patch}'[show patch]' \
503 '(--patch -p)'{-p,--patch}'[show patch]' \
504 '(--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]' \
505 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
505 '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
506 ':destination:_hg_remote'
506 ':destination:_hg_remote'
507 }
507 }
508
508
509 _hg_cmd_parents() {
509 _hg_cmd_parents() {
510 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
510 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
511 '(--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' \
512 ':revision:_hg_tags'
512 ':revision:_hg_tags'
513 }
513 }
514
514
515 _hg_cmd_paths() {
515 _hg_cmd_paths() {
516 _arguments -s -w : $_hg_global_opts \
516 _arguments -s -w : $_hg_global_opts \
517 ':path:_hg_paths'
517 ':path:_hg_paths'
518 }
518 }
519
519
520 _hg_cmd_pull() {
520 _hg_cmd_pull() {
521 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
521 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
522 '(--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]' \
523 '(--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]' \
524 ':source:_hg_remote'
524 ':source:_hg_remote'
525 }
525 }
526
526
527 _hg_cmd_push() {
527 _hg_cmd_push() {
528 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
528 _arguments -s -w : $_hg_global_opts $_hg_remote_opts \
529 '(--force -f)'{-f,--force}'[force push]' \
529 '(--force -f)'{-f,--force}'[force push]' \
530 '(--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]' \
531 ':destination:_hg_remote'
531 ':destination:_hg_remote'
532 }
532 }
533
533
534 _hg_cmd_remove() {
534 _hg_cmd_remove() {
535 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
535 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
536 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
536 '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
537 '(--force -f)'{-f,--force}'[remove file even if modified]' \
537 '(--force -f)'{-f,--force}'[remove file even if modified]' \
538 '*:file:_hg_files'
538 '*:file:_hg_files'
539 }
539 }
540
540
541 _hg_cmd_rename() {
541 _hg_cmd_rename() {
542 _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 \
543 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
543 '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
544 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
544 '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
545 '*:file:_hg_files'
545 '*:file:_hg_files'
546 }
546 }
547
547
548 _hg_cmd_revert() {
548 _hg_cmd_revert() {
549 _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 \
550 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
550 '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
551 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_tags' \
551 '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_tags' \
552 '--no-backup[do not save backup copies of files]' \
552 '--no-backup[do not save backup copies of files]' \
553 '*:file:->diff_files'
553 '*:file:->diff_files'
554
554
555 if [[ $state == 'diff_files' ]]
555 if [[ $state == 'diff_files' ]]
556 then
556 then
557 if [[ -n $opt_args[-r] ]]
557 if [[ -n $opt_args[-r] ]]
558 then
558 then
559 _hg_files
559 _hg_files
560 else
560 else
561 typeset -a status_files
561 typeset -a status_files
562 _hg_status mard
562 _hg_status mard
563 _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
564 fi
564 fi
565 fi
565 fi
566 }
566 }
567
567
568 _hg_cmd_serve() {
568 _hg_cmd_serve() {
569 _arguments -s -w : $_hg_global_opts \
569 _arguments -s -w : $_hg_global_opts \
570 '(--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' \
571 '(--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' \
572 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
572 '(--daemon -d)'{-d,--daemon}'[run server in background]' \
573 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
573 '(--port -p)'{-p+,--port}'[listen port]:listen port:' \
574 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
574 '(--address -a)'{-a+,--address}'[interface address]:interface address:' \
575 '(--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:' \
576 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
576 '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
577 '--style[web template style]:style' \
577 '--style[web template style]:style' \
578 '--stdio[for remote clients]' \
578 '--stdio[for remote clients]' \
579 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
579 '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
580 }
580 }
581
581
582 _hg_cmd_status() {
582 _hg_cmd_status() {
583 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
583 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
584 '(--all -A)'{-A,--all}'[show status of all files]' \
584 '(--all -A)'{-A,--all}'[show status of all files]' \
585 '(--modified -m)'{-m,--modified}'[show only modified files]' \
585 '(--modified -m)'{-m,--modified}'[show only modified files]' \
586 '(--added -a)'{-a,--added}'[show only added files]' \
586 '(--added -a)'{-a,--added}'[show only added files]' \
587 '(--removed -r)'{-r,--removed}'[show only removed files]' \
587 '(--removed -r)'{-r,--removed}'[show only removed files]' \
588 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
588 '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
589 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
589 '(--clean -c)'{-c,--clean}'[show only files without changes]' \
590 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
590 '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
591 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
591 '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
592 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
592 '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
593 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
593 '(--copies -C)'{-C,--copies}'[show source of copied files]' \
594 '(--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]' \
595 '--rev[show difference from revision]:revision:_hg_tags' \
595 '--rev[show difference from revision]:revision:_hg_tags' \
596 '*:files:_files'
596 '*:files:_files'
597 }
597 }
598
598
599 _hg_cmd_tag() {
599 _hg_cmd_tag() {
600 _arguments -s -w : $_hg_global_opts \
600 _arguments -s -w : $_hg_global_opts \
601 '(--local -l)'{-l,--local}'[make the tag local]' \
601 '(--local -l)'{-l,--local}'[make the tag local]' \
602 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
602 '(--message -m)'{-m+,--message}'[message for tag commit log entry]:message:' \
603 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
603 '(--date -d)'{-d+,--date}'[record datecode as commit date]:date code:' \
604 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
604 '(--user -u)'{-u+,--user}'[record user as commiter]:user:' \
605 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_tags' \
605 '(--rev -r)'{-r+,--rev}'[revision to tag]:revision:_hg_tags' \
606 ':tag name:'
606 ':tag name:'
607 }
607 }
608
608
609 _hg_cmd_tip() {
609 _hg_cmd_tip() {
610 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
610 _arguments -s -w : $_hg_global_opts $_hg_style_opts \
611 '(--patch -p)'{-p,--patch}'[show patch]'
611 '(--patch -p)'{-p,--patch}'[show patch]'
612 }
612 }
613
613
614 _hg_cmd_unbundle() {
614 _hg_cmd_unbundle() {
615 _arguments -s -w : $_hg_global_opts \
615 _arguments -s -w : $_hg_global_opts \
616 '(--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]' \
617 ':files:_files'
617 ':files:_files'
618 }
618 }
619
619
620 _hg_cmd_update() {
620 _hg_cmd_update() {
621 _arguments -s -w : $_hg_global_opts \
621 _arguments -s -w : $_hg_global_opts \
622 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
622 '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
623 ':revision:_hg_tags'
623 ':revision:_hg_tags'
624 }
624 }
625
625
626 # HGK
626 # HGK
627 _hg_cmd_view() {
627 _hg_cmd_view() {
628 _arguments -s -w : $_hg_global_opts \
628 _arguments -s -w : $_hg_global_opts \
629 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
629 '(--limit -l)'{-l+,--limit}'[limit number of changes displayed]:' \
630 ':revision range:_hg_tags'
630 ':revision range:_hg_tags'
631 }
631 }
632
632
633 # MQ
633 # MQ
634 _hg_qseries() {
634 _hg_qseries() {
635 typeset -a patches
635 typeset -a patches
636 patches=($(_hg_cmd qseries 2>/dev/null))
636 patches=($(_hg_cmd qseries 2>/dev/null))
637 (( $#patches )) && _describe -t hg-patches 'patches' patches
637 (( $#patches )) && _describe -t hg-patches 'patches' patches
638 }
638 }
639
639
640 _hg_qapplied() {
640 _hg_qapplied() {
641 typeset -a patches
641 typeset -a patches
642 patches=($(_hg_cmd qapplied 2>/dev/null))
642 patches=($(_hg_cmd qapplied 2>/dev/null))
643 if (( $#patches ))
643 if (( $#patches ))
644 then
644 then
645 patches+=(qbase qtip)
645 patches+=(qbase qtip)
646 _describe -t hg-applied-patches 'applied patches' patches
646 _describe -t hg-applied-patches 'applied patches' patches
647 fi
647 fi
648 }
648 }
649
649
650 _hg_qunapplied() {
650 _hg_qunapplied() {
651 typeset -a patches
651 typeset -a patches
652 patches=($(_hg_cmd qunapplied 2>/dev/null))
652 patches=($(_hg_cmd qunapplied 2>/dev/null))
653 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
653 (( $#patches )) && _describe -t hg-unapplied-patches 'unapplied patches' patches
654 }
654 }
655
655
656 _hg_qguards() {
656 _hg_qguards() {
657 typeset -a guards
657 typeset -a guards
658 local guard
658 local guard
659 compset -P "+|-"
659 compset -P "+|-"
660 _hg_cmd qselect -s 2>/dev/null | while read guard
660 _hg_cmd qselect -s 2>/dev/null | while read guard
661 do
661 do
662 guards+=(${guard#(+|-)})
662 guards+=(${guard#(+|-)})
663 done
663 done
664 (( $#guards )) && _describe -t hg-guards 'guards' guards
664 (( $#guards )) && _describe -t hg-guards 'guards' guards
665 }
665 }
666
666
667 _hg_qseries_opts=(
667 _hg_qseries_opts=(
668 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
668 '(--summary -s)'{-s,--summary}'[print first line of patch header]')
669
669
670 _hg_cmd_qapplied() {
670 _hg_cmd_qapplied() {
671 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
671 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
672 }
672 }
673
673
674 _hg_cmd_qdelete() {
674 _hg_cmd_qdelete() {
675 _arguments -s -w : $_hg_global_opts \
675 _arguments -s -w : $_hg_global_opts \
676 '(--keep -k)'{-k,--keep}'[keep patch file]' \
676 '(--keep -k)'{-k,--keep}'[keep patch file]' \
677 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
677 '*'{-r+,--rev}'[stop managing a revision]:applied patch:_hg_revrange' \
678 '*:unapplied patch:_hg_qunapplied'
678 '*:unapplied patch:_hg_qunapplied'
679 }
679 }
680
680
681 _hg_cmd_qdiff() {
681 _hg_cmd_qdiff() {
682 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
682 _arguments -s -w : $_hg_global_opts $_hg_pat_opts \
683 '*:pattern:_hg_files'
683 '*:pattern:_hg_files'
684 }
684 }
685
685
686 _hg_cmd_qfold() {
686 _hg_cmd_qfold() {
687 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
687 _arguments -s -w : $_hg_global_opts $_h_commit_opts \
688 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
688 '(--keep,-k)'{-k,--keep}'[keep folded patch files]' \
689 '*:unapplied patch:_hg_qunapplied'
689 '*:unapplied patch:_hg_qunapplied'
690 }
690 }
691
691
692 _hg_cmd_qguard() {
692 _hg_cmd_qguard() {
693 _arguments -s -w : $_hg_global_opts \
693 _arguments -s -w : $_hg_global_opts \
694 '(--list -l)'{-l,--list}'[list all patches and guards]' \
694 '(--list -l)'{-l,--list}'[list all patches and guards]' \
695 '(--none -n)'{-n,--none}'[drop all guards]' \
695 '(--none -n)'{-n,--none}'[drop all guards]' \
696 ':patch:_hg_qseries' \
696 ':patch:_hg_qseries' \
697 '*:guards:_hg_qguards'
697 '*:guards:_hg_qguards'
698 }
698 }
699
699
700 _hg_cmd_qheader() {
700 _hg_cmd_qheader() {
701 _arguments -s -w : $_hg_global_opts \
701 _arguments -s -w : $_hg_global_opts \
702 ':patch:_hg_qseries'
702 ':patch:_hg_qseries'
703 }
703 }
704
704
705 _hg_cmd_qimport() {
705 _hg_cmd_qimport() {
706 _arguments -s -w : $_hg_global_opts \
706 _arguments -s -w : $_hg_global_opts \
707 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
707 '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
708 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
708 '(--name -n 2)'{-n+,--name}'[patch file name]:name:' \
709 '(--force -f)'{-f,--force}'[overwrite existing files]' \
709 '(--force -f)'{-f,--force}'[overwrite existing files]' \
710 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
710 '*'{-r+,--rev}'[place existing revisions under mq control]:revision:_hg_revrange' \
711 '*:patch:_files'
711 '*:patch:_files'
712 }
712 }
713
713
714 _hg_cmd_qnew() {
714 _hg_cmd_qnew() {
715 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
715 _arguments -s -w : $_hg_global_opts $_hg_commit_opts \
716 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
716 '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
717 ':patch:'
717 ':patch:'
718 }
718 }
719
719
720 _hg_cmd_qnext() {
720 _hg_cmd_qnext() {
721 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
721 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
722 }
722 }
723
723
724 _hg_cmd_qpop() {
724 _hg_cmd_qpop() {
725 _arguments -s -w : $_hg_global_opts \
725 _arguments -s -w : $_hg_global_opts \
726 '(--all -a :)'{-a,--all}'[pop all patches]' \
726 '(--all -a :)'{-a,--all}'[pop all patches]' \
727 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
727 '(--name -n)'{-n+,--name}'[queue name to pop]:' \
728 '(--force -f)'{-f,--force}'[forget any local changes]' \
728 '(--force -f)'{-f,--force}'[forget any local changes]' \
729 ':patch:_hg_qapplied'
729 ':patch:_hg_qapplied'
730 }
730 }
731
731
732 _hg_cmd_qprev() {
732 _hg_cmd_qprev() {
733 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
733 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
734 }
734 }
735
735
736 _hg_cmd_qpush() {
736 _hg_cmd_qpush() {
737 _arguments -s -w : $_hg_global_opts \
737 _arguments -s -w : $_hg_global_opts \
738 '(--all -a :)'{-a,--all}'[apply all patches]' \
738 '(--all -a :)'{-a,--all}'[apply all patches]' \
739 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
739 '(--list -l)'{-l,--list}'[list patch name in commit text]' \
740 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
740 '(--merge -m)'{-m+,--merge}'[merge from another queue]:' \
741 '(--name -n)'{-n+,--name}'[merge queue name]:' \
741 '(--name -n)'{-n+,--name}'[merge queue name]:' \
742 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
742 '(--force -f)'{-f,--force}'[apply if the patch has rejects]' \
743 ':patch:_hg_qunapplied'
743 ':patch:_hg_qunapplied'
744 }
744 }
745
745
746 _hg_cmd_qrefresh() {
746 _hg_cmd_qrefresh() {
747 _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 \
748 '(--git -g)'{-g,--git}'[use git extended diff format]' \
748 '(--git -g)'{-g,--git}'[use git extended diff format]' \
749 '(--short -s)'{-s,--short}'[short refresh]' \
749 '(--short -s)'{-s,--short}'[short refresh]' \
750 '*:files:_hg_files'
750 '*:files:_hg_files'
751 }
751 }
752
752
753 _hg_cmd_qrename() {
753 _hg_cmd_qrename() {
754 _arguments -s -w : $_hg_global_opts \
754 _arguments -s -w : $_hg_global_opts \
755 ':patch:_hg_qseries' \
755 ':patch:_hg_qseries' \
756 ':destination:'
756 ':destination:'
757 }
757 }
758
758
759 _hg_cmd_qselect() {
759 _hg_cmd_qselect() {
760 _arguments -s -w : $_hg_global_opts \
760 _arguments -s -w : $_hg_global_opts \
761 '(--none -n :)'{-n,--none}'[disable all guards]' \
761 '(--none -n :)'{-n,--none}'[disable all guards]' \
762 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
762 '(--series -s :)'{-s,--series}'[list all guards in series file]' \
763 '--pop[pop to before first guarded applied patch]' \
763 '--pop[pop to before first guarded applied patch]' \
764 '--reapply[pop and reapply patches]' \
764 '--reapply[pop and reapply patches]' \
765 '*:guards:_hg_qguards'
765 '*:guards:_hg_qguards'
766 }
766 }
767
767
768 _hg_cmd_qseries() {
768 _hg_cmd_qseries() {
769 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
769 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts \
770 '(--missing -m)'{-m,--missing}'[print patches not in series]'
770 '(--missing -m)'{-m,--missing}'[print patches not in series]'
771 }
771 }
772
772
773 _hg_cmd_qunapplied() {
773 _hg_cmd_qunapplied() {
774 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
774 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
775 }
775 }
776
776
777 _hg_cmd_qtop() {
777 _hg_cmd_qtop() {
778 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
778 _arguments -s -w : $_hg_global_opts $_hg_qseries_opts
779 }
779 }
780
780
781 _hg_cmd_strip() {
781 _hg_cmd_strip() {
782 _arguments -s -w : $_hg_global_opts \
782 _arguments -s -w : $_hg_global_opts \
783 '(--force -f)'{-f,--force}'[force multi-head removal]' \
783 '(--force -f)'{-f,--force}'[force multi-head removal]' \
784 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
784 '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
785 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
785 '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
786 ':revision:_hg_tags'
786 ':revision:_hg_tags'
787 }
787 }
788
788
789 _hg "$@"
789 _hg "$@"
General Comments 0
You need to be logged in to leave comments. Login now