stablesort: make sure heads are processed in sorted order
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 29 Jun 2018 16:51:56 +0200
changeset 3857 9672de8055cd
parent 3856 9c0b37be8582
child 3858 bb4f5ad63877
stablesort: make sure heads are processed in sorted order changeset 72621094505f will fix some ordering issue in the `heads` revset so we stabilise the output in advance.
hgext3rd/evolve/stablesort.py
tests/test-stablesort.t
--- a/hgext3rd/evolve/stablesort.py	Tue Jun 19 23:21:54 2018 +0530
+++ b/hgext3rd/evolve/stablesort.py	Fri Jun 29 16:51:56 2018 +0200
@@ -178,10 +178,10 @@
     if not revs:
         return []
     elif len(revs) == 1:
-        heads = list(revs)
+        heads = list(sorted(revs))
     else:
         # keeps heads only
-        heads = sorted(repo.revs('heads(%ld::%ld)', revs, revs), key=tiebreaker)
+        heads = sorted(repo.revs('sort(heads(%ld::%ld))', revs, revs), key=tiebreaker)
 
     results = []
     while heads:
@@ -247,7 +247,7 @@
     return result
 
 def stablesort_mergepoint_head_basic(repo, revs, limit=None):
-    heads = repo.revs('heads(%ld)', revs)
+    heads = repo.revs('sort(heads(%ld))', revs)
     if not heads:
         return []
     elif 2 < len(heads):
@@ -260,7 +260,7 @@
     return revs[-limit:]
 
 def stablesort_mergepoint_head_debug(repo, revs, limit=None):
-    heads = repo.revs('heads(%ld)', revs)
+    heads = repo.revs('sort(heads(%ld))', revs)
     if not heads:
         return []
     elif 2 < len(heads):
@@ -305,7 +305,7 @@
     return bottom + mid + top
 
 def stablesort_mergepoint_head_cached(repo, revs, limit=None):
-    heads = repo.revs('heads(%ld)', revs)
+    heads = repo.revs('sort(heads(%ld))', revs)
     if not heads:
         return []
     elif 2 < len(heads):
@@ -505,7 +505,7 @@
             recordjump(previous, lower, size)
 
 def stablesort_mergepoint_head_ondisk(repo, revs, limit=None):
-    heads = repo.revs('heads(%ld)', revs)
+    heads = repo.revs('sort(heads(%ld))', revs)
     if not heads:
         return []
     elif 2 < len(heads):
--- a/tests/test-stablesort.t	Tue Jun 19 23:21:54 2018 +0530
+++ b/tests/test-stablesort.t	Fri Jun 29 16:51:56 2018 +0200
@@ -538,7 +538,7 @@
   94e0ea8cdade135dabde4ec5e9954329  D.non-heads.order
   $ python "$RUNTESTDIR/md5sum.py" *.non-heads.orderhead
   1e5ce05b507a058c5dac3d7de9ae8feb  A.non-heads.orderhead
-  1e5ce05b507a058c5dac3d7de9ae8feb  B.non-heads.orderhead
+  4b07febabfee9528aedcea156a7d7071  B.non-heads.orderhead
   1e5ce05b507a058c5dac3d7de9ae8feb  C.non-heads.orderhead
   1e5ce05b507a058c5dac3d7de9ae8feb  D.non-heads.orderhead