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