##// END OF EJS Templates
revset: detect integer list on parsing...
Boris Feld -
r41257:73203cdf default
parent child Browse files
Show More
@@ -15,6 +15,7 b' from . import ('
15 15 node,
16 16 parser,
17 17 pycompat,
18 smartset,
18 19 util,
19 20 )
20 21 from .utils import (
@@ -682,6 +683,10 b' def formatspec(expr, *args):'
682 683 for t, arg in parsed:
683 684 if t is None:
684 685 ret.append(arg)
686 elif t == 'baseset':
687 if isinstance(arg, set):
688 arg = sorted(arg)
689 ret.append(_formatintlist(list(arg)))
685 690 else:
686 691 raise error.ProgrammingError("unknown revspec item type: %r" % t)
687 692 return b''.join(ret)
@@ -692,7 +697,8 b' def _parseargs(expr, args):'
692 697 return a list of tuple [(arg-type, arg-value)]
693 698
694 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 703 expr = pycompat.bytestr(expr)
698 704 argiter = iter(args)
@@ -722,10 +728,25 b' def _parseargs(expr, args):'
722 728 if f:
723 729 # a list of some type, might be expensive, do not replace
724 730 pos += 1
731 islist = (d == 'l')
725 732 try:
726 733 d = expr[pos]
727 734 except IndexError:
728 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 750 try:
730 751 ret.append((None, f(list(arg), d)))
731 752 except (TypeError, ValueError):
General Comments 0
You need to be logged in to leave comments. Login now