Patchwork revset: make dagrange preserve order of input set

login
register
mail settings
Submitter Yuya Nishihara
Date May 11, 2016, 1:14 p.m.
Message ID <1d9b068c9d8ef6c100af.1462972460@mimosa>
Download mbox | patch
Permalink /patch/15019/
State Accepted
Headers show

Comments

Yuya Nishihara - May 11, 2016, 1:14 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.
Pierre-Yves David - May 11, 2016, 2:18 p.m.
On 05/11/2016 03:14 PM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@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

Nice, pushed.
Thanks for pushing things up.

Patch

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
 --------------------------------------------