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