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

login
register
mail settings
Submitter Gregory Szorc
Date April 8, 2017, 6:37 p.m.
Message ID <6d0319d5dc7f2d4a6079.1491676626@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20026/
State Accepted
Headers show

Comments

Gregory Szorc - April 8, 2017, 6:37 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.
Yuya Nishihara - April 9, 2017, 4:27 a.m.
On Sat, 08 Apr 2017 11:37:06 -0700, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc@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

Queued, thanks.

Patch

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):
             continue