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