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