# HG changeset patch
# User Martin Geisler <mg@aragost.com>
# Date 1276683734 -7200
#      Wed Jun 16 12:22:14 2010 +0200
# Node ID 7914628b4751a6f8d56e26711f347df8df46d588
# Parent  511445840148dfbce32fa09e8ba2e0cca7b4b564
relink: ensure deterministic directory walk in collect

diff --git a/hgext/relink.py b/hgext/relink.py
--- a/hgext/relink.py
+++ b/hgext/relink.py
@@ -72,8 +72,9 @@
     ui.status(_("tip has %d files, estimated total number of files: %s\n")
               % (live, total))
     for dirpath, dirnames, filenames in os.walk(src):
+        dirnames.sort()
         relpath = dirpath[len(src) + seplen:]
-        for filename in filenames:
+        for filename in sorted(filenames):
             if not filename[-2:] in ('.d', '.i'):
                 continue
             st = os.stat(os.path.join(dirpath, filename))
diff --git a/tests/test-relink.out b/tests/test-relink.out
--- a/tests/test-relink.out
+++ b/tests/test-relink.out
@@ -15,9 +15,9 @@
 tip has 2 files, estimated total number of files: 3
 collecting: 00changelog.i 1/3 files (33.33%)
 collecting: 00manifest.i 2/3 files (66.67%)
-collecting: dummy.i 3/3 files (100.00%)
+collecting: a.i 3/3 files (100.00%)
 collecting: b.i 4/3 files (133.33%)
-collecting: a.i 5/3 files (166.67%)
+collecting: dummy.i 5/3 files (166.67%)
 collected 5 candidate storage files
 not linkable: 00changelog.i
 not linkable: 00manifest.i