[PATCH 1 of 3] tags: write tags cache deterministically

Gregory Szorc gregory.szorc at gmail.com
Tue Feb 24 09:11:52 UTC 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1424765207 28800
#      Tue Feb 24 00:06:47 2015 -0800
# Branch stable
# Node ID 0051ab347e37bea44a875deb9045af5ef076cbfb
# Parent  942a5a34b2d0611ab284380fbe45b9bb1897af98
tags: write tags cache deterministically

An upcoming test verifies content of the .hg/cache/tags file. During
testing, inconsistent output was observed. This is the result of
iterating over a dictionary.

Throw a sorted() around tags entries to ensure .hg/cache/tags is written
deterministically so test output is stable.

diff --git a/mercurial/tags.py b/mercurial/tags.py
--- a/mercurial/tags.py
+++ b/mercurial/tags.py
@@ -336,9 +336,9 @@ def _writetagcache(ui, repo, heads, tagf
     # we keep them in UTF-8 throughout this module.  If we converted
     # them local encoding on input, we would lose info writing them to
     # the cache.
     cachefile.write('\n')
-    for (name, (node, hist)) in cachetags.iteritems():
+    for (name, (node, hist)) in sorted(cachetags.iteritems()):
         for n in hist:
             cachefile.write("%s %s\n" % (hex(n), name))
         cachefile.write("%s %s\n" % (hex(node), name))
 


More information about the Mercurial-devel mailing list