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