Show More
@@ -1,588 +1,588 b'' | |||
|
1 | 1 | # bash completion for the Mercurial distributed SCM |
|
2 | 2 | |
|
3 | 3 | # Docs: |
|
4 | 4 | # |
|
5 | 5 | # If you source this file from your .bashrc, bash should be able to |
|
6 | 6 | # complete a command line that uses hg with all the available commands |
|
7 | 7 | # and options and sometimes even arguments. |
|
8 | 8 | # |
|
9 | 9 | # Mercurial allows you to define additional commands through extensions. |
|
10 | 10 | # Bash should be able to automatically figure out the name of these new |
|
11 | 11 | # commands and their options. See below for how to define _hg_opt_foo |
|
12 | 12 | # and _hg_cmd_foo functions to fine-tune the completion for option and |
|
13 | 13 | # non-option arguments, respectively. |
|
14 | 14 | # |
|
15 | 15 | # |
|
16 | 16 | # Notes about completion for specific commands: |
|
17 | 17 | # |
|
18 | 18 | # - the completion function for the email command from the patchbomb |
|
19 | 19 | # extension will try to call _hg_emails to get a list of e-mail |
|
20 | 20 | # addresses. It's up to the user to define this function. For |
|
21 | 21 | # example, put the addresses of the lists that you usually patchbomb |
|
22 | 22 | # in ~/.patchbomb-to and the addresses that you usually use to send |
|
23 | 23 | # the patchbombs in ~/.patchbomb-from and use something like this: |
|
24 | 24 | # |
|
25 | 25 | # _hg_emails() |
|
26 | 26 | # { |
|
27 | 27 | # if [ -r ~/.patchbomb-$1 ]; then |
|
28 | 28 | # cat ~/.patchbomb-$1 |
|
29 | 29 | # fi |
|
30 | 30 | # } |
|
31 | 31 | # |
|
32 | 32 | # |
|
33 | 33 | # Writing completion functions for additional commands: |
|
34 | 34 | # |
|
35 | 35 | # If it exists, the function _hg_cmd_foo will be called without |
|
36 | 36 | # arguments to generate the completion candidates for the hg command |
|
37 | 37 | # "foo". If the command receives some arguments that aren't options |
|
38 | 38 | # even though they start with a "-", you can define a function called |
|
39 | 39 | # _hg_opt_foo to generate the completion candidates. If _hg_opt_foo |
|
40 | 40 | # doesn't return 0, regular completion for options is attempted. |
|
41 | 41 | # |
|
42 | 42 | # In addition to the regular completion variables provided by bash, |
|
43 | 43 | # the following variables are also set: |
|
44 | 44 | # - $hg - the hg program being used (e.g. /usr/bin/hg) |
|
45 | 45 | # - $cmd - the name of the hg command being completed |
|
46 | 46 | # - $cmd_index - the index of $cmd in $COMP_WORDS |
|
47 | 47 | # - $cur - the current argument being completed |
|
48 | 48 | # - $prev - the argument before $cur |
|
49 | 49 | # - $global_args - "|"-separated list of global options that accept |
|
50 | 50 | # an argument (e.g. '--cwd|-R|--repository') |
|
51 | 51 | # - $canonical - 1 if we canonicalized $cmd before calling the function |
|
52 | 52 | # 0 otherwise |
|
53 | 53 | # |
|
54 | 54 | |
|
55 | 55 | shopt -s extglob |
|
56 | 56 | |
|
57 | 57 | _hg_cmd() |
|
58 | 58 | { |
|
59 | 59 | HGPLAIN=1 "$hg" "$@" 2>/dev/null |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | _hg_commands() |
|
63 | 63 | { |
|
64 | 64 | local commands |
|
65 | 65 | commands="$(_hg_cmd debugcomplete "$cur")" || commands="" |
|
66 | 66 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$commands' -- "$cur")) |
|
67 | 67 | } |
|
68 | 68 | |
|
69 | 69 | _hg_paths() |
|
70 | 70 | { |
|
71 | 71 | local paths="$(_hg_cmd paths | sed -e 's/ = .*$//')" |
|
72 | 72 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$paths' -- "$cur")) |
|
73 | 73 | } |
|
74 | 74 | |
|
75 | 75 | _hg_repos() |
|
76 | 76 | { |
|
77 | 77 | local i |
|
78 | 78 | for i in $(compgen -d -- "$cur"); do |
|
79 | 79 | test ! -d "$i"/.hg || COMPREPLY=(${COMPREPLY[@]:-} "$i") |
|
80 | 80 | done |
|
81 | 81 | } |
|
82 | 82 | |
|
83 | 83 | _hg_status() |
|
84 | 84 | { |
|
85 | 85 | local files="$(_hg_cmd status -n$1 .)" |
|
86 | 86 | local IFS=$'\n' |
|
87 | 87 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) |
|
88 | 88 | } |
|
89 | 89 | |
|
90 | 90 | _hg_tags() |
|
91 | 91 | { |
|
92 | 92 | local tags="$(_hg_cmd tags -q)" |
|
93 | 93 | local IFS=$'\n' |
|
94 | 94 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$tags' -- "$cur")) |
|
95 | 95 | } |
|
96 | 96 | |
|
97 | 97 | _hg_branches() |
|
98 | 98 | { |
|
99 | 99 | local branches="$(_hg_cmd branches -q)" |
|
100 | 100 | local IFS=$'\n' |
|
101 | 101 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$branches' -- "$cur")) |
|
102 | 102 | } |
|
103 | 103 | |
|
104 | 104 | # this is "kind of" ugly... |
|
105 | 105 | _hg_count_non_option() |
|
106 | 106 | { |
|
107 | 107 | local i count=0 |
|
108 | 108 | local filters="$1" |
|
109 | 109 | |
|
110 | 110 | for ((i=1; $i<=$COMP_CWORD; i++)); do |
|
111 | 111 | if [[ "${COMP_WORDS[i]}" != -* ]]; then |
|
112 | 112 | if [[ ${COMP_WORDS[i-1]} == @($filters|$global_args) ]]; then |
|
113 | 113 | continue |
|
114 | 114 | fi |
|
115 | 115 | count=$(($count + 1)) |
|
116 | 116 | fi |
|
117 | 117 | done |
|
118 | 118 | |
|
119 | 119 | echo $(($count - 1)) |
|
120 | 120 | } |
|
121 | 121 | |
|
122 | 122 | _hg() |
|
123 | 123 | { |
|
124 | 124 | local cur prev cmd cmd_index opts i |
|
125 | 125 | # global options that receive an argument |
|
126 | 126 | local global_args='--cwd|-R|--repository' |
|
127 | 127 | local hg="$1" |
|
128 | 128 | local canonical=0 |
|
129 | 129 | |
|
130 | 130 | COMPREPLY=() |
|
131 | 131 | cur="$2" |
|
132 | 132 | prev="$3" |
|
133 | 133 | |
|
134 | 134 | # searching for the command |
|
135 | 135 | # (first non-option argument that doesn't follow a global option that |
|
136 | 136 | # receives an argument) |
|
137 | 137 | for ((i=1; $i<=$COMP_CWORD; i++)); do |
|
138 | 138 | if [[ ${COMP_WORDS[i]} != -* ]]; then |
|
139 | 139 | if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
|
140 | 140 | cmd="${COMP_WORDS[i]}" |
|
141 | 141 | cmd_index=$i |
|
142 | 142 | break |
|
143 | 143 | fi |
|
144 | 144 | fi |
|
145 | 145 | done |
|
146 | 146 | |
|
147 | 147 | if [[ "$cur" == -* ]]; then |
|
148 | 148 | if [ "$(type -t "_hg_opt_$cmd")" = function ] && "_hg_opt_$cmd"; then |
|
149 | 149 | return |
|
150 | 150 | fi |
|
151 | 151 | |
|
152 | 152 | opts=$(_hg_cmd debugcomplete --options "$cmd") |
|
153 | 153 | |
|
154 | 154 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$opts' -- "$cur")) |
|
155 | 155 | return |
|
156 | 156 | fi |
|
157 | 157 | |
|
158 | 158 | # global options |
|
159 | 159 | case "$prev" in |
|
160 | 160 | -R|--repository) |
|
161 | 161 | _hg_paths |
|
162 | 162 | _hg_repos |
|
163 | 163 | return |
|
164 | 164 | ;; |
|
165 | 165 | --cwd) |
|
166 | 166 | # Stick with default bash completion |
|
167 | 167 | return |
|
168 | 168 | ;; |
|
169 | 169 | esac |
|
170 | 170 | |
|
171 | 171 | if [ -z "$cmd" ] || [ $COMP_CWORD -eq $i ]; then |
|
172 | 172 | _hg_commands |
|
173 | 173 | return |
|
174 | 174 | fi |
|
175 | 175 | |
|
176 | 176 | # try to generate completion candidates for whatever command the user typed |
|
177 | 177 | local help |
|
178 | 178 | if _hg_command_specific; then |
|
179 | 179 | return |
|
180 | 180 | fi |
|
181 | 181 | |
|
182 | 182 | # canonicalize the command name and try again |
|
183 | 183 | help=$(_hg_cmd help "$cmd") |
|
184 | 184 | if [ $? -ne 0 ]; then |
|
185 | 185 | # Probably either the command doesn't exist or it's ambiguous |
|
186 | 186 | return |
|
187 | 187 | fi |
|
188 | 188 | cmd=${help#hg } |
|
189 | 189 | cmd=${cmd%%[$' \n']*} |
|
190 | 190 | canonical=1 |
|
191 | 191 | _hg_command_specific |
|
192 | 192 | } |
|
193 | 193 | |
|
194 | 194 | _hg_command_specific() |
|
195 | 195 | { |
|
196 | 196 | if [ "$(type -t "_hg_cmd_$cmd")" = function ]; then |
|
197 | 197 | "_hg_cmd_$cmd" |
|
198 | 198 | return 0 |
|
199 | 199 | fi |
|
200 | 200 | |
|
201 | 201 | if [ "$cmd" != status ] && [ "$prev" = -r ] || [ "$prev" == --rev ]; then |
|
202 | 202 | if [ $canonical = 1 ]; then |
|
203 | 203 | _hg_tags |
|
204 | 204 | _hg_branches |
|
205 | 205 | return 0 |
|
206 | 206 | elif [[ status != "$cmd"* ]]; then |
|
207 | 207 | _hg_tags |
|
208 | 208 | _hg_branches |
|
209 | 209 | return 0 |
|
210 | 210 | else |
|
211 | 211 | return 1 |
|
212 | 212 | fi |
|
213 | 213 | fi |
|
214 | 214 | |
|
215 | 215 | case "$cmd" in |
|
216 | 216 | help) |
|
217 | 217 | _hg_commands |
|
218 | 218 | ;; |
|
219 | 219 | export) |
|
220 | 220 | if _hg_ext_mq_patchlist qapplied && [ "${COMPREPLY[*]}" ]; then |
|
221 | 221 | return 0 |
|
222 | 222 | fi |
|
223 | 223 | _hg_tags |
|
224 | 224 | _hg_branches |
|
225 | 225 | ;; |
|
226 | 226 | manifest|update) |
|
227 | 227 | _hg_tags |
|
228 | 228 | _hg_branches |
|
229 | 229 | ;; |
|
230 | 230 | pull|push|outgoing|incoming) |
|
231 | 231 | _hg_paths |
|
232 | 232 | _hg_repos |
|
233 | 233 | ;; |
|
234 | 234 | paths) |
|
235 | 235 | _hg_paths |
|
236 | 236 | ;; |
|
237 | 237 | add) |
|
238 | 238 | _hg_status "u" |
|
239 | 239 | ;; |
|
240 | 240 | merge) |
|
241 | 241 | _hg_tags |
|
242 | 242 | _hg_branches |
|
243 | 243 | ;; |
|
244 | 244 | commit) |
|
245 | 245 | _hg_status "mar" |
|
246 | 246 | ;; |
|
247 | 247 | remove) |
|
248 | 248 | _hg_status "d" |
|
249 | 249 | ;; |
|
250 | 250 | forget) |
|
251 | 251 | _hg_status "a" |
|
252 | 252 | ;; |
|
253 | 253 | diff) |
|
254 | 254 | _hg_status "mar" |
|
255 | 255 | ;; |
|
256 | 256 | revert) |
|
257 | 257 | _hg_status "mard" |
|
258 | 258 | ;; |
|
259 | 259 | clone) |
|
260 | 260 | local count=$(_hg_count_non_option) |
|
261 | 261 | if [ $count = 1 ]; then |
|
262 | 262 | _hg_paths |
|
263 | 263 | fi |
|
264 | 264 | _hg_repos |
|
265 | 265 | ;; |
|
266 | 266 | debugindex|debugindexdot) |
|
267 | 267 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.i" -- "$cur")) |
|
268 | 268 | ;; |
|
269 | 269 | debugdata) |
|
270 | 270 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -f -X "!*.d" -- "$cur")) |
|
271 | 271 | ;; |
|
272 | 272 | *) |
|
273 | 273 | return 1 |
|
274 | 274 | ;; |
|
275 | 275 | esac |
|
276 | 276 | |
|
277 | 277 | return 0 |
|
278 | 278 | } |
|
279 | 279 | |
|
280 | 280 | complete -o bashdefault -o default -F _hg hg \ |
|
281 | 281 | || complete -o default -F _hg hg |
|
282 | 282 | |
|
283 | 283 | |
|
284 | 284 | # Completion for commands provided by extensions |
|
285 | 285 | |
|
286 | 286 | # bookmarks |
|
287 | 287 | _hg_bookmarks() |
|
288 | 288 | { |
|
289 | 289 | local bookmarks="$(_hg_cmd bookmarks --quiet )" |
|
290 | 290 | local IFS=$'\n' |
|
291 | 291 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$bookmarks' -- "$cur")) |
|
292 | 292 | } |
|
293 | 293 | |
|
294 | 294 | _hg_cmd_bookmarks() |
|
295 | 295 | { |
|
296 | 296 | if [[ "$prev" = @(-d|--delete|-m|--rename) ]]; then |
|
297 | 297 | _hg_bookmarks |
|
298 | 298 | return |
|
299 | 299 | fi |
|
300 | 300 | } |
|
301 | 301 | |
|
302 | 302 | # mq |
|
303 | 303 | _hg_ext_mq_patchlist() |
|
304 | 304 | { |
|
305 | 305 | local patches |
|
306 | 306 | patches=$(_hg_cmd $1) |
|
307 | 307 | if [ $? -eq 0 ] && [ "$patches" ]; then |
|
308 | 308 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$patches' -- "$cur")) |
|
309 | 309 | return 0 |
|
310 | 310 | fi |
|
311 | 311 | return 1 |
|
312 | 312 | } |
|
313 | 313 | |
|
314 | 314 | _hg_ext_mq_queues() |
|
315 | 315 | { |
|
316 | 316 | local root=$(_hg_cmd root) |
|
317 | 317 | local n |
|
318 | 318 | for n in $(cd "$root"/.hg && compgen -d -- "$cur"); do |
|
319 | 319 | # I think we're usually not interested in the regular "patches" queue |
|
320 | 320 | # so just filter it. |
|
321 | 321 | if [ "$n" != patches ] && [ -e "$root/.hg/$n/series" ]; then |
|
322 | 322 | COMPREPLY=(${COMPREPLY[@]:-} "$n") |
|
323 | 323 | fi |
|
324 | 324 | done |
|
325 | 325 | } |
|
326 | 326 | |
|
327 | 327 | _hg_cmd_qpop() |
|
328 | 328 | { |
|
329 | 329 | if [[ "$prev" = @(-n|--name) ]]; then |
|
330 | 330 | _hg_ext_mq_queues |
|
331 | 331 | return |
|
332 | 332 | fi |
|
333 | 333 | _hg_ext_mq_patchlist qapplied |
|
334 | 334 | } |
|
335 | 335 | |
|
336 | 336 | _hg_cmd_qpush() |
|
337 | 337 | { |
|
338 | 338 | if [[ "$prev" = @(-n|--name) ]]; then |
|
339 | 339 | _hg_ext_mq_queues |
|
340 | 340 | return |
|
341 | 341 | fi |
|
342 | 342 | _hg_ext_mq_patchlist qunapplied |
|
343 | 343 | } |
|
344 | 344 | |
|
345 | 345 | _hg_cmd_qgoto() |
|
346 | 346 | { |
|
347 | 347 | if [[ "$prev" = @(-n|--name) ]]; then |
|
348 | 348 | _hg_ext_mq_queues |
|
349 | 349 | return |
|
350 | 350 | fi |
|
351 | 351 | _hg_ext_mq_patchlist qseries |
|
352 | 352 | } |
|
353 | 353 | |
|
354 | 354 | _hg_cmd_qdelete() |
|
355 | 355 | { |
|
356 | 356 | local qcmd=qunapplied |
|
357 | 357 | if [[ "$prev" = @(-r|--rev) ]]; then |
|
358 | 358 | qcmd=qapplied |
|
359 | 359 | fi |
|
360 | 360 | _hg_ext_mq_patchlist $qcmd |
|
361 | 361 | } |
|
362 | 362 | |
|
363 | 363 | _hg_cmd_qfinish() |
|
364 | 364 | { |
|
365 | 365 | if [[ "$prev" = @(-a|--applied) ]]; then |
|
366 | 366 | return |
|
367 | 367 | fi |
|
368 | 368 | _hg_ext_mq_patchlist qapplied |
|
369 | 369 | } |
|
370 | 370 | |
|
371 | 371 | _hg_cmd_qsave() |
|
372 | 372 | { |
|
373 | 373 | if [[ "$prev" = @(-n|--name) ]]; then |
|
374 | 374 | _hg_ext_mq_queues |
|
375 | 375 | return |
|
376 | 376 | fi |
|
377 | 377 | } |
|
378 | 378 | |
|
379 | 379 | _hg_cmd_strip() |
|
380 | 380 | { |
|
381 | 381 | _hg_tags |
|
382 | 382 | _hg_branches |
|
383 | 383 | } |
|
384 | 384 | |
|
385 | 385 | _hg_cmd_qcommit() |
|
386 | 386 | { |
|
387 | 387 | local root=$(_hg_cmd root) |
|
388 | 388 | # this is run in a sub-shell, so we can't use _hg_status |
|
389 | 389 | local files=$(cd "$root/.hg/patches" && _hg_cmd status -nmar) |
|
390 | 390 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur")) |
|
391 | 391 | } |
|
392 | 392 | |
|
393 | 393 | _hg_cmd_qfold() |
|
394 | 394 | { |
|
395 | 395 | _hg_ext_mq_patchlist qunapplied |
|
396 | 396 | } |
|
397 | 397 | |
|
398 | 398 | _hg_cmd_qrename() |
|
399 | 399 | { |
|
400 | 400 | _hg_ext_mq_patchlist qseries |
|
401 | 401 | } |
|
402 | 402 | |
|
403 | 403 | _hg_cmd_qheader() |
|
404 | 404 | { |
|
405 | 405 | _hg_ext_mq_patchlist qseries |
|
406 | 406 | } |
|
407 | 407 | |
|
408 | 408 | _hg_cmd_qclone() |
|
409 | 409 | { |
|
410 | 410 | local count=$(_hg_count_non_option) |
|
411 | 411 | if [ $count = 1 ]; then |
|
412 | 412 | _hg_paths |
|
413 | 413 | fi |
|
414 | 414 | _hg_repos |
|
415 | 415 | } |
|
416 | 416 | |
|
417 | 417 | _hg_ext_mq_guards() |
|
418 | 418 | { |
|
419 | 419 | _hg_cmd qselect --series | sed -e 's/^.//' |
|
420 | 420 | } |
|
421 | 421 | |
|
422 | 422 | _hg_cmd_qselect() |
|
423 | 423 | { |
|
424 | 424 | local guards=$(_hg_ext_mq_guards) |
|
425 | 425 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$guards' -- "$cur")) |
|
426 | 426 | } |
|
427 | 427 | |
|
428 | 428 | _hg_cmd_qguard() |
|
429 | 429 | { |
|
430 | 430 | local prefix='' |
|
431 | 431 | |
|
432 | 432 | if [[ "$cur" == +* ]]; then |
|
433 | 433 | prefix=+ |
|
434 | 434 | elif [[ "$cur" == -* ]]; then |
|
435 | 435 | prefix=- |
|
436 | 436 | fi |
|
437 | 437 | local ncur=${cur#[-+]} |
|
438 | 438 | |
|
439 | 439 | if ! [ "$prefix" ]; then |
|
440 | 440 | _hg_ext_mq_patchlist qseries |
|
441 | 441 | return |
|
442 | 442 | fi |
|
443 | 443 | |
|
444 | 444 | local guards=$(_hg_ext_mq_guards) |
|
445 | 445 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -P $prefix -W '$guards' -- "$ncur")) |
|
446 | 446 | } |
|
447 | 447 | |
|
448 | 448 | _hg_opt_qguard() |
|
449 | 449 | { |
|
450 | 450 | local i |
|
451 | 451 | for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do |
|
452 | 452 | if [[ ${COMP_WORDS[i]} != -* ]]; then |
|
453 | 453 | if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
|
454 | 454 | _hg_cmd_qguard |
|
455 | 455 | return 0 |
|
456 | 456 | fi |
|
457 | 457 | elif [ "${COMP_WORDS[i]}" = -- ]; then |
|
458 | 458 | _hg_cmd_qguard |
|
459 | 459 | return 0 |
|
460 | 460 | fi |
|
461 | 461 | done |
|
462 | 462 | return 1 |
|
463 | 463 | } |
|
464 | 464 | |
|
465 | 465 | _hg_cmd_qqueue() |
|
466 | 466 | { |
|
467 | 467 | local q |
|
468 | 468 | local queues |
|
469 | local opts="--list --create --delete" | |
|
469 | local opts="--list --create --rename --delete --purge" | |
|
470 | 470 | |
|
471 | 471 | queues=$( _hg_cmd qqueue --quiet ) |
|
472 | 472 | |
|
473 | 473 | COMPREPLY=( $( compgen -W "${opts} ${queues}" "${cur}" ) ) |
|
474 | 474 | } |
|
475 | 475 | |
|
476 | 476 | |
|
477 | 477 | # hbisect |
|
478 | 478 | _hg_cmd_bisect() |
|
479 | 479 | { |
|
480 | 480 | local i subcmd |
|
481 | 481 | |
|
482 | 482 | # find the sub-command |
|
483 | 483 | for ((i=cmd_index+1; i<=COMP_CWORD; i++)); do |
|
484 | 484 | if [[ ${COMP_WORDS[i]} != -* ]]; then |
|
485 | 485 | if [[ ${COMP_WORDS[i-1]} != @($global_args) ]]; then |
|
486 | 486 | subcmd="${COMP_WORDS[i]}" |
|
487 | 487 | break |
|
488 | 488 | fi |
|
489 | 489 | fi |
|
490 | 490 | done |
|
491 | 491 | |
|
492 | 492 | if [ -z "$subcmd" ] || [ $COMP_CWORD -eq $i ] || [ "$subcmd" = help ]; then |
|
493 | 493 | COMPREPLY=(${COMPREPLY[@]:-} |
|
494 | 494 | $(compgen -W 'bad good help init next reset' -- "$cur")) |
|
495 | 495 | return |
|
496 | 496 | fi |
|
497 | 497 | |
|
498 | 498 | case "$subcmd" in |
|
499 | 499 | good|bad) |
|
500 | 500 | _hg_tags |
|
501 | 501 | _hg_branches |
|
502 | 502 | ;; |
|
503 | 503 | esac |
|
504 | 504 | |
|
505 | 505 | return |
|
506 | 506 | } |
|
507 | 507 | |
|
508 | 508 | |
|
509 | 509 | # patchbomb |
|
510 | 510 | _hg_cmd_email() |
|
511 | 511 | { |
|
512 | 512 | case "$prev" in |
|
513 | 513 | -c|--cc|-t|--to|-f|--from|--bcc) |
|
514 | 514 | # we need an e-mail address. let the user provide a function |
|
515 | 515 | # to get them |
|
516 | 516 | if [ "$(type -t _hg_emails)" = function ]; then |
|
517 | 517 | local arg=to |
|
518 | 518 | if [[ "$prev" == @(-f|--from) ]]; then |
|
519 | 519 | arg=from |
|
520 | 520 | fi |
|
521 | 521 | local addresses=$(_hg_emails $arg) |
|
522 | 522 | COMPREPLY=(${COMPREPLY[@]:-} |
|
523 | 523 | $(compgen -W '$addresses' -- "$cur")) |
|
524 | 524 | fi |
|
525 | 525 | return |
|
526 | 526 | ;; |
|
527 | 527 | -m|--mbox) |
|
528 | 528 | # fallback to standard filename completion |
|
529 | 529 | return |
|
530 | 530 | ;; |
|
531 | 531 | -s|--subject) |
|
532 | 532 | # free form string |
|
533 | 533 | return |
|
534 | 534 | ;; |
|
535 | 535 | esac |
|
536 | 536 | |
|
537 | 537 | _hg_tags |
|
538 | 538 | _hg_branches |
|
539 | 539 | return |
|
540 | 540 | } |
|
541 | 541 | |
|
542 | 542 | |
|
543 | 543 | # gpg |
|
544 | 544 | _hg_cmd_sign() |
|
545 | 545 | { |
|
546 | 546 | _hg_tags |
|
547 | 547 | _hg_branches |
|
548 | 548 | } |
|
549 | 549 | |
|
550 | 550 | |
|
551 | 551 | # transplant |
|
552 | 552 | _hg_cmd_transplant() |
|
553 | 553 | { |
|
554 | 554 | case "$prev" in |
|
555 | 555 | -s|--source) |
|
556 | 556 | _hg_paths |
|
557 | 557 | _hg_repos |
|
558 | 558 | return |
|
559 | 559 | ;; |
|
560 | 560 | --filter) |
|
561 | 561 | # standard filename completion |
|
562 | 562 | return |
|
563 | 563 | ;; |
|
564 | 564 | esac |
|
565 | 565 | |
|
566 | 566 | # all other transplant options values and command parameters are revisions |
|
567 | 567 | _hg_tags |
|
568 | 568 | _hg_branches |
|
569 | 569 | return |
|
570 | 570 | } |
|
571 | 571 | |
|
572 | 572 | # shelve |
|
573 | 573 | _hg_shelves() |
|
574 | 574 | { |
|
575 | 575 | local shelves="$(_hg_cmd unshelve -l .)" |
|
576 | 576 | local IFS=$'\n' |
|
577 | 577 | COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$shelves' -- "$cur")) |
|
578 | 578 | } |
|
579 | 579 | |
|
580 | 580 | _hg_cmd_shelve() |
|
581 | 581 | { |
|
582 | 582 | _hg_status "mard" |
|
583 | 583 | } |
|
584 | 584 | |
|
585 | 585 | _hg_cmd_unshelve() |
|
586 | 586 | { |
|
587 | 587 | _hg_shelves |
|
588 | 588 | } |
General Comments 0
You need to be logged in to leave comments.
Login now