Patchwork D12394: subsetmaker: stabilize the computation of `scratch` subset

login
register
mail settings
Submitter phabricator
Date March 22, 2022, 7:06 a.m.
Message ID <differential-rev-PHID-DREV-u56rpujz7ry7swxzgvqb-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/50738/
State New
Headers show

Comments

phabricator - March 22, 2022, 7:06 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  `heads` is set, order of the element are not deterministic and we need to
  stabilize that if we want to get reproducible results.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D12394

AFFECTED FILES
  contrib/perf-utils/subsetmaker.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/contrib/perf-utils/subsetmaker.py b/contrib/perf-utils/subsetmaker.py
--- a/contrib/perf-utils/subsetmaker.py
+++ b/contrib/perf-utils/subsetmaker.py
@@ -102,7 +102,9 @@ 
     for x in range(n):
         if not heads:
             break
-        pick = rand.choice(list(heads))
+        pickable = list(heads)
+        pickable.sort()
+        pick = rand.choice(pickable)
         heads.remove(pick)
         assert pick not in selected
         selected.add(pick)