[PATCH 1 of 3 STABLE V3] repair: iterate store files deterministically

Gregory Szorc gregory.szorc at gmail.com
Sat Apr 8 14:37:06 EDT 2017

# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1491676500 25200
#      Sat Apr 08 11:35:00 2017 -0700
# Branch stable
# Node ID 6d0319d5dc7f2d4a6079437a5d1f8382dcb40e42
# Parent  68f263f52d2e3e2798b4f1e55cb665c6b043f93b
repair: iterate store files deterministically

An upcoming test will add a 2nd file. Since readdir() is
non-deterministic, add a sorted() to make traversal deterministic.

diff --git a/mercurial/repair.py b/mercurial/repair.py
--- a/mercurial/repair.py
+++ b/mercurial/repair.py
@@ -868,7 +868,8 @@ def _upgraderepo(ui, srcrepo, dstrepo, r
                      'redeltamultibase' in actions)
     # Now copy other files in the store directory.
-    for p, kind, st in srcrepo.store.vfs.readdir('', stat=True):
+    # The sorted() makes execution deterministic.
+    for p, kind, st in sorted(srcrepo.store.vfs.readdir('', stat=True)):
         if not _upgradefilterstorefile(srcrepo, dstrepo, requirements,
                                        p, kind, st):

More information about the Mercurial-devel mailing list