# HG changeset patch # User Gregory Szorc # Date 2016-07-17 21:51:00 # Node ID 6215b5537ba59bce999e6f49353fc9d8c7137aed # Parent 84c1a5942f1d24cd34d38a498113226b93fb0588 bundle2: use a sorted dict for holding parameters An upcoming change that introduces a 2nd part parameter to a part reveals that `hg debugbundle` isn't deterministic because parameters are stored on n plain, unsorted dict. While we could change that command to sort before output, I think the more important underlying issue is that bundle2 reading is taking an ordered data structure and converting it to an unordered one. Plugging in util.sortdict() fixes that problem while preserving API compatibility. This patch also appears to shine light on the fact that we don't have tests verifying parts with multiple parameters roundtrip correctly. That would be a good thing to test (and fuzz)... someday. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -690,7 +690,7 @@ class unbundle20(unpackermixin): def _processallparams(self, paramsblock): """""" - params = {} + params = util.sortdict() for p in paramsblock.split(' '): p = p.split('=', 1) p = [urlreq.unquote(i) for i in p] @@ -1115,8 +1115,8 @@ class unbundlepart(unpackermixin): self.mandatoryparams = tuple(mandatoryparams) self.advisoryparams = tuple(advisoryparams) # user friendly UI - self.params = dict(self.mandatoryparams) - self.params.update(dict(self.advisoryparams)) + self.params = util.sortdict(self.mandatoryparams) + self.params.update(self.advisoryparams) self.mandatorykeys = frozenset(p[0] for p in mandatoryparams) def _payloadchunks(self, chunknum=0):