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.
--- a/mercurial/revset.py Wed Jun 27 23:33:57 2018 +0900
+++ b/mercurial/revset.py Wed Jun 27 23:39:41 2018 +0900
@@ -1129,11 +1129,14 @@
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
--- a/tests/test-revset.t Wed Jun 27 23:33:57 2018 +0900
+++ b/tests/test-revset.t Wed Jun 27 23:39:41 2018 +0900
@@ -1376,20 +1376,20 @@
<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