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