Patchwork D579: revset: do not flip "and" arguments when optimizing

login
register
mail settings
Submitter phabricator
Date Aug. 31, 2017, 5:50 a.m.
Message ID <92fe89490db3a005b7920b981425748f@localhost.localdomain>
Download mbox | patch
Permalink /patch/23530/
State Not Applicable
Headers show

Comments

phabricator - Aug. 31, 2017, 5:50 a.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG37b82485097f: revset: do not flip "and" arguments when optimizing (authored by quark).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D579?vs=1466&id=1467

REVISION DETAIL
  https://phab.mercurial-scm.org/D579

AFFECTED FILES
  mercurial/revset.py
  mercurial/revsetlang.py
  tests/test-revset.t

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -714,11 +714,11 @@ 
       None)
     ('symbol', '2'))
   * optimized:
-  (flipand
-    ('symbol', '2')
+  (andsmally
     (func
       ('symbol', 'r3232')
-      None))
+      None)
+    ('symbol', '2'))
   * analyzed set:
   <baseset [2]>
   * optimized set:
@@ -2056,13 +2056,13 @@ 
       ('symbol', '_intlist')
       ('string', '0\x001\x002')))
   * optimized:
-  (flipand
+  (andsmally
+    (range
+      ('symbol', '2')
+      ('symbol', '0'))
     (func
       ('symbol', '_intlist')
-      ('string', '0\x001\x002'))
-    (range
-      ('symbol', '2')
-      ('symbol', '0')))
+      ('string', '0\x001\x002')))
   * set:
   <filteredset
     <spanset- 0:3>,
@@ -2130,13 +2130,13 @@ 
       ('symbol', '2')
       ('symbol', '0')))
   * optimized:
-  (flipand
+  (andsmally
+    (func
+      ('symbol', '_hexlist')
+      ('string', '*')) (glob)
     (range
       ('symbol', '2')
-      ('symbol', '0'))
-    (func
-      ('symbol', '_hexlist')
-      ('string', '*'))) (glob)
+      ('symbol', '0')))
   * set:
   <baseset [0, 2, 1]>
   0
@@ -2415,13 +2415,13 @@ 
           ('symbol', '0')
           ('symbol', '1')))))
   * optimized:
-  (flipand
+  (andsmally
+    (func
+      ('symbol', 'contains')
+      ('string', 'glob:*'))
     (func
       ('symbol', '_list')
-      ('string', '2\x000\x001'))
-    (func
-      ('symbol', 'contains')
-      ('string', 'glob:*')))
+      ('string', '2\x000\x001')))
   * set:
   <filteredset
     <baseset+ [0, 1, 2]>,
@@ -2447,15 +2447,15 @@ 
           ('symbol', '2')
           ('symbol', '1')))))
   * optimized:
-  (flipand
-    (func
-      ('symbol', '_list')
-      ('string', '0\x002\x001'))
+  (andsmally
     (func
       ('symbol', 'reverse')
       (func
         ('symbol', 'contains')
-        ('string', 'glob:*'))))
+        ('string', 'glob:*')))
+    (func
+      ('symbol', '_list')
+      ('string', '0\x002\x001')))
   * set:
   <filteredset
     <baseset- [0, 1, 2]>,
@@ -3154,11 +3154,11 @@ 
     (group
       None))
   * optimized:
-  (flipand
-    None
+  (andsmally
     (func
       ('symbol', 'ancestors')
-      ('symbol', '1')))
+      ('symbol', '1'))
+    None)
   hg: parse error: missing argument
   [255]
 
diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -374,7 +374,7 @@ 
         if tb is not None and tb[0] == 'not':
             return wa, ('difference', ta, tb[1])
         if wa > wb:
-            return w, ('flipand', tb, ta)
+            op = 'andsmally'
         return w, (op, ta, tb)
     elif op == 'or':
         # fast path for machine-generated expression, that is likely to have
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -169,8 +169,8 @@ 
         yorder = followorder
     return getset(repo, getset(repo, subset, x, order), y, yorder)
 
-def flipandset(repo, subset, y, x, order):
-    # 'flipand(y, x)' is equivalent to 'and(x, y)', but faster when y is small
+def andsmallyset(repo, subset, x, y, order):
+    # 'andsmally(x, y)' is equivalent to 'and(x, y)', but faster when y is small
     if order == anyorder:
         yorder = anyorder
     else:
@@ -2101,7 +2101,7 @@ 
     "string": stringset,
     "symbol": stringset,
     "and": andset,
-    "flipand": flipandset,
+    "andsmally": andsmallyset,
     "or": orset,
     "not": notset,
     "difference": differenceset,