Show More
@@ -52,10 +52,10 b' fullreposet = smartset.fullreposet' | |||||
52 |
|
52 | |||
53 | # helpers |
|
53 | # helpers | |
54 |
|
54 | |||
55 | def getset(repo, subset, x): |
|
55 | def getset(repo, subset, x, order=defineorder): | |
56 | if not x: |
|
56 | if not x: | |
57 | raise error.ParseError(_("missing argument")) |
|
57 | raise error.ParseError(_("missing argument")) | |
58 | return methods[x[0]](repo, subset, *x[1:]) |
|
58 | return methods[x[0]](repo, subset, *x[1:], order=order) | |
59 |
|
59 | |||
60 | def _getrevsource(repo, r): |
|
60 | def _getrevsource(repo, r): | |
61 | extra = repo[r].extra() |
|
61 | extra = repo[r].extra() | |
@@ -69,7 +69,7 b' def _getrevsource(repo, r):' | |||||
69 |
|
69 | |||
70 | # operator methods |
|
70 | # operator methods | |
71 |
|
71 | |||
72 | def stringset(repo, subset, x): |
|
72 | def stringset(repo, subset, x, order): | |
73 | x = scmutil.intrev(repo[x]) |
|
73 | x = scmutil.intrev(repo[x]) | |
74 | if (x in subset |
|
74 | if (x in subset | |
75 | or x == node.nullrev and isinstance(subset, fullreposet)): |
|
75 | or x == node.nullrev and isinstance(subset, fullreposet)): | |
@@ -126,30 +126,42 b' def dagrange(repo, subset, x, y, order):' | |||||
126 | return subset & xs |
|
126 | return subset & xs | |
127 |
|
127 | |||
128 | def andset(repo, subset, x, y, order): |
|
128 | def andset(repo, subset, x, y, order): | |
129 | return getset(repo, getset(repo, subset, x), y) |
|
129 | if order == anyorder: | |
|
130 | yorder = anyorder | |||
|
131 | else: | |||
|
132 | yorder = followorder | |||
|
133 | return getset(repo, getset(repo, subset, x, order), y, yorder) | |||
|
134 | ||||
|
135 | def flipandset(repo, subset, y, x, order): | |||
|
136 | # 'flipand(y, x)' is equivalent to 'and(x, y)', but faster when y is small | |||
|
137 | if order == anyorder: | |||
|
138 | yorder = anyorder | |||
|
139 | else: | |||
|
140 | yorder = followorder | |||
|
141 | return getset(repo, getset(repo, subset, y, yorder), x, order) | |||
130 |
|
142 | |||
131 | def differenceset(repo, subset, x, y, order): |
|
143 | def differenceset(repo, subset, x, y, order): | |
132 | return getset(repo, subset, x) - getset(repo, subset, y) |
|
144 | return getset(repo, subset, x, order) - getset(repo, subset, y, anyorder) | |
133 |
|
145 | |||
134 | def _orsetlist(repo, subset, xs): |
|
146 | def _orsetlist(repo, subset, xs, order): | |
135 | assert xs |
|
147 | assert xs | |
136 | if len(xs) == 1: |
|
148 | if len(xs) == 1: | |
137 | return getset(repo, subset, xs[0]) |
|
149 | return getset(repo, subset, xs[0], order) | |
138 | p = len(xs) // 2 |
|
150 | p = len(xs) // 2 | |
139 | a = _orsetlist(repo, subset, xs[:p]) |
|
151 | a = _orsetlist(repo, subset, xs[:p], order) | |
140 | b = _orsetlist(repo, subset, xs[p:]) |
|
152 | b = _orsetlist(repo, subset, xs[p:], order) | |
141 | return a + b |
|
153 | return a + b | |
142 |
|
154 | |||
143 | def orset(repo, subset, x, order): |
|
155 | def orset(repo, subset, x, order): | |
144 | xs = getlist(x) |
|
156 | xs = getlist(x) | |
145 | if order == followorder: |
|
157 | if order == followorder: | |
146 | # slow path to take the subset order |
|
158 | # slow path to take the subset order | |
147 | return subset & _orsetlist(repo, fullreposet(repo), xs) |
|
159 | return subset & _orsetlist(repo, fullreposet(repo), xs, anyorder) | |
148 | else: |
|
160 | else: | |
149 | return _orsetlist(repo, subset, xs) |
|
161 | return _orsetlist(repo, subset, xs, order) | |
150 |
|
162 | |||
151 | def notset(repo, subset, x, order): |
|
163 | def notset(repo, subset, x, order): | |
152 | return subset - getset(repo, subset, x) |
|
164 | return subset - getset(repo, subset, x, anyorder) | |
153 |
|
165 | |||
154 | def relationset(repo, subset, x, y, order): |
|
166 | def relationset(repo, subset, x, y, order): | |
155 | raise error.ParseError(_("can't use a relation in this context")) |
|
167 | raise error.ParseError(_("can't use a relation in this context")) | |
@@ -176,11 +188,11 b' def relsubscriptset(repo, subset, x, y, ' | |||||
176 | def subscriptset(repo, subset, x, y, order): |
|
188 | def subscriptset(repo, subset, x, y, order): | |
177 | raise error.ParseError(_("can't use a subscript in this context")) |
|
189 | raise error.ParseError(_("can't use a subscript in this context")) | |
178 |
|
190 | |||
179 | def listset(repo, subset, *xs): |
|
191 | def listset(repo, subset, *xs, **opts): | |
180 | raise error.ParseError(_("can't use a list in this context"), |
|
192 | raise error.ParseError(_("can't use a list in this context"), | |
181 | hint=_('see hg help "revsets.x or y"')) |
|
193 | hint=_('see hg help "revsets.x or y"')) | |
182 |
|
194 | |||
183 | def keyvaluepair(repo, subset, k, v): |
|
195 | def keyvaluepair(repo, subset, k, v, order): | |
184 | raise error.ParseError(_("can't use a key-value pair in this context")) |
|
196 | raise error.ParseError(_("can't use a key-value pair in this context")) | |
185 |
|
197 | |||
186 | def func(repo, subset, a, b, order): |
|
198 | def func(repo, subset, a, b, order): | |
@@ -1508,8 +1520,8 b' def parentspec(repo, subset, x, n, order' | |||||
1508 | ps.add(parents[1].rev()) |
|
1520 | ps.add(parents[1].rev()) | |
1509 | return subset & ps |
|
1521 | return subset & ps | |
1510 |
|
1522 | |||
1511 | @predicate('present(set)', safe=True) |
|
1523 | @predicate('present(set)', safe=True, takeorder=True) | |
1512 | def present(repo, subset, x): |
|
1524 | def present(repo, subset, x, order): | |
1513 | """An empty set, if any revision in set isn't found; otherwise, |
|
1525 | """An empty set, if any revision in set isn't found; otherwise, | |
1514 | all revisions in set. |
|
1526 | all revisions in set. | |
1515 |
|
1527 | |||
@@ -1518,7 +1530,7 b' def present(repo, subset, x):' | |||||
1518 | to continue even in such cases. |
|
1530 | to continue even in such cases. | |
1519 | """ |
|
1531 | """ | |
1520 | try: |
|
1532 | try: | |
1521 | return getset(repo, subset, x) |
|
1533 | return getset(repo, subset, x, order) | |
1522 | except error.RepoLookupError: |
|
1534 | except error.RepoLookupError: | |
1523 | return baseset() |
|
1535 | return baseset() | |
1524 |
|
1536 | |||
@@ -1718,7 +1730,7 b' def matching(repo, subset, x):' | |||||
1718 | def reverse(repo, subset, x, order): |
|
1730 | def reverse(repo, subset, x, order): | |
1719 | """Reverse order of set. |
|
1731 | """Reverse order of set. | |
1720 | """ |
|
1732 | """ | |
1721 | l = getset(repo, subset, x) |
|
1733 | l = getset(repo, subset, x, order) | |
1722 | if order == defineorder: |
|
1734 | if order == defineorder: | |
1723 | l.reverse() |
|
1735 | l.reverse() | |
1724 | return l |
|
1736 | return l | |
@@ -1802,7 +1814,7 b' def sort(repo, subset, x, order):' | |||||
1802 |
|
1814 | |||
1803 | """ |
|
1815 | """ | |
1804 | s, keyflags, opts = _getsortargs(x) |
|
1816 | s, keyflags, opts = _getsortargs(x) | |
1805 | revs = getset(repo, subset, s) |
|
1817 | revs = getset(repo, subset, s, order) | |
1806 |
|
1818 | |||
1807 | if not keyflags or order != defineorder: |
|
1819 | if not keyflags or order != defineorder: | |
1808 | return revs |
|
1820 | return revs | |
@@ -1988,7 +2000,7 b' def _orderedlist(repo, subset, x):' | |||||
1988 | raise ValueError |
|
2000 | raise ValueError | |
1989 | revs = [r] |
|
2001 | revs = [r] | |
1990 | except ValueError: |
|
2002 | except ValueError: | |
1991 | revs = stringset(repo, subset, t) |
|
2003 | revs = stringset(repo, subset, t, defineorder) | |
1992 |
|
2004 | |||
1993 | for r in revs: |
|
2005 | for r in revs: | |
1994 | if r in seen: |
|
2006 | if r in seen: | |
@@ -2052,6 +2064,7 b' methods = {' | |||||
2052 | "string": stringset, |
|
2064 | "string": stringset, | |
2053 | "symbol": stringset, |
|
2065 | "symbol": stringset, | |
2054 | "and": andset, |
|
2066 | "and": andset, | |
|
2067 | "flipand": flipandset, | |||
2055 | "or": orset, |
|
2068 | "or": orset, | |
2056 | "not": notset, |
|
2069 | "not": notset, | |
2057 | "difference": differenceset, |
|
2070 | "difference": differenceset, | |
@@ -2113,17 +2126,17 b' def matchany(ui, specs, repo=None, order' | |||||
2113 | if aliases: |
|
2126 | if aliases: | |
2114 | tree = revsetlang.expandaliases(tree, aliases, warn=warn) |
|
2127 | tree = revsetlang.expandaliases(tree, aliases, warn=warn) | |
2115 | tree = revsetlang.foldconcat(tree) |
|
2128 | tree = revsetlang.foldconcat(tree) | |
2116 |
tree = revsetlang.analyze(tree |
|
2129 | tree = revsetlang.analyze(tree) | |
2117 | tree = revsetlang.optimize(tree) |
|
2130 | tree = revsetlang.optimize(tree) | |
2118 | posttreebuilthook(tree, repo) |
|
2131 | posttreebuilthook(tree, repo) | |
2119 | return makematcher(tree) |
|
2132 | return makematcher(tree, order) | |
2120 |
|
2133 | |||
2121 | def makematcher(tree): |
|
2134 | def makematcher(tree, order=defineorder): | |
2122 | """Create a matcher from an evaluatable tree""" |
|
2135 | """Create a matcher from an evaluatable tree""" | |
2123 | def mfunc(repo, subset=None): |
|
2136 | def mfunc(repo, subset=None): | |
2124 | if subset is None: |
|
2137 | if subset is None: | |
2125 | subset = fullreposet(repo) |
|
2138 | subset = fullreposet(repo) | |
2126 | return getset(repo, subset, tree) |
|
2139 | return getset(repo, subset, tree, order) | |
2127 | return mfunc |
|
2140 | return mfunc | |
2128 |
|
2141 | |||
2129 | def loadpredicate(ui, extname, registrarobj): |
|
2142 | def loadpredicate(ui, extname, registrarobj): |
@@ -258,7 +258,7 b' def _matchnamedfunc(x, funcname):' | |||||
258 | return |
|
258 | return | |
259 | return x[2] |
|
259 | return x[2] | |
260 |
|
260 | |||
261 |
# Constants for ordering requirement, used in |
|
261 | # Constants for ordering requirement, used in getset(): | |
262 | # |
|
262 | # | |
263 | # If 'define', any nested functions and operations can change the ordering of |
|
263 | # If 'define', any nested functions and operations can change the ordering of | |
264 | # the entries in the set. If 'follow', any nested functions and operations |
|
264 | # the entries in the set. If 'follow', any nested functions and operations | |
@@ -282,26 +282,10 b' def _matchnamedfunc(x, funcname):' | |||||
282 | # |
|
282 | # | |
283 | # 'y()' can either enforce its ordering requirement or take the ordering |
|
283 | # 'y()' can either enforce its ordering requirement or take the ordering | |
284 | # specified by 'x()' because 'not()' doesn't care the order. |
|
284 | # specified by 'x()' because 'not()' doesn't care the order. | |
285 | # |
|
|||
286 | # Transition of ordering requirement: |
|
|||
287 | # |
|
|||
288 | # 1. starts with 'define' |
|
|||
289 | # 2. shifts to 'follow' by 'x & y' |
|
|||
290 | # 3. changes back to 'define' on function call 'f(x)' or function-like |
|
|||
291 | # operation 'x (f) y' because 'f' may have its own ordering requirement |
|
|||
292 | # for 'x' and 'y' (e.g. 'first(x)') |
|
|||
293 | # |
|
|||
294 | anyorder = 'any' # don't care the order |
|
285 | anyorder = 'any' # don't care the order | |
295 | defineorder = 'define' # should define the order |
|
286 | defineorder = 'define' # should define the order | |
296 | followorder = 'follow' # must follow the current order |
|
287 | followorder = 'follow' # must follow the current order | |
297 |
|
288 | |||
298 | # transition table for 'x & y', from the current expression 'x' to 'y' |
|
|||
299 | _tofolloworder = { |
|
|||
300 | anyorder: anyorder, |
|
|||
301 | defineorder: followorder, |
|
|||
302 | followorder: followorder, |
|
|||
303 | } |
|
|||
304 |
|
||||
305 | def _matchonly(revs, bases): |
|
289 | def _matchonly(revs, bases): | |
306 | """ |
|
290 | """ | |
307 | >>> f = lambda *args: _matchonly(*map(parse, args)) |
|
291 | >>> f = lambda *args: _matchonly(*map(parse, args)) | |
@@ -340,76 +324,59 b' def _fixops(x):' | |||||
340 |
|
324 | |||
341 | return (op,) + tuple(_fixops(y) for y in x[1:]) |
|
325 | return (op,) + tuple(_fixops(y) for y in x[1:]) | |
342 |
|
326 | |||
343 |
def _analyze(x |
|
327 | def _analyze(x): | |
344 | if x is None: |
|
328 | if x is None: | |
345 | return x |
|
329 | return x | |
346 |
|
330 | |||
347 | op = x[0] |
|
331 | op = x[0] | |
348 | if op == 'minus': |
|
332 | if op == 'minus': | |
349 |
return _analyze(('and', x[1], ('not', x[2])) |
|
333 | return _analyze(('and', x[1], ('not', x[2]))) | |
350 | elif op == 'only': |
|
334 | elif op == 'only': | |
351 | t = ('func', ('symbol', 'only'), ('list', x[1], x[2])) |
|
335 | t = ('func', ('symbol', 'only'), ('list', x[1], x[2])) | |
352 |
return _analyze(t |
|
336 | return _analyze(t) | |
353 | elif op == 'onlypost': |
|
337 | elif op == 'onlypost': | |
354 |
return _analyze(('func', ('symbol', 'only'), x[1]) |
|
338 | return _analyze(('func', ('symbol', 'only'), x[1])) | |
355 | elif op == 'dagrangepre': |
|
339 | elif op == 'dagrangepre': | |
356 |
return _analyze(('func', ('symbol', 'ancestors'), x[1]) |
|
340 | return _analyze(('func', ('symbol', 'ancestors'), x[1])) | |
357 | elif op == 'dagrangepost': |
|
341 | elif op == 'dagrangepost': | |
358 |
return _analyze(('func', ('symbol', 'descendants'), x[1]) |
|
342 | return _analyze(('func', ('symbol', 'descendants'), x[1])) | |
359 | elif op == 'negate': |
|
343 | elif op == 'negate': | |
360 | s = getstring(x[1], _("can't negate that")) |
|
344 | s = getstring(x[1], _("can't negate that")) | |
361 |
return _analyze(('string', '-' + s) |
|
345 | return _analyze(('string', '-' + s)) | |
362 | elif op in ('string', 'symbol'): |
|
346 | elif op in ('string', 'symbol'): | |
363 | return x |
|
347 | return x | |
364 | elif op == 'and': |
|
|||
365 | ta = _analyze(x[1], order) |
|
|||
366 | tb = _analyze(x[2], _tofolloworder[order]) |
|
|||
367 | return (op, ta, tb, order) |
|
|||
368 | elif op == 'or': |
|
|||
369 | return (op, _analyze(x[1], order), order) |
|
|||
370 | elif op == 'not': |
|
|||
371 | return (op, _analyze(x[1], anyorder), order) |
|
|||
372 | elif op == 'rangeall': |
|
348 | elif op == 'rangeall': | |
373 |
return (op, None |
|
349 | return (op, None) | |
374 |
elif op in |
|
350 | elif op in {'or', 'not', 'rangepre', 'rangepost', 'parentpost'}: | |
375 |
return (op, _analyze(x[1] |
|
351 | return (op, _analyze(x[1])) | |
376 | elif op == 'group': |
|
352 | elif op == 'group': | |
377 |
return _analyze(x[1] |
|
353 | return _analyze(x[1]) | |
378 |
elif op in |
|
354 | elif op in {'and', 'dagrange', 'range', 'parent', 'ancestor', 'relation', | |
379 |
'subscript' |
|
355 | 'subscript'}: | |
380 |
ta = _analyze(x[1] |
|
356 | ta = _analyze(x[1]) | |
381 |
tb = _analyze(x[2] |
|
357 | tb = _analyze(x[2]) | |
382 |
return (op, ta, tb |
|
358 | return (op, ta, tb) | |
383 | elif op == 'relsubscript': |
|
359 | elif op == 'relsubscript': | |
384 |
ta = _analyze(x[1] |
|
360 | ta = _analyze(x[1]) | |
385 |
tb = _analyze(x[2] |
|
361 | tb = _analyze(x[2]) | |
386 |
tc = _analyze(x[3] |
|
362 | tc = _analyze(x[3]) | |
387 |
return (op, ta, tb, tc |
|
363 | return (op, ta, tb, tc) | |
388 | elif op == 'list': |
|
364 | elif op == 'list': | |
389 |
return (op,) + tuple(_analyze(y |
|
365 | return (op,) + tuple(_analyze(y) for y in x[1:]) | |
390 | elif op == 'keyvalue': |
|
366 | elif op == 'keyvalue': | |
391 |
return (op, x[1], _analyze(x[2] |
|
367 | return (op, x[1], _analyze(x[2])) | |
392 | elif op == 'func': |
|
368 | elif op == 'func': | |
393 | f = getsymbol(x[1]) |
|
369 | return (op, x[1], _analyze(x[2])) | |
394 | d = defineorder |
|
|||
395 | if f == 'present': |
|
|||
396 | # 'present(set)' is known to return the argument set with no |
|
|||
397 | # modification, so forward the current order to its argument |
|
|||
398 | d = order |
|
|||
399 | return (op, x[1], _analyze(x[2], d), order) |
|
|||
400 | raise ValueError('invalid operator %r' % op) |
|
370 | raise ValueError('invalid operator %r' % op) | |
401 |
|
371 | |||
402 |
def analyze(x |
|
372 | def analyze(x): | |
403 | """Transform raw parsed tree to evaluatable tree which can be fed to |
|
373 | """Transform raw parsed tree to evaluatable tree which can be fed to | |
404 | optimize() or getset() |
|
374 | optimize() or getset() | |
405 |
|
375 | |||
406 | All pseudo operations should be mapped to real operations or functions |
|
376 | All pseudo operations should be mapped to real operations or functions | |
407 | defined in methods or symbols table respectively. |
|
377 | defined in methods or symbols table respectively. | |
408 |
|
||||
409 | 'order' specifies how the current expression 'x' is ordered (see the |
|
|||
410 | constants defined above.) |
|
|||
411 | """ |
|
378 | """ | |
412 |
return _analyze(x |
|
379 | return _analyze(x) | |
413 |
|
380 | |||
414 | def _optimize(x, small): |
|
381 | def _optimize(x, small): | |
415 | if x is None: |
|
382 | if x is None: | |
@@ -425,24 +392,21 b' def _optimize(x, small):' | |||||
425 | elif op == 'and': |
|
392 | elif op == 'and': | |
426 | wa, ta = _optimize(x[1], True) |
|
393 | wa, ta = _optimize(x[1], True) | |
427 | wb, tb = _optimize(x[2], True) |
|
394 | wb, tb = _optimize(x[2], True) | |
428 | order = x[3] |
|
|||
429 | w = min(wa, wb) |
|
395 | w = min(wa, wb) | |
430 |
|
396 | |||
431 | # (::x and not ::y)/(not ::y and ::x) have a fast path |
|
397 | # (::x and not ::y)/(not ::y and ::x) have a fast path | |
432 | tm = _matchonly(ta, tb) or _matchonly(tb, ta) |
|
398 | tm = _matchonly(ta, tb) or _matchonly(tb, ta) | |
433 | if tm: |
|
399 | if tm: | |
434 |
return w, ('func', ('symbol', 'only'), tm |
|
400 | return w, ('func', ('symbol', 'only'), tm) | |
435 |
|
401 | |||
436 | if tb is not None and tb[0] == 'not': |
|
402 | if tb is not None and tb[0] == 'not': | |
437 |
return wa, ('difference', ta, tb[1] |
|
403 | return wa, ('difference', ta, tb[1]) | |
438 |
|
||||
439 | if wa > wb: |
|
404 | if wa > wb: | |
440 |
return w, ( |
|
405 | return w, ('flipand', tb, ta) | |
441 |
return w, (op, ta, tb |
|
406 | return w, (op, ta, tb) | |
442 | elif op == 'or': |
|
407 | elif op == 'or': | |
443 | # fast path for machine-generated expression, that is likely to have |
|
408 | # fast path for machine-generated expression, that is likely to have | |
444 | # lots of trivial revisions: 'a + b + c()' to '_list(a b) + c()' |
|
409 | # lots of trivial revisions: 'a + b + c()' to '_list(a b) + c()' | |
445 | order = x[2] |
|
|||
446 | ws, ts, ss = [], [], [] |
|
410 | ws, ts, ss = [], [], [] | |
447 | def flushss(): |
|
411 | def flushss(): | |
448 | if not ss: |
|
412 | if not ss: | |
@@ -451,7 +415,7 b' def _optimize(x, small):' | |||||
451 | w, t = ss[0] |
|
415 | w, t = ss[0] | |
452 | else: |
|
416 | else: | |
453 | s = '\0'.join(t[1] for w, t in ss) |
|
417 | s = '\0'.join(t[1] for w, t in ss) | |
454 |
y = ('func', ('symbol', '_list'), ('string', s) |
|
418 | y = ('func', ('symbol', '_list'), ('string', s)) | |
455 | w, t = _optimize(y, False) |
|
419 | w, t = _optimize(y, False) | |
456 | ws.append(w) |
|
420 | ws.append(w) | |
457 | ts.append(t) |
|
421 | ts.append(t) | |
@@ -467,37 +431,31 b' def _optimize(x, small):' | |||||
467 | flushss() |
|
431 | flushss() | |
468 | if len(ts) == 1: |
|
432 | if len(ts) == 1: | |
469 | return ws[0], ts[0] # 'or' operation is fully optimized out |
|
433 | return ws[0], ts[0] # 'or' operation is fully optimized out | |
470 |
return max(ws), (op, ('list',) + tuple(ts) |
|
434 | return max(ws), (op, ('list',) + tuple(ts)) | |
471 | elif op == 'not': |
|
435 | elif op == 'not': | |
472 | # Optimize not public() to _notpublic() because we have a fast version |
|
436 | # Optimize not public() to _notpublic() because we have a fast version | |
473 | if x[1][:3] == ('func', ('symbol', 'public'), None): |
|
437 | if x[1][:3] == ('func', ('symbol', 'public'), None): | |
474 | order = x[1][3] |
|
438 | newsym = ('func', ('symbol', '_notpublic'), None) | |
475 | newsym = ('func', ('symbol', '_notpublic'), None, order) |
|
|||
476 | o = _optimize(newsym, not small) |
|
439 | o = _optimize(newsym, not small) | |
477 | return o[0], o[1] |
|
440 | return o[0], o[1] | |
478 | else: |
|
441 | else: | |
479 | o = _optimize(x[1], not small) |
|
442 | o = _optimize(x[1], not small) | |
480 | order = x[2] |
|
443 | return o[0], (op, o[1]) | |
481 | return o[0], (op, o[1], order) |
|
|||
482 | elif op == 'rangeall': |
|
444 | elif op == 'rangeall': | |
483 | return smallbonus, x |
|
445 | return smallbonus, x | |
484 | elif op in ('rangepre', 'rangepost', 'parentpost'): |
|
446 | elif op in ('rangepre', 'rangepost', 'parentpost'): | |
485 | o = _optimize(x[1], small) |
|
447 | o = _optimize(x[1], small) | |
486 | order = x[2] |
|
448 | return o[0], (op, o[1]) | |
487 | return o[0], (op, o[1], order) |
|
|||
488 | elif op in ('dagrange', 'range'): |
|
449 | elif op in ('dagrange', 'range'): | |
489 | wa, ta = _optimize(x[1], small) |
|
450 | wa, ta = _optimize(x[1], small) | |
490 | wb, tb = _optimize(x[2], small) |
|
451 | wb, tb = _optimize(x[2], small) | |
491 | order = x[3] |
|
452 | return wa + wb, (op, ta, tb) | |
492 | return wa + wb, (op, ta, tb, order) |
|
|||
493 | elif op in ('parent', 'ancestor', 'relation', 'subscript'): |
|
453 | elif op in ('parent', 'ancestor', 'relation', 'subscript'): | |
494 | w, t = _optimize(x[1], small) |
|
454 | w, t = _optimize(x[1], small) | |
495 | order = x[3] |
|
455 | return w, (op, t, x[2]) | |
496 | return w, (op, t, x[2], order) |
|
|||
497 | elif op == 'relsubscript': |
|
456 | elif op == 'relsubscript': | |
498 | w, t = _optimize(x[1], small) |
|
457 | w, t = _optimize(x[1], small) | |
499 | order = x[4] |
|
458 | return w, (op, t, x[2], x[3]) | |
500 | return w, (op, t, x[2], x[3], order) |
|
|||
501 | elif op == 'list': |
|
459 | elif op == 'list': | |
502 | ws, ts = zip(*(_optimize(y, small) for y in x[1:])) |
|
460 | ws, ts = zip(*(_optimize(y, small) for y in x[1:])) | |
503 | return sum(ws), (op,) + ts |
|
461 | return sum(ws), (op,) + ts | |
@@ -522,8 +480,7 b' def _optimize(x, small):' | |||||
522 | w = 10 # assume most sorts look at changelog |
|
480 | w = 10 # assume most sorts look at changelog | |
523 | else: |
|
481 | else: | |
524 | w = 1 |
|
482 | w = 1 | |
525 | order = x[3] |
|
483 | return w + wa, (op, x[1], ta) | |
526 | return w + wa, (op, x[1], ta, order) |
|
|||
527 | raise ValueError('invalid operator %r' % op) |
|
484 | raise ValueError('invalid operator %r' % op) | |
528 |
|
485 | |||
529 | def optimize(tree): |
|
486 | def optimize(tree): |
@@ -166,8 +166,7 b' trivial' | |||||
166 | None) |
|
166 | None) | |
167 | * optimized: |
|
167 | * optimized: | |
168 | (rangeall |
|
168 | (rangeall | |
169 | None |
|
169 | None) | |
170 | define) |
|
|||
171 | * set: |
|
170 | * set: | |
172 | <spanset+ 0:10> |
|
171 | <spanset+ 0:10> | |
173 | 0 |
|
172 | 0 | |
@@ -495,8 +494,7 b' keyword arguments' | |||||
495 | ('symbol', 'foo') |
|
494 | ('symbol', 'foo') | |
496 | (func |
|
495 | (func | |
497 | ('symbol', '_notpublic') |
|
496 | ('symbol', '_notpublic') | |
498 | None |
|
497 | None)) | |
499 | any)) |
|
|||
500 | hg: parse error: can't use a key-value pair in this context |
|
498 | hg: parse error: can't use a key-value pair in this context | |
501 | [255] |
|
499 | [255] | |
502 |
|
500 | |||
@@ -538,21 +536,16 b' left-hand side of relation-subscript ope' | |||||
538 | (not |
|
536 | (not | |
539 | (func |
|
537 | (func | |
540 | ('symbol', 'public') |
|
538 | ('symbol', 'public') | |
541 | None |
|
539 | None)) | |
542 | any) |
|
|||
543 | define) |
|
|||
544 | ('symbol', 'generations') |
|
540 | ('symbol', 'generations') | |
545 | ('symbol', '0') |
|
541 | ('symbol', '0')) | |
546 | define) |
|
|||
547 | * optimized: |
|
542 | * optimized: | |
548 | (relsubscript |
|
543 | (relsubscript | |
549 | (func |
|
544 | (func | |
550 | ('symbol', '_notpublic') |
|
545 | ('symbol', '_notpublic') | |
551 | None |
|
546 | None) | |
552 | any) |
|
|||
553 | ('symbol', 'generations') |
|
547 | ('symbol', 'generations') | |
554 | ('symbol', '0') |
|
548 | ('symbol', '0')) | |
555 | define) |
|
|||
556 |
|
549 | |||
557 | resolution of subscript and relation-subscript ternary operators: |
|
550 | resolution of subscript and relation-subscript ternary operators: | |
558 |
|
551 | |||
@@ -560,8 +553,7 b' resolution of subscript and relation-sub' | |||||
560 | * analyzed: |
|
553 | * analyzed: | |
561 | (subscript |
|
554 | (subscript | |
562 | ('symbol', 'tip') |
|
555 | ('symbol', 'tip') | |
563 | ('symbol', '0') |
|
556 | ('symbol', '0')) | |
564 | define) |
|
|||
565 | hg: parse error: can't use a subscript in this context |
|
557 | hg: parse error: can't use a subscript in this context | |
566 | [255] |
|
558 | [255] | |
567 |
|
559 | |||
@@ -570,8 +562,7 b' resolution of subscript and relation-sub' | |||||
570 | (relsubscript |
|
562 | (relsubscript | |
571 | ('symbol', 'tip') |
|
563 | ('symbol', 'tip') | |
572 | ('symbol', 'rel') |
|
564 | ('symbol', 'rel') | |
573 | ('symbol', '0') |
|
565 | ('symbol', '0')) | |
574 | define) |
|
|||
575 | hg: parse error: unknown identifier: rel |
|
566 | hg: parse error: unknown identifier: rel | |
576 | [255] |
|
567 | [255] | |
577 |
|
568 | |||
@@ -580,10 +571,8 b' resolution of subscript and relation-sub' | |||||
580 | (subscript |
|
571 | (subscript | |
581 | (relation |
|
572 | (relation | |
582 | ('symbol', 'tip') |
|
573 | ('symbol', 'tip') | |
583 | ('symbol', 'rel') |
|
574 | ('symbol', 'rel')) | |
584 | define) |
|
575 | ('symbol', '0')) | |
585 | ('symbol', '0') |
|
|||
586 | define) |
|
|||
587 | hg: parse error: can't use a subscript in this context |
|
576 | hg: parse error: can't use a subscript in this context | |
588 | [255] |
|
577 | [255] | |
589 |
|
578 | |||
@@ -593,10 +582,8 b' resolution of subscript and relation-sub' | |||||
593 | (relsubscript |
|
582 | (relsubscript | |
594 | ('symbol', 'tip') |
|
583 | ('symbol', 'tip') | |
595 | ('symbol', 'rel') |
|
584 | ('symbol', 'rel') | |
596 | ('symbol', '0') |
|
585 | ('symbol', '0')) | |
597 | define) |
|
586 | ('symbol', '1')) | |
598 | ('symbol', '1') |
|
|||
599 | define) |
|
|||
600 | hg: parse error: can't use a subscript in this context |
|
587 | hg: parse error: can't use a subscript in this context | |
601 | [255] |
|
588 | [255] | |
602 |
|
589 | |||
@@ -605,11 +592,9 b' resolution of subscript and relation-sub' | |||||
605 | (relsubscript |
|
592 | (relsubscript | |
606 | (relation |
|
593 | (relation | |
607 | ('symbol', 'tip') |
|
594 | ('symbol', 'tip') | |
608 | ('symbol', 'rel0') |
|
595 | ('symbol', 'rel0')) | |
609 | define) |
|
|||
610 | ('symbol', 'rel1') |
|
596 | ('symbol', 'rel1') | |
611 | ('symbol', '1') |
|
597 | ('symbol', '1')) | |
612 | define) |
|
|||
613 | hg: parse error: unknown identifier: rel1 |
|
598 | hg: parse error: unknown identifier: rel1 | |
614 | [255] |
|
599 | [255] | |
615 |
|
600 | |||
@@ -619,11 +604,9 b' resolution of subscript and relation-sub' | |||||
619 | (relsubscript |
|
604 | (relsubscript | |
620 | ('symbol', 'tip') |
|
605 | ('symbol', 'tip') | |
621 | ('symbol', 'rel0') |
|
606 | ('symbol', 'rel0') | |
622 | ('symbol', '0') |
|
607 | ('symbol', '0')) | |
623 | define) |
|
|||
624 | ('symbol', 'rel1') |
|
608 | ('symbol', 'rel1') | |
625 | ('symbol', '1') |
|
609 | ('symbol', '1')) | |
626 | define) |
|
|||
627 | hg: parse error: unknown identifier: rel1 |
|
610 | hg: parse error: unknown identifier: rel1 | |
628 | [255] |
|
611 | [255] | |
629 |
|
612 | |||
@@ -700,20 +683,15 b' parsed tree at stages:' | |||||
700 | (or |
|
683 | (or | |
701 | (list |
|
684 | (list | |
702 | ('symbol', '0') |
|
685 | ('symbol', '0') | |
703 | ('symbol', '1')) |
|
686 | ('symbol', '1'))) | |
704 | define) |
|
|||
705 | (not |
|
687 | (not | |
706 | ('symbol', '1') |
|
688 | ('symbol', '1'))) | |
707 | follow) |
|
|||
708 | define) |
|
|||
709 | * optimized: |
|
689 | * optimized: | |
710 | (difference |
|
690 | (difference | |
711 | (func |
|
691 | (func | |
712 | ('symbol', '_list') |
|
692 | ('symbol', '_list') | |
713 | ('string', '0\x001') |
|
693 | ('string', '0\x001')) | |
714 | define) |
|
694 | ('symbol', '1')) | |
715 | ('symbol', '1') |
|
|||
716 | define) |
|
|||
717 | 0 |
|
695 | 0 | |
718 |
|
696 | |||
719 | $ hg debugrevspec -p unknown '0' |
|
697 | $ hg debugrevspec -p unknown '0' | |
@@ -733,18 +711,14 b' verify optimized tree:' | |||||
733 | (and |
|
711 | (and | |
734 | (func |
|
712 | (func | |
735 | ('symbol', 'r3232') |
|
713 | ('symbol', 'r3232') | |
736 | None |
|
714 | None) | |
737 | define) |
|
715 | ('symbol', '2')) | |
738 | ('symbol', '2') |
|
|||
739 | define) |
|
|||
740 | * optimized: |
|
716 | * optimized: | |
741 | (and |
|
717 | (flipand | |
742 | ('symbol', '2') |
|
718 | ('symbol', '2') | |
743 | (func |
|
719 | (func | |
744 | ('symbol', 'r3232') |
|
720 | ('symbol', 'r3232') | |
745 | None |
|
721 | None)) | |
746 | define) |
|
|||
747 | define) |
|
|||
748 | * analyzed set: |
|
722 | * analyzed set: | |
749 | <baseset [2]> |
|
723 | <baseset [2]> | |
750 | * optimized set: |
|
724 | * optimized set: | |
@@ -776,8 +750,7 b' may be hidden (issue5385)' | |||||
776 | None) |
|
750 | None) | |
777 | * analyzed: |
|
751 | * analyzed: | |
778 | (rangeall |
|
752 | (rangeall | |
779 | None |
|
753 | None) | |
780 | define) |
|
|||
781 | * set: |
|
754 | * set: | |
782 | <spanset+ 0:10> |
|
755 | <spanset+ 0:10> | |
783 | 0 |
|
756 | 0 | |
@@ -793,8 +766,7 b' may be hidden (issue5385)' | |||||
793 | $ try -p analyzed ':1' |
|
766 | $ try -p analyzed ':1' | |
794 | * analyzed: |
|
767 | * analyzed: | |
795 | (rangepre |
|
768 | (rangepre | |
796 | ('symbol', '1') |
|
769 | ('symbol', '1')) | |
797 | define) |
|
|||
798 | * set: |
|
770 | * set: | |
799 | <spanset+ 0:2> |
|
771 | <spanset+ 0:2> | |
800 | 0 |
|
772 | 0 | |
@@ -805,9 +777,7 b' may be hidden (issue5385)' | |||||
805 | (or |
|
777 | (or | |
806 | (list |
|
778 | (list | |
807 | ('symbol', '1') |
|
779 | ('symbol', '1') | |
808 | ('symbol', '2')) |
|
780 | ('symbol', '2')))) | |
809 | define) |
|
|||
810 | define) |
|
|||
811 | * set: |
|
781 | * set: | |
812 | <spanset+ 0:3> |
|
782 | <spanset+ 0:3> | |
813 | 0 |
|
783 | 0 | |
@@ -818,9 +788,7 b' may be hidden (issue5385)' | |||||
818 | (rangepre |
|
788 | (rangepre | |
819 | (and |
|
789 | (and | |
820 | ('symbol', '1') |
|
790 | ('symbol', '1') | |
821 | ('symbol', '2') |
|
791 | ('symbol', '2'))) | |
822 | define) |
|
|||
823 | define) |
|
|||
824 | * set: |
|
792 | * set: | |
825 | <baseset []> |
|
793 | <baseset []> | |
826 |
|
794 | |||
@@ -1643,11 +1611,8 b" Test operand of '%' is optimized recursi" | |||||
1643 | (difference |
|
1611 | (difference | |
1644 | (range |
|
1612 | (range | |
1645 | ('symbol', '8') |
|
1613 | ('symbol', '8') | |
1646 | ('symbol', '9') |
|
1614 | ('symbol', '9')) | |
1647 | define) |
|
1615 | ('symbol', '8'))) | |
1648 | ('symbol', '8') |
|
|||
1649 | define) |
|
|||
1650 | define) |
|
|||
1651 | * set: |
|
1616 | * set: | |
1652 | <baseset+ [8, 9]> |
|
1617 | <baseset+ [8, 9]> | |
1653 | 8 |
|
1618 | 8 | |
@@ -1663,8 +1628,7 b" Test operand of '%' is optimized recursi" | |||||
1663 | ('symbol', 'only') |
|
1628 | ('symbol', 'only') | |
1664 | (list |
|
1629 | (list | |
1665 | ('symbol', '9') |
|
1630 | ('symbol', '9') | |
1666 | ('symbol', '5')) |
|
1631 | ('symbol', '5'))) | |
1667 | define) |
|
|||
1668 | * set: |
|
1632 | * set: | |
1669 | <baseset+ [2, 4, 8, 9]> |
|
1633 | <baseset+ [2, 4, 8, 9]> | |
1670 | 2 |
|
1634 | 2 | |
@@ -1999,18 +1963,13 b' ordering defined by it.' | |||||
1999 | (and |
|
1963 | (and | |
2000 | (range |
|
1964 | (range | |
2001 | ('symbol', '3') |
|
1965 | ('symbol', '3') | |
2002 | ('symbol', '0') |
|
1966 | ('symbol', '0')) | |
2003 | define) |
|
|||
2004 | (range |
|
1967 | (range | |
2005 | ('symbol', '0') |
|
1968 | ('symbol', '0') | |
2006 | ('symbol', '3') |
|
1969 | ('symbol', '3'))) | |
2007 | follow) |
|
|||
2008 | define) |
|
|||
2009 | (range |
|
1970 | (range | |
2010 | ('symbol', '2') |
|
1971 | ('symbol', '2') | |
2011 | ('symbol', '1') |
|
1972 | ('symbol', '1'))) | |
2012 | any) |
|
|||
2013 | define) |
|
|||
2014 | * set: |
|
1973 | * set: | |
2015 | <filteredset |
|
1974 | <filteredset | |
2016 | <filteredset |
|
1975 | <filteredset | |
@@ -2039,13 +1998,10 b' ordering defined by it.' | |||||
2039 | (and |
|
1998 | (and | |
2040 | (range |
|
1999 | (range | |
2041 | ('symbol', '2') |
|
2000 | ('symbol', '2') | |
2042 | ('symbol', '0') |
|
2001 | ('symbol', '0')) | |
2043 | define) |
|
|||
2044 | (func |
|
2002 | (func | |
2045 | ('symbol', '_list') |
|
2003 | ('symbol', '_list') | |
2046 | ('string', '0\x001\x002') |
|
2004 | ('string', '0\x001\x002'))) | |
2047 | follow) |
|
|||
2048 | define) |
|
|||
2049 | * set: |
|
2005 | * set: | |
2050 | <filteredset |
|
2006 | <filteredset | |
2051 | <spanset- 0:3>, |
|
2007 | <spanset- 0:3>, | |
@@ -2072,17 +2028,13 b' ordering defined by it.' | |||||
2072 | (and |
|
2028 | (and | |
2073 | (range |
|
2029 | (range | |
2074 | ('symbol', '2') |
|
2030 | ('symbol', '2') | |
2075 | ('symbol', '0') |
|
2031 | ('symbol', '0')) | |
2076 | define) |
|
|||
2077 | (or |
|
2032 | (or | |
2078 | (list |
|
2033 | (list | |
2079 | (range |
|
2034 | (range | |
2080 | ('symbol', '0') |
|
2035 | ('symbol', '0') | |
2081 | ('symbol', '1') |
|
2036 | ('symbol', '1')) | |
2082 | follow) |
|
2037 | ('symbol', '2')))) | |
2083 | ('symbol', '2')) |
|
|||
2084 | follow) |
|
|||
2085 | define) |
|
|||
2086 | * set: |
|
2038 | * set: | |
2087 | <filteredset |
|
2039 | <filteredset | |
2088 | <spanset- 0:3>, |
|
2040 | <spanset- 0:3>, | |
@@ -2104,16 +2056,13 b' ordering defined by it.' | |||||
2104 | ('symbol', '_intlist') |
|
2056 | ('symbol', '_intlist') | |
2105 | ('string', '0\x001\x002'))) |
|
2057 | ('string', '0\x001\x002'))) | |
2106 | * optimized: |
|
2058 | * optimized: | |
2107 | (and |
|
2059 | (flipand | |
2108 | (func |
|
2060 | (func | |
2109 | ('symbol', '_intlist') |
|
2061 | ('symbol', '_intlist') | |
2110 | ('string', '0\x001\x002') |
|
2062 | ('string', '0\x001\x002')) | |
2111 | follow) |
|
|||
2112 | (range |
|
2063 | (range | |
2113 | ('symbol', '2') |
|
2064 | ('symbol', '2') | |
2114 | ('symbol', '0') |
|
2065 | ('symbol', '0'))) | |
2115 | define) |
|
|||
2116 | define) |
|
|||
2117 | * set: |
|
2066 | * set: | |
2118 | <filteredset |
|
2067 | <filteredset | |
2119 | <spanset- 0:3>, |
|
2068 | <spanset- 0:3>, | |
@@ -2134,13 +2083,10 b' ordering defined by it.' | |||||
2134 | (and |
|
2083 | (and | |
2135 | (func |
|
2084 | (func | |
2136 | ('symbol', '_intlist') |
|
2085 | ('symbol', '_intlist') | |
2137 | ('string', '0\x002\x001') |
|
2086 | ('string', '0\x002\x001')) | |
2138 | define) |
|
|||
2139 | (range |
|
2087 | (range | |
2140 | ('symbol', '2') |
|
2088 | ('symbol', '2') | |
2141 | ('symbol', '0') |
|
2089 | ('symbol', '0'))) | |
2142 | follow) |
|
|||
2143 | define) |
|
|||
2144 | * set: |
|
2090 | * set: | |
2145 | <filteredset |
|
2091 | <filteredset | |
2146 | <baseset [0, 2, 1]>, |
|
2092 | <baseset [0, 2, 1]>, | |
@@ -2163,13 +2109,10 b' ordering defined by it.' | |||||
2163 | (and |
|
2109 | (and | |
2164 | (range |
|
2110 | (range | |
2165 | ('symbol', '2') |
|
2111 | ('symbol', '2') | |
2166 | ('symbol', '0') |
|
2112 | ('symbol', '0')) | |
2167 | define) |
|
|||
2168 | (func |
|
2113 | (func | |
2169 | ('symbol', '_hexlist') |
|
2114 | ('symbol', '_hexlist') | |
2170 | ('string', '*') (glob) |
|
2115 | ('string', '*'))) (glob) | |
2171 | follow) |
|
|||
2172 | define) |
|
|||
2173 | * set: |
|
2116 | * set: | |
2174 | <filteredset |
|
2117 | <filteredset | |
2175 | <spanset- 0:3>, |
|
2118 | <spanset- 0:3>, | |
@@ -2187,16 +2130,13 b' ordering defined by it.' | |||||
2187 | ('symbol', '2') |
|
2130 | ('symbol', '2') | |
2188 | ('symbol', '0'))) |
|
2131 | ('symbol', '0'))) | |
2189 | * optimized: |
|
2132 | * optimized: | |
2190 | (and |
|
2133 | (flipand | |
2191 | (range |
|
2134 | (range | |
2192 | ('symbol', '2') |
|
2135 | ('symbol', '2') | |
2193 | ('symbol', '0') |
|
2136 | ('symbol', '0')) | |
2194 | follow) |
|
|||
2195 | (func |
|
2137 | (func | |
2196 | ('symbol', '_hexlist') |
|
2138 | ('symbol', '_hexlist') | |
2197 | ('string', '*') (glob) |
|
2139 | ('string', '*'))) (glob) | |
2198 | define) |
|
|||
2199 | define) |
|
|||
2200 | * set: |
|
2140 | * set: | |
2201 | <baseset [0, 2, 1]> |
|
2141 | <baseset [0, 2, 1]> | |
2202 | 0 |
|
2142 | 0 | |
@@ -2211,13 +2151,10 b' ordering defined by it.' | |||||
2211 | (difference |
|
2151 | (difference | |
2212 | (range |
|
2152 | (range | |
2213 | ('symbol', '2') |
|
2153 | ('symbol', '2') | |
2214 | ('symbol', '0') |
|
2154 | ('symbol', '0')) | |
2215 | define) |
|
|||
2216 | (func |
|
2155 | (func | |
2217 | ('symbol', '_list') |
|
2156 | ('symbol', '_list') | |
2218 | ('string', '0\x001') |
|
2157 | ('string', '0\x001'))) | |
2219 | any) |
|
|||
2220 | define) |
|
|||
2221 | * set: |
|
2158 | * set: | |
2222 | <filteredset |
|
2159 | <filteredset | |
2223 | <spanset- 0:3>, |
|
2160 | <spanset- 0:3>, | |
@@ -2230,19 +2167,14 b' ordering defined by it.' | |||||
2230 | (difference |
|
2167 | (difference | |
2231 | (range |
|
2168 | (range | |
2232 | ('symbol', '2') |
|
2169 | ('symbol', '2') | |
2233 | ('symbol', '0') |
|
2170 | ('symbol', '0')) | |
2234 | define) |
|
|||
2235 | (and |
|
2171 | (and | |
2236 | (range |
|
2172 | (range | |
2237 | ('symbol', '0') |
|
2173 | ('symbol', '0') | |
2238 | ('symbol', '2') |
|
2174 | ('symbol', '2')) | |
2239 | any) |
|
|||
2240 | (func |
|
2175 | (func | |
2241 | ('symbol', '_list') |
|
2176 | ('symbol', '_list') | |
2242 | ('string', '0\x001') |
|
2177 | ('string', '0\x001')))) | |
2243 | any) |
|
|||
2244 | any) |
|
|||
2245 | define) |
|
|||
2246 | * set: |
|
2178 | * set: | |
2247 | <filteredset |
|
2179 | <filteredset | |
2248 | <spanset- 0:3>, |
|
2180 | <spanset- 0:3>, | |
@@ -2259,9 +2191,7 b' ordering defined by it.' | |||||
2259 | ('symbol', 'present') |
|
2191 | ('symbol', 'present') | |
2260 | (func |
|
2192 | (func | |
2261 | ('symbol', '_list') |
|
2193 | ('symbol', '_list') | |
2262 | ('string', '2\x000\x001') |
|
2194 | ('string', '2\x000\x001'))) | |
2263 | define) |
|
|||
2264 | define) |
|
|||
2265 | * set: |
|
2195 | * set: | |
2266 | <baseset [2, 0, 1]> |
|
2196 | <baseset [2, 0, 1]> | |
2267 | 2 |
|
2197 | 2 | |
@@ -2284,16 +2214,12 b' ordering defined by it.' | |||||
2284 | (and |
|
2214 | (and | |
2285 | (range |
|
2215 | (range | |
2286 | ('symbol', '2') |
|
2216 | ('symbol', '2') | |
2287 | ('symbol', '0') |
|
2217 | ('symbol', '0')) | |
2288 | define) |
|
|||
2289 | (func |
|
2218 | (func | |
2290 | ('symbol', 'present') |
|
2219 | ('symbol', 'present') | |
2291 | (func |
|
2220 | (func | |
2292 | ('symbol', '_list') |
|
2221 | ('symbol', '_list') | |
2293 | ('string', '0\x001\x002') |
|
2222 | ('string', '0\x001\x002')))) | |
2294 | follow) |
|
|||
2295 | follow) |
|
|||
2296 | define) |
|
|||
2297 | * set: |
|
2223 | * set: | |
2298 | <filteredset |
|
2224 | <filteredset | |
2299 | <spanset- 0:3>, |
|
2225 | <spanset- 0:3>, | |
@@ -2318,16 +2244,12 b' ordering defined by it.' | |||||
2318 | (and |
|
2244 | (and | |
2319 | (range |
|
2245 | (range | |
2320 | ('symbol', '0') |
|
2246 | ('symbol', '0') | |
2321 | ('symbol', '2') |
|
2247 | ('symbol', '2')) | |
2322 | define) |
|
|||
2323 | (func |
|
2248 | (func | |
2324 | ('symbol', 'reverse') |
|
2249 | ('symbol', 'reverse') | |
2325 | (func |
|
2250 | (func | |
2326 | ('symbol', 'all') |
|
2251 | ('symbol', 'all') | |
2327 | None |
|
2252 | None))) | |
2328 | define) |
|
|||
2329 | follow) |
|
|||
2330 | define) |
|
|||
2331 | * set: |
|
2253 | * set: | |
2332 | <filteredset |
|
2254 | <filteredset | |
2333 | <spanset+ 0:3>, |
|
2255 | <spanset+ 0:3>, | |
@@ -2355,18 +2277,14 b' ordering defined by it.' | |||||
2355 | (and |
|
2277 | (and | |
2356 | (range |
|
2278 | (range | |
2357 | ('symbol', '0') |
|
2279 | ('symbol', '0') | |
2358 | ('symbol', '2') |
|
2280 | ('symbol', '2')) | |
2359 | define) |
|
|||
2360 | (func |
|
2281 | (func | |
2361 | ('symbol', 'sort') |
|
2282 | ('symbol', 'sort') | |
2362 | (list |
|
2283 | (list | |
2363 | (func |
|
2284 | (func | |
2364 | ('symbol', 'all') |
|
2285 | ('symbol', 'all') | |
2365 | None |
|
2286 | None) | |
2366 | define) |
|
2287 | ('string', '-rev')))) | |
2367 | ('string', '-rev')) |
|
|||
2368 | follow) |
|
|||
2369 | define) |
|
|||
2370 | * set: |
|
2288 | * set: | |
2371 | <filteredset |
|
2289 | <filteredset | |
2372 | <spanset+ 0:3>, |
|
2290 | <spanset+ 0:3>, | |
@@ -2402,16 +2320,12 b' ordering defined by it.' | |||||
2402 | (and |
|
2320 | (and | |
2403 | (range |
|
2321 | (range | |
2404 | ('symbol', '2') |
|
2322 | ('symbol', '2') | |
2405 | ('symbol', '0') |
|
2323 | ('symbol', '0')) | |
2406 | define) |
|
|||
2407 | (func |
|
2324 | (func | |
2408 | ('symbol', 'first') |
|
2325 | ('symbol', 'first') | |
2409 | (func |
|
2326 | (func | |
2410 | ('symbol', '_list') |
|
2327 | ('symbol', '_list') | |
2411 | ('string', '1\x000\x002') |
|
2328 | ('string', '1\x000\x002')))) | |
2412 | define) |
|
|||
2413 | follow) |
|
|||
2414 | define) |
|
|||
2415 | * set: |
|
2329 | * set: | |
2416 | <filteredset |
|
2330 | <filteredset | |
2417 | <baseset [1]>, |
|
2331 | <baseset [1]>, | |
@@ -2435,16 +2349,12 b' ordering defined by it.' | |||||
2435 | (difference |
|
2349 | (difference | |
2436 | (range |
|
2350 | (range | |
2437 | ('symbol', '2') |
|
2351 | ('symbol', '2') | |
2438 | ('symbol', '0') |
|
2352 | ('symbol', '0')) | |
2439 | define) |
|
|||
2440 | (func |
|
2353 | (func | |
2441 | ('symbol', 'last') |
|
2354 | ('symbol', 'last') | |
2442 | (func |
|
2355 | (func | |
2443 | ('symbol', '_list') |
|
2356 | ('symbol', '_list') | |
2444 | ('string', '0\x002\x001') |
|
2357 | ('string', '0\x002\x001')))) | |
2445 | define) |
|
|||
2446 | any) |
|
|||
2447 | define) |
|
|||
2448 | * set: |
|
2358 | * set: | |
2449 | <filteredset |
|
2359 | <filteredset | |
2450 | <spanset- 0:3>, |
|
2360 | <spanset- 0:3>, | |
@@ -2477,29 +2387,21 b' ordering defined by it.' | |||||
2477 | (and |
|
2387 | (and | |
2478 | (range |
|
2388 | (range | |
2479 | ('symbol', '2') |
|
2389 | ('symbol', '2') | |
2480 | ('symbol', '0') |
|
2390 | ('symbol', '0')) | |
2481 | define) |
|
|||
2482 | (range |
|
2391 | (range | |
2483 | (func |
|
2392 | (func | |
2484 | ('symbol', '_list') |
|
2393 | ('symbol', '_list') | |
2485 | ('string', '1\x000\x002') |
|
2394 | ('string', '1\x000\x002')) | |
2486 | define) |
|
|||
2487 | (func |
|
2395 | (func | |
2488 | ('symbol', '_list') |
|
2396 | ('symbol', '_list') | |
2489 | ('string', '0\x002\x001') |
|
2397 | ('string', '0\x002\x001')))) | |
2490 | define) |
|
|||
2491 | follow) |
|
|||
2492 | define) |
|
|||
2493 | * set: |
|
2398 | * set: | |
2494 | <filteredset |
|
2399 | <filteredset | |
2495 | <spanset- 0:3>, |
|
2400 | <spanset- 0:3>, | |
2496 | <baseset [1]>> |
|
2401 | <baseset [1]>> | |
2497 | 1 |
|
2402 | 1 | |
2498 |
|
2403 | |||
2499 |
'A & B' can be rewritten as ' |
|
2404 | 'A & B' can be rewritten as 'flipand(B, A)' by weight. | |
2500 | the ordering rule is determined before the rewrite; in this example, |
|
|||
2501 | 'B' follows the order of the initial set, which is the same order as 'A' |
|
|||
2502 | since 'A' also follows the order: |
|
|||
2503 |
|
2405 | |||
2504 | $ try --optimize 'contains("glob:*") & (2 + 0 + 1)' |
|
2406 | $ try --optimize 'contains("glob:*") & (2 + 0 + 1)' | |
2505 | (and |
|
2407 | (and | |
@@ -2513,16 +2415,13 b' ordering defined by it.' | |||||
2513 | ('symbol', '0') |
|
2415 | ('symbol', '0') | |
2514 | ('symbol', '1'))))) |
|
2416 | ('symbol', '1'))))) | |
2515 | * optimized: |
|
2417 | * optimized: | |
2516 | (and |
|
2418 | (flipand | |
2517 | (func |
|
2419 | (func | |
2518 | ('symbol', '_list') |
|
2420 | ('symbol', '_list') | |
2519 | ('string', '2\x000\x001') |
|
2421 | ('string', '2\x000\x001')) | |
2520 | follow) |
|
|||
2521 | (func |
|
2422 | (func | |
2522 | ('symbol', 'contains') |
|
2423 | ('symbol', 'contains') | |
2523 | ('string', 'glob:*') |
|
2424 | ('string', 'glob:*'))) | |
2524 | define) |
|
|||
2525 | define) |
|
|||
2526 | * set: |
|
2425 | * set: | |
2527 | <filteredset |
|
2426 | <filteredset | |
2528 | <baseset+ [0, 1, 2]>, |
|
2427 | <baseset+ [0, 1, 2]>, | |
@@ -2548,19 +2447,15 b' ordering defined by it.' | |||||
2548 | ('symbol', '2') |
|
2447 | ('symbol', '2') | |
2549 | ('symbol', '1'))))) |
|
2448 | ('symbol', '1'))))) | |
2550 | * optimized: |
|
2449 | * optimized: | |
2551 | (and |
|
2450 | (flipand | |
2552 | (func |
|
2451 | (func | |
2553 | ('symbol', '_list') |
|
2452 | ('symbol', '_list') | |
2554 | ('string', '0\x002\x001') |
|
2453 | ('string', '0\x002\x001')) | |
2555 | follow) |
|
|||
2556 | (func |
|
2454 | (func | |
2557 | ('symbol', 'reverse') |
|
2455 | ('symbol', 'reverse') | |
2558 | (func |
|
2456 | (func | |
2559 | ('symbol', 'contains') |
|
2457 | ('symbol', 'contains') | |
2560 | ('string', 'glob:*') |
|
2458 | ('string', 'glob:*')))) | |
2561 | define) |
|
|||
2562 | define) |
|
|||
2563 | define) |
|
|||
2564 | * set: |
|
2459 | * set: | |
2565 | <filteredset |
|
2460 | <filteredset | |
2566 | <baseset- [0, 1, 2]>, |
|
2461 | <baseset- [0, 1, 2]>, | |
@@ -2953,8 +2848,7 b' test optimization of trivial `or` operat' | |||||
2953 | * optimized: |
|
2848 | * optimized: | |
2954 | (func |
|
2849 | (func | |
2955 | ('symbol', '_list') |
|
2850 | ('symbol', '_list') | |
2956 | ('string', '0\x001\x002\x00-2\x00tip\x00null') |
|
2851 | ('string', '0\x001\x002\x00-2\x00tip\x00null')) | |
2957 | define) |
|
|||
2958 | * set: |
|
2852 | * set: | |
2959 | <baseset [0, 1, 2, 8, 9, -1]> |
|
2853 | <baseset [0, 1, 2, 8, 9, -1]> | |
2960 | 0 |
|
2854 | 0 | |
@@ -2977,13 +2871,10 b' test optimization of trivial `or` operat' | |||||
2977 | (list |
|
2871 | (list | |
2978 | (func |
|
2872 | (func | |
2979 | ('symbol', '_list') |
|
2873 | ('symbol', '_list') | |
2980 | ('string', '0\x001') |
|
2874 | ('string', '0\x001')) | |
2981 | define) |
|
|||
2982 | (range |
|
2875 | (range | |
2983 | ('symbol', '2') |
|
2876 | ('symbol', '2') | |
2984 | ('symbol', '3') |
|
2877 | ('symbol', '3')))) | |
2985 | define)) |
|
|||
2986 | define) |
|
|||
2987 | * set: |
|
2878 | * set: | |
2988 | <addset |
|
2879 | <addset | |
2989 | <baseset [0, 1]>, |
|
2880 | <baseset [0, 1]>, | |
@@ -3010,18 +2901,14 b' test optimization of trivial `or` operat' | |||||
3010 | (list |
|
2901 | (list | |
3011 | (range |
|
2902 | (range | |
3012 | ('symbol', '0') |
|
2903 | ('symbol', '0') | |
3013 | ('symbol', '1') |
|
2904 | ('symbol', '1')) | |
3014 | define) |
|
|||
3015 | ('symbol', '2') |
|
2905 | ('symbol', '2') | |
3016 | (range |
|
2906 | (range | |
3017 | ('symbol', '3') |
|
2907 | ('symbol', '3') | |
3018 | ('symbol', '4') |
|
2908 | ('symbol', '4')) | |
3019 | define) |
|
|||
3020 | (func |
|
2909 | (func | |
3021 | ('symbol', '_list') |
|
2910 | ('symbol', '_list') | |
3022 | ('string', '5\x006') |
|
2911 | ('string', '5\x006')))) | |
3023 | define)) |
|
|||
3024 | define) |
|
|||
3025 | * set: |
|
2912 | * set: | |
3026 | <addset |
|
2913 | <addset | |
3027 | <addset |
|
2914 | <addset | |
@@ -3048,8 +2935,7 b' unoptimized `or` looks like this' | |||||
3048 | ('symbol', '1') |
|
2935 | ('symbol', '1') | |
3049 | ('symbol', '2') |
|
2936 | ('symbol', '2') | |
3050 | ('symbol', '3') |
|
2937 | ('symbol', '3') | |
3051 | ('symbol', '4')) |
|
2938 | ('symbol', '4'))) | |
3052 | define) |
|
|||
3053 | * set: |
|
2939 | * set: | |
3054 | <addset |
|
2940 | <addset | |
3055 | <addset |
|
2941 | <addset | |
@@ -3169,8 +3055,7 b' no crash by empty group "()" while optim' | |||||
3169 | (or |
|
3055 | (or | |
3170 | (list |
|
3056 | (list | |
3171 | ('symbol', '0') |
|
3057 | ('symbol', '0') | |
3172 | None) |
|
3058 | None)) | |
3173 | define) |
|
|||
3174 | hg: parse error: missing argument |
|
3059 | hg: parse error: missing argument | |
3175 | [255] |
|
3060 | [255] | |
3176 |
|
3061 | |||
@@ -3200,8 +3085,7 b' check that conversion to only works' | |||||
3200 | ('symbol', 'only') |
|
3085 | ('symbol', 'only') | |
3201 | (list |
|
3086 | (list | |
3202 | ('symbol', '3') |
|
3087 | ('symbol', '3') | |
3203 | ('symbol', '1')) |
|
3088 | ('symbol', '1'))) | |
3204 | define) |
|
|||
3205 | * set: |
|
3089 | * set: | |
3206 | <baseset+ [3]> |
|
3090 | <baseset+ [3]> | |
3207 | 3 |
|
3091 | 3 | |
@@ -3218,8 +3102,7 b' check that conversion to only works' | |||||
3218 | ('symbol', 'only') |
|
3102 | ('symbol', 'only') | |
3219 | (list |
|
3103 | (list | |
3220 | ('symbol', '1') |
|
3104 | ('symbol', '1') | |
3221 | ('symbol', '3')) |
|
3105 | ('symbol', '3'))) | |
3222 | define) |
|
|||
3223 | * set: |
|
3106 | * set: | |
3224 | <baseset+ []> |
|
3107 | <baseset+ []> | |
3225 | $ try --optimize 'not ::2 and ::6' |
|
3108 | $ try --optimize 'not ::2 and ::6' | |
@@ -3234,8 +3117,7 b' check that conversion to only works' | |||||
3234 | ('symbol', 'only') |
|
3117 | ('symbol', 'only') | |
3235 | (list |
|
3118 | (list | |
3236 | ('symbol', '6') |
|
3119 | ('symbol', '6') | |
3237 | ('symbol', '2')) |
|
3120 | ('symbol', '2'))) | |
3238 | define) |
|
|||
3239 | * set: |
|
3121 | * set: | |
3240 | <baseset+ [3, 4, 5, 6]> |
|
3122 | <baseset+ [3, 4, 5, 6]> | |
3241 | 3 |
|
3123 | 3 | |
@@ -3256,8 +3138,7 b' check that conversion to only works' | |||||
3256 | ('symbol', 'only') |
|
3138 | ('symbol', 'only') | |
3257 | (list |
|
3139 | (list | |
3258 | ('symbol', '6') |
|
3140 | ('symbol', '6') | |
3259 | ('symbol', '4')) |
|
3141 | ('symbol', '4'))) | |
3260 | define) |
|
|||
3261 | * set: |
|
3142 | * set: | |
3262 | <baseset+ [3, 5, 6]> |
|
3143 | <baseset+ [3, 5, 6]> | |
3263 | 3 |
|
3144 | 3 | |
@@ -3273,13 +3154,11 b' no crash by empty group "()" while optim' | |||||
3273 | (group |
|
3154 | (group | |
3274 | None)) |
|
3155 | None)) | |
3275 | * optimized: |
|
3156 | * optimized: | |
3276 | (and |
|
3157 | (flipand | |
3277 | None |
|
3158 | None | |
3278 | (func |
|
3159 | (func | |
3279 | ('symbol', 'ancestors') |
|
3160 | ('symbol', 'ancestors') | |
3280 | ('symbol', '1') |
|
3161 | ('symbol', '1'))) | |
3281 | define) |
|
|||
3282 | define) |
|
|||
3283 | hg: parse error: missing argument |
|
3162 | hg: parse error: missing argument | |
3284 | [255] |
|
3163 | [255] | |
3285 |
|
3164 | |||
@@ -3290,15 +3169,12 b' optimization to only() works only if anc' | |||||
3290 | (difference |
|
3169 | (difference | |
3291 | (func |
|
3170 | (func | |
3292 | ('symbol', 'ancestors') |
|
3171 | ('symbol', 'ancestors') | |
3293 | ('symbol', '6') |
|
3172 | ('symbol', '6')) | |
3294 | define) |
|
|||
3295 | (func |
|
3173 | (func | |
3296 | ('symbol', 'ancestors') |
|
3174 | ('symbol', 'ancestors') | |
3297 | (list |
|
3175 | (list | |
3298 | ('symbol', '4') |
|
3176 | ('symbol', '4') | |
3299 | ('symbol', '1')) |
|
3177 | ('symbol', '1')))) | |
3300 | any) |
|
|||
3301 | define) |
|
|||
3302 | 0 |
|
3178 | 0 | |
3303 | 1 |
|
3179 | 1 | |
3304 | 3 |
|
3180 | 3 | |
@@ -3311,13 +3187,10 b' optimization to only() works only if anc' | |||||
3311 | ('symbol', 'ancestors') |
|
3187 | ('symbol', 'ancestors') | |
3312 | (list |
|
3188 | (list | |
3313 | ('symbol', '6') |
|
3189 | ('symbol', '6') | |
3314 | ('symbol', '1')) |
|
3190 | ('symbol', '1'))) | |
3315 | define) |
|
|||
3316 | (func |
|
3191 | (func | |
3317 | ('symbol', 'ancestors') |
|
3192 | ('symbol', 'ancestors') | |
3318 | ('symbol', '4') |
|
3193 | ('symbol', '4'))) | |
3319 | any) |
|
|||
3320 | define) |
|
|||
3321 | 5 |
|
3194 | 5 | |
3322 | 6 |
|
3195 | 6 | |
3323 |
|
3196 | |||
@@ -3331,15 +3204,12 b' to support it)' | |||||
3331 | ('symbol', 'ancestors') |
|
3204 | ('symbol', 'ancestors') | |
3332 | (keyvalue |
|
3205 | (keyvalue | |
3333 | ('symbol', 'set') |
|
3206 | ('symbol', 'set') | |
3334 | ('symbol', '6')) |
|
3207 | ('symbol', '6'))) | |
3335 | define) |
|
|||
3336 | (func |
|
3208 | (func | |
3337 | ('symbol', 'ancestors') |
|
3209 | ('symbol', 'ancestors') | |
3338 | (keyvalue |
|
3210 | (keyvalue | |
3339 | ('symbol', 'set') |
|
3211 | ('symbol', 'set') | |
3340 | ('symbol', '4')) |
|
3212 | ('symbol', '4')))) | |
3341 | any) |
|
|||
3342 | define) |
|
|||
3343 | 3 |
|
3213 | 3 | |
3344 | 5 |
|
3214 | 5 | |
3345 | 6 |
|
3215 | 6 |
General Comments 0
You need to be logged in to leave comments.
Login now