Show More
@@ -15,6 +15,7 b' from . import (' | |||||
15 | node, |
|
15 | node, | |
16 | parser, |
|
16 | parser, | |
17 | pycompat, |
|
17 | pycompat, | |
|
18 | smartset, | |||
18 | util, |
|
19 | util, | |
19 | ) |
|
20 | ) | |
20 | from .utils import ( |
|
21 | from .utils import ( | |
@@ -682,6 +683,10 b' def formatspec(expr, *args):' | |||||
682 | for t, arg in parsed: |
|
683 | for t, arg in parsed: | |
683 | if t is None: |
|
684 | if t is None: | |
684 | ret.append(arg) |
|
685 | ret.append(arg) | |
|
686 | elif t == 'baseset': | |||
|
687 | if isinstance(arg, set): | |||
|
688 | arg = sorted(arg) | |||
|
689 | ret.append(_formatintlist(list(arg))) | |||
685 | else: |
|
690 | else: | |
686 | raise error.ProgrammingError("unknown revspec item type: %r" % t) |
|
691 | raise error.ProgrammingError("unknown revspec item type: %r" % t) | |
687 | return b''.join(ret) |
|
692 | return b''.join(ret) | |
@@ -693,6 +698,7 b' def _parseargs(expr, args):' | |||||
693 |
|
698 | |||
694 | Arg-type can be: |
|
699 | Arg-type can be: | |
695 | * None: a string ready to be concatenated into a final spec |
|
700 | * None: a string ready to be concatenated into a final spec | |
|
701 | * 'baseset': an iterable of revisions | |||
696 | """ |
|
702 | """ | |
697 | expr = pycompat.bytestr(expr) |
|
703 | expr = pycompat.bytestr(expr) | |
698 | argiter = iter(args) |
|
704 | argiter = iter(args) | |
@@ -722,10 +728,25 b' def _parseargs(expr, args):' | |||||
722 | if f: |
|
728 | if f: | |
723 | # a list of some type, might be expensive, do not replace |
|
729 | # a list of some type, might be expensive, do not replace | |
724 | pos += 1 |
|
730 | pos += 1 | |
|
731 | islist = (d == 'l') | |||
725 | try: |
|
732 | try: | |
726 | d = expr[pos] |
|
733 | d = expr[pos] | |
727 | except IndexError: |
|
734 | except IndexError: | |
728 | raise error.ParseError(_('incomplete revspec format character')) |
|
735 | raise error.ParseError(_('incomplete revspec format character')) | |
|
736 | if islist and d == 'd' and arg: | |||
|
737 | # special case, we might be able to speedup the list of int case | |||
|
738 | # | |||
|
739 | # We have been very conservative here for the first version. | |||
|
740 | # Other types (eg: generator) are probably fine, but we did not | |||
|
741 | # wanted to take any risk> | |||
|
742 | safeinputtype = (list, tuple, set, smartset.abstractsmartset) | |||
|
743 | if isinstance(arg, safeinputtype): | |||
|
744 | # we don't create a baseset yet, because it come with an | |||
|
745 | # extra cost. If we are going to serialize it we better | |||
|
746 | # skip it. | |||
|
747 | ret.append(('baseset', arg)) | |||
|
748 | pos += 1 | |||
|
749 | continue | |||
729 | try: |
|
750 | try: | |
730 | ret.append((None, f(list(arg), d))) |
|
751 | ret.append((None, f(list(arg), d))) | |
731 | except (TypeError, ValueError): |
|
752 | except (TypeError, ValueError): |
General Comments 0
You need to be logged in to leave comments.
Login now