# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1530110381 -32400
#      Wed Jun 27 23:39:41 2018 +0900
# Node ID 542ca250795430ee77aeb5e5558f36f60dab3ca1
# Parent  5aee640e2a99a305dc6f5219c35d2140180169a1
revset: fix heads() order to always follow the input set (BC)

An argument expression should never affect the order of the result set.
That's the rule of the revset predicates.

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -1129,11 +1129,14 @@ def head(repo, subset, x):
         hs.update(cl.rev(h) for h in ls)
     return subset & baseset(hs)
 
-@predicate('heads(set)', safe=True)
-def heads(repo, subset, x):
+@predicate('heads(set)', safe=True, takeorder=True)
+def heads(repo, subset, x, order):
     """Members of set with no children in set.
     """
-    s = getset(repo, subset, x)
+    # argument set should never define order
+    if order == defineorder:
+        order = followorder
+    s = getset(repo, subset, x, order=order)
     ps = parents(repo, subset, x)
     return s - ps
 
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -1376,20 +1376,20 @@ Test heads
         <baseset [9]>, set([0, 1, 2, 3, 4, 5, 6, 8])>>>
   9
 
- BROKEN: but should follow the order of the subset
+ but should follow the order of the subset
 
   $ log 'heads(all())'
   7
   9
   $ log 'heads(tip:0)'
+  7
   9
-  7
   $ log 'tip:0 & heads(all())'
   9
   7
   $ log 'tip:0 & heads(0:tip)'
+  9
   7
-  9
 
   $ log 'keyword(issue)'
   6
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to