[PATCH] revset: make dagrange preserve order of input set

Yuya Nishihara yuya at tcha.org
Wed May 11 13:14:20 UTC 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1462246604 -32400
#      Tue May 03 12:36:44 2016 +0900
# Node ID 1d9b068c9d8ef6c100aff935683c462953fdae2e
# Parent  d115cbf5980b451e94f429fb57a29ca2cd279676
revset: make dagrange preserve order of input set

Unlike range, dagrange has no inverted range (such as '10:0'). So there should
be no practical reason to keep dagrange as a function that forces its own
ordering.

No performance regression is spotted in contrib/base-revsets.txt.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -386,9 +386,7 @@ def dagrange(repo, subset, x, y):
     r = fullreposet(repo)
     xs = reachableroots(repo, getset(repo, r, x), getset(repo, r, y),
                          includepath=True)
-    # XXX We should combine with subset first: 'subset & baseset(...)'. This is
-    # necessary to ensure we preserve the order in subset.
-    return xs & subset
+    return subset & xs
 
 def andset(repo, subset, x, y):
     return getset(repo, getset(repo, subset, x), y)
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -898,6 +898,16 @@ Test working-directory revision
   $ log 'tag(tip)'
   9
 
+Test order of revisions in compound expression
+----------------------------------------------
+
+ 'A & B' should follow the order of 'A':
+
+  $ log '2:0 & 0::2'
+  2
+  1
+  0
+
 test sort revset
 --------------------------------------------
 


More information about the Mercurial-devel mailing list