Show More
@@ -643,11 +643,11 b' def _parseconfig(ui, config):' | |||||
643 |
|
643 | |||
644 | return configs |
|
644 | return configs | |
645 |
|
645 | |||
646 | def _earlygetopt(aliases, args): |
|
646 | def _earlygetopt(aliases, args, strip=True): | |
647 | """Return list of values for an option (or aliases). |
|
647 | """Return list of values for an option (or aliases). | |
648 |
|
648 | |||
649 | The values are listed in the order they appear in args. |
|
649 | The values are listed in the order they appear in args. | |
650 | The options and values are removed from args. |
|
650 | The options and values are removed from args if strip=True. | |
651 |
|
651 | |||
652 | >>> args = [b'x', b'--cwd', b'foo', b'y'] |
|
652 | >>> args = [b'x', b'--cwd', b'foo', b'y'] | |
653 | >>> _earlygetopt([b'--cwd'], args), args |
|
653 | >>> _earlygetopt([b'--cwd'], args), args | |
@@ -657,14 +657,26 b' def _earlygetopt(aliases, args):' | |||||
657 | >>> _earlygetopt([b'--cwd'], args), args |
|
657 | >>> _earlygetopt([b'--cwd'], args), args | |
658 | (['bar'], ['x', 'y']) |
|
658 | (['bar'], ['x', 'y']) | |
659 |
|
659 | |||
|
660 | >>> args = [b'x', b'--cwd=bar', b'y'] | |||
|
661 | >>> _earlygetopt([b'--cwd'], args, strip=False), args | |||
|
662 | (['bar'], ['x', '--cwd=bar', 'y']) | |||
|
663 | ||||
660 | >>> args = [b'x', b'-R', b'foo', b'y'] |
|
664 | >>> args = [b'x', b'-R', b'foo', b'y'] | |
661 | >>> _earlygetopt([b'-R'], args), args |
|
665 | >>> _earlygetopt([b'-R'], args), args | |
662 | (['foo'], ['x', 'y']) |
|
666 | (['foo'], ['x', 'y']) | |
663 |
|
667 | |||
|
668 | >>> args = [b'x', b'-R', b'foo', b'y'] | |||
|
669 | >>> _earlygetopt([b'-R'], args, strip=False), args | |||
|
670 | (['foo'], ['x', '-R', 'foo', 'y']) | |||
|
671 | ||||
664 | >>> args = [b'x', b'-Rbar', b'y'] |
|
672 | >>> args = [b'x', b'-Rbar', b'y'] | |
665 | >>> _earlygetopt([b'-R'], args), args |
|
673 | >>> _earlygetopt([b'-R'], args), args | |
666 | (['bar'], ['x', 'y']) |
|
674 | (['bar'], ['x', 'y']) | |
667 |
|
675 | |||
|
676 | >>> args = [b'x', b'-Rbar', b'y'] | |||
|
677 | >>> _earlygetopt([b'-R'], args, strip=False), args | |||
|
678 | (['bar'], ['x', '-Rbar', 'y']) | |||
|
679 | ||||
668 | >>> args = [b'x', b'-R=bar', b'y'] |
|
680 | >>> args = [b'x', b'-R=bar', b'y'] | |
669 | >>> _earlygetopt([b'-R'], args), args |
|
681 | >>> _earlygetopt([b'-R'], args), args | |
670 | (['=bar'], ['x', 'y']) |
|
682 | (['=bar'], ['x', 'y']) | |
@@ -689,20 +701,30 b' def _earlygetopt(aliases, args):' | |||||
689 | arg = arg[:equals] |
|
701 | arg = arg[:equals] | |
690 | if arg in aliases: |
|
702 | if arg in aliases: | |
691 | if equals > -1: |
|
703 | if equals > -1: | |
692 | del args[pos] |
|
|||
693 | values.append(fullarg[equals + 1:]) |
|
704 | values.append(fullarg[equals + 1:]) | |
694 |
|
|
705 | if strip: | |
|
706 | del args[pos] | |||
|
707 | argcount -= 1 | |||
|
708 | else: | |||
|
709 | pos += 1 | |||
695 | else: |
|
710 | else: | |
696 | if pos + 1 >= argcount: |
|
711 | if pos + 1 >= argcount: | |
697 | # ignore and let getopt report an error if there is no value |
|
712 | # ignore and let getopt report an error if there is no value | |
698 | break |
|
713 | break | |
699 |
|
|
714 | values.append(args[pos + 1]) | |
700 | values.append(args.pop(pos)) |
|
715 | if strip: | |
701 |
|
|
716 | del args[pos:pos + 2] | |
|
717 | argcount -= 2 | |||
|
718 | else: | |||
|
719 | pos += 2 | |||
702 | elif arg[:2] in shortopts: |
|
720 | elif arg[:2] in shortopts: | |
703 | # short option can have no following space, e.g. hg log -Rfoo |
|
721 | # short option can have no following space, e.g. hg log -Rfoo | |
704 |
values.append(args |
|
722 | values.append(args[pos][2:]) | |
705 | argcount -= 1 |
|
723 | if strip: | |
|
724 | del args[pos] | |||
|
725 | argcount -= 1 | |||
|
726 | else: | |||
|
727 | pos += 1 | |||
706 | else: |
|
728 | else: | |
707 | pos += 1 |
|
729 | pos += 1 | |
708 | return values |
|
730 | return values |
General Comments 0
You need to be logged in to leave comments.
Login now