##// END OF EJS Templates
revset: wrap arguments of 'or' by 'list' node...
Yuya Nishihara -
r29929:b3845cab default
parent child Browse files
Show More
@@ -397,15 +397,18 b' def andset(repo, subset, x, y):'
397 397 def differenceset(repo, subset, x, y):
398 398 return getset(repo, subset, x) - getset(repo, subset, y)
399 399
400 def orset(repo, subset, *xs):
400 def _orsetlist(repo, subset, xs):
401 401 assert xs
402 402 if len(xs) == 1:
403 403 return getset(repo, subset, xs[0])
404 404 p = len(xs) // 2
405 a = orset(repo, subset, *xs[:p])
406 b = orset(repo, subset, *xs[p:])
405 a = _orsetlist(repo, subset, xs[:p])
406 b = _orsetlist(repo, subset, xs[p:])
407 407 return a + b
408 408
409 def orset(repo, subset, x):
410 return _orsetlist(repo, subset, getlist(x))
411
409 412 def notset(repo, subset, x):
410 413 return subset - getset(repo, subset, x)
411 414
@@ -2339,6 +2342,10 b' def _fixops(x):'
2339 2342 return _fixops(('range', post, x[2][1]))
2340 2343 elif x[2][0] == 'rangeall':
2341 2344 return _fixops(('rangepost', post))
2345 elif op == 'or':
2346 # make number of arguments deterministic:
2347 # x + y + z -> (or x y z) -> (or (list x y z))
2348 return (op, _fixops(('list',) + x[1:]))
2342 2349
2343 2350 return (op,) + tuple(_fixops(y) for y in x[1:])
2344 2351
@@ -2374,7 +2381,7 b' def _analyze(x):'
2374 2381 tb = _analyze(x[2])
2375 2382 return (op, ta, tb)
2376 2383 elif op == 'or':
2377 return (op,) + tuple(_analyze(y) for y in x[1:])
2384 return (op, _analyze(x[1]))
2378 2385 elif op == 'not':
2379 2386 return (op, _analyze(x[1]))
2380 2387 elif op == 'parentpost':
@@ -2445,7 +2452,7 b' def _optimize(x, small):'
2445 2452 ws.append(w)
2446 2453 ts.append(t)
2447 2454 del ss[:]
2448 for y in x[1:]:
2455 for y in getlist(x[1]):
2449 2456 w, t = _optimize(y, False)
2450 2457 if t is not None and (t[0] == 'string' or t[0] == 'symbol'):
2451 2458 ss.append((w, t))
@@ -2459,7 +2466,7 b' def _optimize(x, small):'
2459 2466 # we can't reorder trees by weight because it would change the order.
2460 2467 # ("sort(a + b)" == "sort(b + a)", but "a + b" != "b + a")
2461 2468 # ts = tuple(t for w, t in sorted(zip(ws, ts), key=lambda wt: wt[0]))
2462 return max(ws), (op,) + tuple(ts)
2469 return max(ws), (op, ('list',) + tuple(ts))
2463 2470 elif op == 'not':
2464 2471 # Optimize not public() to _notpublic() because we have a fast version
2465 2472 if x[1] == ('func', ('symbol', 'public'), None):
@@ -2613,7 +2620,7 b' def matchany(ui, specs, repo=None):'
2613 2620 if len(specs) == 1:
2614 2621 tree = parse(specs[0], lookup)
2615 2622 else:
2616 tree = ('or',) + tuple(parse(s, lookup) for s in specs)
2623 tree = ('or', ('list',) + tuple(parse(s, lookup) for s in specs))
2617 2624
2618 2625 if ui:
2619 2626 tree = expandaliases(ui, tree)
@@ -1455,12 +1455,13 b' glog always reorders nodes which explain'
1455 1455 (group
1456 1456 (group
1457 1457 (or
1458 (list
1458 1459 (func
1459 1460 ('symbol', 'user')
1460 1461 ('string', 'test'))
1461 1462 (func
1462 1463 ('symbol', 'user')
1463 ('string', 'not-a-user')))))
1464 ('string', 'not-a-user'))))))
1464 1465 $ testlog -b not-a-branch
1465 1466 abort: unknown revision 'not-a-branch'!
1466 1467 abort: unknown revision 'not-a-branch'!
@@ -1470,6 +1471,7 b' glog always reorders nodes which explain'
1470 1471 (group
1471 1472 (group
1472 1473 (or
1474 (list
1473 1475 (func
1474 1476 ('symbol', 'branch')
1475 1477 ('string', 'default'))
@@ -1478,18 +1480,19 b' glog always reorders nodes which explain'
1478 1480 ('string', 'branch'))
1479 1481 (func
1480 1482 ('symbol', 'branch')
1481 ('string', 'branch')))))
1483 ('string', 'branch'))))))
1482 1484 $ testlog -k expand -k merge
1483 1485 []
1484 1486 (group
1485 1487 (group
1486 1488 (or
1489 (list
1487 1490 (func
1488 1491 ('symbol', 'keyword')
1489 1492 ('string', 'expand'))
1490 1493 (func
1491 1494 ('symbol', 'keyword')
1492 ('string', 'merge')))))
1495 ('string', 'merge'))))))
1493 1496 $ testlog --only-merges
1494 1497 []
1495 1498 (group
@@ -1520,17 +1523,19 b' glog always reorders nodes which explain'
1520 1523 (not
1521 1524 (group
1522 1525 (or
1526 (list
1523 1527 ('string', '31')
1524 1528 (func
1525 1529 ('symbol', 'ancestors')
1526 ('string', '31')))))
1530 ('string', '31'))))))
1527 1531 (not
1528 1532 (group
1529 1533 (or
1534 (list
1530 1535 ('string', '32')
1531 1536 (func
1532 1537 ('symbol', 'ancestors')
1533 ('string', '32'))))))))
1538 ('string', '32')))))))))
1534 1539
1535 1540 Dedicated repo for --follow and paths filtering. The g is crafted to
1536 1541 have 2 filelog topological heads in a linear changeset graph.
@@ -1587,12 +1592,13 b' have 2 filelog topological heads in a li'
1587 1592 (group
1588 1593 (group
1589 1594 (or
1595 (list
1590 1596 (func
1591 1597 ('symbol', 'filelog')
1592 1598 ('string', 'a'))
1593 1599 (func
1594 1600 ('symbol', 'filelog')
1595 ('string', 'b')))))
1601 ('string', 'b'))))))
1596 1602
1597 1603 Test falling back to slow path for non-existing files
1598 1604
@@ -1744,12 +1750,13 b' Test --follow and multiple files'
1744 1750 (group
1745 1751 (group
1746 1752 (or
1753 (list
1747 1754 (func
1748 1755 ('symbol', 'follow')
1749 1756 ('string', 'g'))
1750 1757 (func
1751 1758 ('symbol', 'follow')
1752 ('string', 'e')))))
1759 ('string', 'e'))))))
1753 1760 $ cat log.nodes
1754 1761 nodetag 4
1755 1762 nodetag 3
@@ -187,9 +187,10 b' trivial'
187 187 6
188 188 $ try '0|1|2'
189 189 (or
190 (list
190 191 ('symbol', '0')
191 192 ('symbol', '1')
192 ('symbol', '2'))
193 ('symbol', '2')))
193 194 * set:
194 195 <baseset [0, 1, 2]>
195 196 0
@@ -339,10 +340,11 b' quoting needed'
339 340 $ log '1&2'
340 341 $ try '1&2|3' # precedence - and is higher
341 342 (or
343 (list
342 344 (and
343 345 ('symbol', '1')
344 346 ('symbol', '2'))
345 ('symbol', '3'))
347 ('symbol', '3')))
346 348 * set:
347 349 <addset
348 350 <baseset []>,
@@ -350,10 +352,11 b' quoting needed'
350 352 3
351 353 $ try '1|2&3'
352 354 (or
355 (list
353 356 ('symbol', '1')
354 357 (and
355 358 ('symbol', '2')
356 ('symbol', '3')))
359 ('symbol', '3'))))
357 360 * set:
358 361 <addset
359 362 <baseset [1]>,
@@ -369,11 +372,13 b' quoting needed'
369 372 <baseset []>
370 373 $ try '1|(2|3)'
371 374 (or
375 (list
372 376 ('symbol', '1')
373 377 (group
374 378 (or
379 (list
375 380 ('symbol', '2')
376 ('symbol', '3'))))
381 ('symbol', '3'))))))
377 382 * set:
378 383 <addset
379 384 <baseset [1]>,
@@ -465,8 +470,9 b' keyword arguments'
465 470 (keyvalue
466 471 ('symbol', 'foo')
467 472 (or
473 (list
468 474 ('symbol', 'bar')
469 ('symbol', 'baz')))
475 ('symbol', 'baz'))))
470 476 hg: parse error: can't use a key-value pair in this context
471 477 [255]
472 478
@@ -528,14 +534,16 b' parsed tree at stages:'
528 534 (minus
529 535 (group
530 536 (or
537 (list
531 538 ('symbol', '0')
532 ('symbol', '1')))
539 ('symbol', '1'))))
533 540 ('symbol', '1'))
534 541 * analyzed:
535 542 (and
536 543 (or
544 (list
537 545 ('symbol', '0')
538 ('symbol', '1'))
546 ('symbol', '1')))
539 547 (not
540 548 ('symbol', '1')))
541 549 * optimized:
@@ -1242,9 +1250,10 b' ordering defined by it.'
1242 1250 ('symbol', '0'))
1243 1251 (group
1244 1252 (or
1253 (list
1245 1254 ('symbol', '0')
1246 1255 ('symbol', '1')
1247 ('symbol', '2'))))
1256 ('symbol', '2')))))
1248 1257 * optimized:
1249 1258 (and
1250 1259 (range
@@ -1269,20 +1278,22 b' ordering defined by it.'
1269 1278 ('symbol', '0'))
1270 1279 (group
1271 1280 (or
1281 (list
1272 1282 (range
1273 1283 ('symbol', '0')
1274 1284 ('symbol', '1'))
1275 ('symbol', '2'))))
1285 ('symbol', '2')))))
1276 1286 * optimized:
1277 1287 (and
1278 1288 (range
1279 1289 ('symbol', '2')
1280 1290 ('symbol', '0'))
1281 1291 (or
1292 (list
1282 1293 (range
1283 1294 ('symbol', '0')
1284 1295 ('symbol', '1'))
1285 ('symbol', '2')))
1296 ('symbol', '2'))))
1286 1297 * set:
1287 1298 <addset
1288 1299 <filteredset
@@ -1402,9 +1413,10 b' ordering defined by it.'
1402 1413 (func
1403 1414 ('symbol', 'present')
1404 1415 (or
1416 (list
1405 1417 ('symbol', '0')
1406 1418 ('symbol', '1')
1407 ('symbol', '2'))))
1419 ('symbol', '2')))))
1408 1420 * optimized:
1409 1421 (and
1410 1422 (range
@@ -1499,9 +1511,10 b' ordering defined by it.'
1499 1511 (func
1500 1512 ('symbol', 'first')
1501 1513 (or
1514 (list
1502 1515 ('symbol', '1')
1503 1516 ('symbol', '0')
1504 ('symbol', '2'))))
1517 ('symbol', '2')))))
1505 1518 * optimized:
1506 1519 (and
1507 1520 (range
@@ -1528,9 +1541,10 b' ordering defined by it.'
1528 1541 (func
1529 1542 ('symbol', 'last')
1530 1543 (or
1544 (list
1531 1545 ('symbol', '0')
1532 1546 ('symbol', '2')
1533 ('symbol', '1')))))
1547 ('symbol', '1'))))))
1534 1548 * optimized:
1535 1549 (difference
1536 1550 (range
@@ -1562,14 +1576,16 b' ordering defined by it.'
1562 1576 (range
1563 1577 (group
1564 1578 (or
1579 (list
1565 1580 ('symbol', '1')
1566 1581 ('symbol', '0')
1567 ('symbol', '2')))
1582 ('symbol', '2'))))
1568 1583 (group
1569 1584 (or
1585 (list
1570 1586 ('symbol', '0')
1571 1587 ('symbol', '2')
1572 ('symbol', '1')))))
1588 ('symbol', '1'))))))
1573 1589 * optimized:
1574 1590 (and
1575 1591 (range
@@ -1599,9 +1615,10 b' ordering defined by it.'
1599 1615 ('string', 'glob:*'))
1600 1616 (group
1601 1617 (or
1618 (list
1602 1619 ('symbol', '2')
1603 1620 ('symbol', '0')
1604 ('symbol', '1'))))
1621 ('symbol', '1')))))
1605 1622 * optimized:
1606 1623 (and
1607 1624 (func
@@ -1628,9 +1645,10 b' ordering defined by it.'
1628 1645 ('string', 'glob:*')))
1629 1646 (group
1630 1647 (or
1648 (list
1631 1649 ('symbol', '0')
1632 1650 ('symbol', '2')
1633 ('symbol', '1'))))
1651 ('symbol', '1')))))
1634 1652 * optimized:
1635 1653 (and
1636 1654 (func
@@ -1975,6 +1993,7 b' test that `or` operation skips duplicate'
1975 1993
1976 1994 $ try 'reverse(1::5) or ancestors(4)'
1977 1995 (or
1996 (list
1978 1997 (func
1979 1998 ('symbol', 'reverse')
1980 1999 (dagrange
@@ -1982,7 +2001,7 b' test that `or` operation skips duplicate'
1982 2001 ('symbol', '5')))
1983 2002 (func
1984 2003 ('symbol', 'ancestors')
1985 ('symbol', '4')))
2004 ('symbol', '4'))))
1986 2005 * set:
1987 2006 <addset
1988 2007 <baseset- [1, 3, 5]>,
@@ -1997,6 +2016,7 b' test that `or` operation skips duplicate'
1997 2016 (func
1998 2017 ('symbol', 'sort')
1999 2018 (or
2019 (list
2000 2020 (func
2001 2021 ('symbol', 'ancestors')
2002 2022 ('symbol', '4'))
@@ -2004,7 +2024,7 b' test that `or` operation skips duplicate'
2004 2024 ('symbol', 'reverse')
2005 2025 (dagrange
2006 2026 ('symbol', '1')
2007 ('symbol', '5')))))
2027 ('symbol', '5'))))))
2008 2028 * set:
2009 2029 <addset+
2010 2030 <generatorset+>,
@@ -2020,6 +2040,7 b' test optimization of trivial `or` operat'
2020 2040
2021 2041 $ try --optimize '0|(1)|"2"|-2|tip|null'
2022 2042 (or
2043 (list
2023 2044 ('symbol', '0')
2024 2045 (group
2025 2046 ('symbol', '1'))
@@ -2027,7 +2048,7 b' test optimization of trivial `or` operat'
2027 2048 (negate
2028 2049 ('symbol', '2'))
2029 2050 ('symbol', 'tip')
2030 ('symbol', 'null'))
2051 ('symbol', 'null')))
2031 2052 * optimized:
2032 2053 (func
2033 2054 ('symbol', '_list')
@@ -2043,19 +2064,21 b' test optimization of trivial `or` operat'
2043 2064
2044 2065 $ try --optimize '0|1|2:3'
2045 2066 (or
2067 (list
2046 2068 ('symbol', '0')
2047 2069 ('symbol', '1')
2048 2070 (range
2049 2071 ('symbol', '2')
2050 ('symbol', '3')))
2072 ('symbol', '3'))))
2051 2073 * optimized:
2052 2074 (or
2075 (list
2053 2076 (func
2054 2077 ('symbol', '_list')
2055 2078 ('string', '0\x001'))
2056 2079 (range
2057 2080 ('symbol', '2')
2058 ('symbol', '3')))
2081 ('symbol', '3'))))
2059 2082 * set:
2060 2083 <addset
2061 2084 <baseset [0, 1]>,
@@ -2067,6 +2090,7 b' test optimization of trivial `or` operat'
2067 2090
2068 2091 $ try --optimize '0:1|2|3:4|5|6'
2069 2092 (or
2093 (list
2070 2094 (range
2071 2095 ('symbol', '0')
2072 2096 ('symbol', '1'))
@@ -2075,9 +2099,10 b' test optimization of trivial `or` operat'
2075 2099 ('symbol', '3')
2076 2100 ('symbol', '4'))
2077 2101 ('symbol', '5')
2078 ('symbol', '6'))
2102 ('symbol', '6')))
2079 2103 * optimized:
2080 2104 (or
2105 (list
2081 2106 (range
2082 2107 ('symbol', '0')
2083 2108 ('symbol', '1'))
@@ -2087,7 +2112,7 b' test optimization of trivial `or` operat'
2087 2112 ('symbol', '4'))
2088 2113 (func
2089 2114 ('symbol', '_list')
2090 ('string', '5\x006')))
2115 ('string', '5\x006'))))
2091 2116 * set:
2092 2117 <addset
2093 2118 <addset
@@ -2109,11 +2134,12 b' unoptimized `or` looks like this'
2109 2134 $ try --no-optimized -p analyzed '0|1|2|3|4'
2110 2135 * analyzed:
2111 2136 (or
2137 (list
2112 2138 ('symbol', '0')
2113 2139 ('symbol', '1')
2114 2140 ('symbol', '2')
2115 2141 ('symbol', '3')
2116 ('symbol', '4'))
2142 ('symbol', '4')))
2117 2143 * set:
2118 2144 <addset
2119 2145 <addset
@@ -2188,6 +2214,7 b' test that chained `or` operations make b'
2188 2214
2189 2215 $ try '0:1|1:2|2:3|3:4|4:5'
2190 2216 (or
2217 (list
2191 2218 (range
2192 2219 ('symbol', '0')
2193 2220 ('symbol', '1'))
@@ -2202,7 +2229,7 b' test that chained `or` operations make b'
2202 2229 ('symbol', '4'))
2203 2230 (range
2204 2231 ('symbol', '4')
2205 ('symbol', '5')))
2232 ('symbol', '5'))))
2206 2233 * set:
2207 2234 <addset
2208 2235 <addset
@@ -2224,13 +2251,15 b' no crash by empty group "()" while optim'
2224 2251
2225 2252 $ try --optimize '0|()'
2226 2253 (or
2254 (list
2227 2255 ('symbol', '0')
2228 2256 (group
2229 None))
2257 None)))
2230 2258 * optimized:
2231 2259 (or
2260 (list
2232 2261 ('symbol', '0')
2233 None)
2262 None))
2234 2263 hg: parse error: missing argument
2235 2264 [255]
2236 2265
@@ -2715,10 +2744,12 b' test infinite recursion'
2715 2744 ('symbol', '3')))
2716 2745 * expanded:
2717 2746 (or
2747 (list
2718 2748 ('symbol', '3')
2719 2749 (or
2750 (list
2720 2751 ('symbol', '1')
2721 ('symbol', '2')))
2752 ('symbol', '2')))))
2722 2753 * set:
2723 2754 <addset
2724 2755 <baseset [3]>,
@@ -2769,6 +2800,7 b' test chained `or` operations are flatten'
2769 2800 ('symbol', '3'))))
2770 2801 * expanded:
2771 2802 (or
2803 (list
2772 2804 (range
2773 2805 ('symbol', '0')
2774 2806 ('symbol', '1'))
@@ -2777,7 +2809,7 b' test chained `or` operations are flatten'
2777 2809 ('symbol', '2'))
2778 2810 (range
2779 2811 ('symbol', '2')
2780 ('symbol', '3')))
2812 ('symbol', '3'))))
2781 2813 * set:
2782 2814 <addset
2783 2815 <spanset+ 0:1>,
@@ -2868,10 +2900,11 b' test unknown reference:'
2868 2900 ('symbol', 'tip')))
2869 2901 * expanded:
2870 2902 (or
2903 (list
2871 2904 ('symbol', 'tip')
2872 2905 (func
2873 2906 ('symbol', 'desc')
2874 ('string', '$1')))
2907 ('string', '$1'))))
2875 2908 * set:
2876 2909 <addset
2877 2910 <baseset [9]>,
@@ -2907,8 +2940,9 b' test unknown reference:'
2907 2940 ('symbol', 'rs')
2908 2941 (list
2909 2942 (or
2943 (list
2910 2944 ('symbol', '2')
2911 ('symbol', '3'))
2945 ('symbol', '3')))
2912 2946 ('symbol', 'date')))
2913 2947 * expanded:
2914 2948 (func
@@ -2917,8 +2951,9 b' test unknown reference:'
2917 2951 ('symbol', 'sort')
2918 2952 (list
2919 2953 (or
2954 (list
2920 2955 ('symbol', '2')
2921 ('symbol', '3'))
2956 ('symbol', '3')))
2922 2957 ('symbol', 'date'))))
2923 2958 * set:
2924 2959 <baseset [3, 2]>
@@ -2950,8 +2985,9 b' test unknown reference:'
2950 2985 ('symbol', 'rs4')
2951 2986 (list
2952 2987 (or
2988 (list
2953 2989 ('symbol', '2')
2954 ('symbol', '3'))
2990 ('symbol', '3')))
2955 2991 ('symbol', 'x')
2956 2992 ('symbol', 'x')
2957 2993 ('symbol', 'date')))
@@ -2962,8 +2998,9 b' test unknown reference:'
2962 2998 ('symbol', 'sort')
2963 2999 (list
2964 3000 (or
3001 (list
2965 3002 ('symbol', '2')
2966 ('symbol', '3'))
3003 ('symbol', '3')))
2967 3004 ('symbol', 'date'))))
2968 3005 * set:
2969 3006 <baseset [3, 2]>
@@ -3034,9 +3071,10 b' issue2549 - correct optimizations'
3034 3071 ('symbol', 'limit')
3035 3072 (list
3036 3073 (or
3074 (list
3037 3075 ('symbol', '1')
3038 3076 ('symbol', '2')
3039 ('symbol', '3'))
3077 ('symbol', '3')))
3040 3078 ('symbol', '2')))
3041 3079 (not
3042 3080 ('symbol', '2')))
@@ -3054,8 +3092,9 b' issue2549 - correct optimizations'
3054 3092 (func
3055 3093 ('symbol', 'max')
3056 3094 (or
3095 (list
3057 3096 ('symbol', '1')
3058 ('symbol', '2')))
3097 ('symbol', '2'))))
3059 3098 (not
3060 3099 ('symbol', '2')))
3061 3100 * set:
@@ -3071,8 +3110,9 b' issue2549 - correct optimizations'
3071 3110 (func
3072 3111 ('symbol', 'min')
3073 3112 (or
3113 (list
3074 3114 ('symbol', '1')
3075 ('symbol', '2')))
3115 ('symbol', '2'))))
3076 3116 (not
3077 3117 ('symbol', '1')))
3078 3118 * set:
@@ -3089,8 +3129,9 b' issue2549 - correct optimizations'
3089 3129 ('symbol', 'last')
3090 3130 (list
3091 3131 (or
3132 (list
3092 3133 ('symbol', '1')
3093 ('symbol', '2'))
3134 ('symbol', '2')))
3094 3135 ('symbol', '1')))
3095 3136 (not
3096 3137 ('symbol', '2')))
General Comments 0
You need to be logged in to leave comments. Login now