Patchwork [1,of,3] tags: write tags cache deterministically

mail settings
Submitter Gregory Szorc
Date Feb. 24, 2015, 9:11 a.m.
Message ID <0051ab347e37bea44a87.1424769112@gps-mbp.local>
Download mbox | patch
Permalink /patch/7823/
State Accepted
Headers show


Gregory Szorc - Feb. 24, 2015, 9:11 a.m.
# HG changeset patch
# User Gregory Szorc <>
# 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/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -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.
-    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))