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