Patchwork D2469: bookmarks: write bookmarks file deterministically

login
register
mail settings
Submitter phabricator
Date Feb. 26, 2018, 9:34 p.m.
Message ID <differential-rev-PHID-DREV-fk4oufyd43pws5g3abmj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/28434/
State Superseded
Headers show

Comments

phabricator - Feb. 26, 2018, 9:34 p.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Bookmarks are internally stored as an unsorted dictionary. Let's at
  least write out the bookmarks file in a deterministic order so it is
  easier to test, diff, etc.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2469

AFFECTED FILES
  mercurial/bookmarks.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/bookmarks.py b/mercurial/bookmarks.py
--- a/mercurial/bookmarks.py
+++ b/mercurial/bookmarks.py
@@ -179,7 +179,7 @@ 
         self._aclean = True
 
     def _write(self, fp):
-        for name, node in self.iteritems():
+        for name, node in sorted(self.iteritems()):
             fp.write("%s %s\n" % (hex(node), encoding.fromlocal(name)))
         self._clean = True
         self._repo.invalidatevolatilesets()