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