diff mercurial/revset.py @ 29939:e34cd85dc5b1

revset: fix order of nested '_(|int|hex)list' expression (BC) This fixes the order of 'x & (y + z)' where 'y' and 'z' are trivial, and the other uses of _list()-family functions. The original functions are renamed to '_ordered(|int|hex)list' to say clearly that they do not follow the subset ordering.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 26 Jun 2016 18:41:28 +0900
parents 2c6a05b938d8
children 80c86b9bb40b
line wrap: on
line diff
--- a/mercurial/revset.py	Sun Jun 26 18:17:12 2016 +0900
+++ b/mercurial/revset.py	Sun Jun 26 18:41:28 2016 +0900
@@ -2253,9 +2253,7 @@
         return baseset([node.wdirrev])
     return baseset()
 
-# for internal use
-@predicate('_list', safe=True)
-def _list(repo, subset, x):
+def _orderedlist(repo, subset, x):
     s = getstring(x, "internal error")
     if not s:
         return baseset()
@@ -2284,8 +2282,15 @@
     return baseset(ls)
 
 # for internal use
-@predicate('_intlist', safe=True)
-def _intlist(repo, subset, x):
+@predicate('_list', safe=True, takeorder=True)
+def _list(repo, subset, x, order):
+    if order == followorder:
+        # slow path to take the subset order
+        return subset & _orderedlist(repo, fullreposet(repo), x)
+    else:
+        return _orderedlist(repo, subset, x)
+
+def _orderedintlist(repo, subset, x):
     s = getstring(x, "internal error")
     if not s:
         return baseset()
@@ -2294,8 +2299,15 @@
     return baseset([r for r in ls if r in s])
 
 # for internal use
-@predicate('_hexlist', safe=True)
-def _hexlist(repo, subset, x):
+@predicate('_intlist', safe=True, takeorder=True)
+def _intlist(repo, subset, x, order):
+    if order == followorder:
+        # slow path to take the subset order
+        return subset & _orderedintlist(repo, fullreposet(repo), x)
+    else:
+        return _orderedintlist(repo, subset, x)
+
+def _orderedhexlist(repo, subset, x):
     s = getstring(x, "internal error")
     if not s:
         return baseset()
@@ -2304,6 +2316,15 @@
     s = subset
     return baseset([r for r in ls if r in s])
 
+# for internal use
+@predicate('_hexlist', safe=True, takeorder=True)
+def _hexlist(repo, subset, x, order):
+    if order == followorder:
+        # slow path to take the subset order
+        return subset & _orderedhexlist(repo, fullreposet(repo), x)
+    else:
+        return _orderedhexlist(repo, subset, x)
+
 methods = {
     "range": rangeset,
     "dagrange": dagrange,