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