revset: restore order of `or` operation as in Mercurial 2.9
authorPierre-Yves David <pierre-yves.david@fb.com>
Thu, 09 Oct 2014 04:24:51 -0700
changeset 22861 546fa6576815
parent 22860 1dd178277cf5
child 22862 9e5576f822cc
revset: restore order of `or` operation as in Mercurial 2.9 Lazy revset broke the ordering of the `or` revset. We now stop assuming that two ascending revset are combine into an ascending one. Behavior in 3.0: 3:4 or 2:5 == [2, 3, 4, 5] Behavior in 2.9: 3:4 or 2:5 == [3, 4, 2, 5] We are adding a test for it. For unclear reason, the performance `or` revset with expensive filter are getting even worse than they used to be. This is probably caused by extra uncached containment check or iteration. revset #9: author(lmoscovicz) or author(mpm) before) wall 3.487583 comb 3.490000 user 3.490000 sys 0.000000 (best of 3) after) wall 4.481486 comb 4.480000 user 4.470000 sys 0.010000 (best of 3) revset #10: author(mpm) or author(lmoscovicz) before) wall 3.164839 comb 3.170000 user 3.160000 sys 0.010000 (best of 3) after) wall 4.574965 comb 4.570000 user 4.570000 sys 0.000000 (best of 3)
mercurial/revset.py
tests/test-revset.t
--- a/mercurial/revset.py	Thu Oct 09 09:12:54 2014 -0700
+++ b/mercurial/revset.py	Thu Oct 09 04:24:51 2014 -0700
@@ -2283,12 +2283,7 @@
         """Returns a new object with the union of the two collections.
 
         This is part of the mandatory API for smartset."""
-        kwargs = {}
-        if self.isascending() and other.isascending():
-            kwargs['ascending'] = True
-        if self.isdescending() and other.isdescending():
-            kwargs['ascending'] = False
-        return addset(self, other, **kwargs)
+        return addset(self, other)
 
     def __sub__(self, other):
         """Returns a new object with the substraction of the two collections.
--- a/tests/test-revset.t	Thu Oct 09 09:12:54 2014 -0700
+++ b/tests/test-revset.t	Thu Oct 09 04:24:51 2014 -0700
@@ -572,6 +572,29 @@
   5
   8
 
+test that `or` operation combines elements in the right order:
+
+  $ log '3:4 or 2:5'
+  3
+  4
+  2
+  5
+  $ log '3:4 or 5:2'
+  3
+  4
+  5
+  2
+  $ log 'sort(3:4 or 2:5)'
+  2
+  3
+  4
+  5
+  $ log 'sort(3:4 or 5:2)'
+  2
+  3
+  4
+  5
+
 check that conversion to only works
   $ try --optimize '::3 - ::1'
   (minus