Show More
@@ -699,8 +699,28 b' def _earlygetopt(aliases, args):' | |||||
699 | return values |
|
699 | return values | |
700 |
|
700 | |||
701 | def _earlyreqoptbool(req, name, aliases): |
|
701 | def _earlyreqoptbool(req, name, aliases): | |
702 | assert len(aliases) == 1 |
|
702 | """Peek a boolean option without using a full options table | |
703 | return aliases[0] in req.args |
|
703 | ||
|
704 | >>> req = request([b'x', b'--debugger']) | |||
|
705 | >>> _earlyreqoptbool(req, b'debugger', [b'--debugger']) | |||
|
706 | True | |||
|
707 | ||||
|
708 | >>> req = request([b'x', b'--', b'--debugger']) | |||
|
709 | >>> _earlyreqoptbool(req, b'debugger', [b'--debugger']) | |||
|
710 | False | |||
|
711 | """ | |||
|
712 | try: | |||
|
713 | argcount = req.args.index("--") | |||
|
714 | except ValueError: | |||
|
715 | argcount = len(req.args) | |||
|
716 | value = False | |||
|
717 | pos = 0 | |||
|
718 | while pos < argcount: | |||
|
719 | arg = req.args[pos] | |||
|
720 | if arg in aliases: | |||
|
721 | value = True | |||
|
722 | pos += 1 | |||
|
723 | return value | |||
704 |
|
724 | |||
705 | def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions): |
|
725 | def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions): | |
706 | # run pre-hook, and abort if it fails |
|
726 | # run pre-hook, and abort if it fails |
@@ -42,6 +42,15 b' Missing parameter for early option:' | |||||
42 | hg log [OPTION]... [FILE] |
|
42 | hg log [OPTION]... [FILE] | |
43 | (use 'hg log -h' to show more help) |
|
43 | (use 'hg log -h' to show more help) | |
44 |
|
44 | |||
|
45 | Parsing of early options should stop at "--": | |||
|
46 | ||||
|
47 | $ hg cat -- --config=hooks.pre-cat=false | |||
|
48 | --config=hooks.pre-cat=false: no such file in rev cb9a9f314b8b | |||
|
49 | [1] | |||
|
50 | $ hg cat -- --debugger | |||
|
51 | --debugger: no such file in rev cb9a9f314b8b | |||
|
52 | [1] | |||
|
53 | ||||
45 | [defaults] |
|
54 | [defaults] | |
46 |
|
55 | |||
47 |
$ |
|
56 | $ hg cat a |
General Comments 0
You need to be logged in to leave comments.
Login now