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