Show More
@@ -1362,9 +1362,8 b' class localrepository(object):' | |||||
1362 | Returns a revset.abstractsmartset, which is a list-like interface |
|
1362 | Returns a revset.abstractsmartset, which is a list-like interface | |
1363 | that contains integer revisions. |
|
1363 | that contains integer revisions. | |
1364 | ''' |
|
1364 | ''' | |
1365 |
|
|
1365 | tree = revsetlang.spectree(expr, *args) | |
1366 |
|
|
1366 | return revset.makematcher(tree)(self) | |
1367 | return m(self) |
|
|||
1368 |
|
1367 | |||
1369 | def set(self, expr, *args): |
|
1368 | def set(self, expr, *args): | |
1370 | '''Find revisions matching a revset and emit changectx instances. |
|
1369 | '''Find revisions matching a revset and emit changectx instances. |
@@ -125,6 +125,13 b' def stringset(repo, subset, x, order):' | |||||
125 | return baseset([x]) |
|
125 | return baseset([x]) | |
126 | return baseset() |
|
126 | return baseset() | |
127 |
|
127 | |||
|
128 | def rawsmartset(repo, subset, x, order): | |||
|
129 | """argument is already a smartset, use that directly""" | |||
|
130 | if order == followorder: | |||
|
131 | return subset & x | |||
|
132 | else: | |||
|
133 | return x & subset | |||
|
134 | ||||
128 | def rangeset(repo, subset, x, y, order): |
|
135 | def rangeset(repo, subset, x, y, order): | |
129 | m = getset(repo, fullreposet(repo), x) |
|
136 | m = getset(repo, fullreposet(repo), x) | |
130 | n = getset(repo, fullreposet(repo), y) |
|
137 | n = getset(repo, fullreposet(repo), y) | |
@@ -2216,6 +2223,7 b' methods = {' | |||||
2216 | "ancestor": ancestorspec, |
|
2223 | "ancestor": ancestorspec, | |
2217 | "parent": parentspec, |
|
2224 | "parent": parentspec, | |
2218 | "parentpost": parentpost, |
|
2225 | "parentpost": parentpost, | |
|
2226 | "smartset": rawsmartset, | |||
2219 | } |
|
2227 | } | |
2220 |
|
2228 | |||
2221 | subscriptrelations = { |
|
2229 | subscriptrelations = { |
@@ -333,7 +333,7 b' def _analyze(x):' | |||||
333 | elif op == 'negate': |
|
333 | elif op == 'negate': | |
334 | s = getstring(x[1], _("can't negate that")) |
|
334 | s = getstring(x[1], _("can't negate that")) | |
335 | return _analyze(('string', '-' + s)) |
|
335 | return _analyze(('string', '-' + s)) | |
336 | elif op in ('string', 'symbol'): |
|
336 | elif op in ('string', 'symbol', 'smartset'): | |
337 | return x |
|
337 | return x | |
338 | elif op == 'rangeall': |
|
338 | elif op == 'rangeall': | |
339 | return (op, None) |
|
339 | return (op, None) | |
@@ -373,7 +373,7 b' def _optimize(x):' | |||||
373 | return 0, x |
|
373 | return 0, x | |
374 |
|
374 | |||
375 | op = x[0] |
|
375 | op = x[0] | |
376 | if op in ('string', 'symbol'): |
|
376 | if op in ('string', 'symbol', 'smartset'): | |
377 | return 0.5, x # single revisions are small |
|
377 | return 0.5, x # single revisions are small | |
378 | elif op == 'and': |
|
378 | elif op == 'and': | |
379 | wa, ta = _optimize(x[1]) |
|
379 | wa, ta = _optimize(x[1]) | |
@@ -535,7 +535,8 b' def expandaliases(tree, aliases, warn=No' | |||||
535 | def foldconcat(tree): |
|
535 | def foldconcat(tree): | |
536 | """Fold elements to be concatenated by `##` |
|
536 | """Fold elements to be concatenated by `##` | |
537 | """ |
|
537 | """ | |
538 |
if not isinstance(tree, tuple) |
|
538 | if (not isinstance(tree, tuple) | |
|
539 | or tree[0] in ('string', 'symbol', 'smartset')): | |||
539 | return tree |
|
540 | return tree | |
540 | if tree[0] == '_concat': |
|
541 | if tree[0] == '_concat': | |
541 | pending = [tree] |
|
542 | pending = [tree] | |
@@ -691,6 +692,28 b' def formatspec(expr, *args):' | |||||
691 | raise error.ProgrammingError("unknown revspec item type: %r" % t) |
|
692 | raise error.ProgrammingError("unknown revspec item type: %r" % t) | |
692 | return b''.join(ret) |
|
693 | return b''.join(ret) | |
693 |
|
694 | |||
|
695 | def spectree(expr, *args): | |||
|
696 | """similar to formatspec but return a parsed and optimized tree""" | |||
|
697 | parsed = _parseargs(expr, args) | |||
|
698 | ret = [] | |||
|
699 | inputs = [] | |||
|
700 | for t, arg in parsed: | |||
|
701 | if t is None: | |||
|
702 | ret.append(arg) | |||
|
703 | elif t == 'baseset': | |||
|
704 | newtree = ('smartset', smartset.baseset(arg)) | |||
|
705 | inputs.append(newtree) | |||
|
706 | ret.append("$") | |||
|
707 | else: | |||
|
708 | raise error.ProgrammingError("unknown revspec item type: %r" % t) | |||
|
709 | expr = b''.join(ret) | |||
|
710 | tree = _parsewith(expr, syminitletters=_aliassyminitletters) | |||
|
711 | tree = parser.buildtree(tree, ('symbol', '$'), *inputs) | |||
|
712 | tree = foldconcat(tree) | |||
|
713 | tree = analyze(tree) | |||
|
714 | tree = optimize(tree) | |||
|
715 | return tree | |||
|
716 | ||||
694 | def _parseargs(expr, args): |
|
717 | def _parseargs(expr, args): | |
695 | """parse the expression and replace all inexpensive args |
|
718 | """parse the expression and replace all inexpensive args | |
696 |
|
719 |
General Comments 0
You need to be logged in to leave comments.
Login now