Patchwork [2,of,6] phases: emit phases to pushkey protocol in deterministic order

login
register
mail settings
Submitter Gregory Szorc
Date April 14, 2017, 7:44 a.m.
Message ID <283a95fe4ce5b91af4e2.1492155846@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20195/
State Accepted
Headers show

Comments

Gregory Szorc - April 14, 2017, 7:44 a.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1492146724 25200
#      Thu Apr 13 22:12:04 2017 -0700
# Node ID 283a95fe4ce5b91af4e2ed8ed1d3fe18ef3544bb
# Parent  c56b03b176c65a460e282956827f5f8ab6890283
phases: emit phases to pushkey protocol in deterministic order

An upcoming test will report exact bytes sent over the wire protocol.
Without this change, the ordering of phases listkey data is
non-deterministic.

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -116,6 +116,7 @@  from . import (
     error,
     smartset,
     txnutil,
+    util,
 )
 
 allphases = public, draft, secret = range(3)
@@ -386,7 +387,8 @@  def retractboundary(repo, tr, targetphas
 
 def listphases(repo):
     """List phases root for serialization over pushkey"""
-    keys = {}
+    # Use ordered dictionary so behavior is deterministic.
+    keys = util.sortdict()
     value = '%i' % draft
     for root in repo._phasecache.phaseroots[draft]:
         keys[hex(root)] = value