diff mercurial/hook.py @ 13207:1775382ff833

hooks: sort any dictionaries set in the environment The actual order of dictionary items is implementation-defined in Python, and differs between CPython and PyPy. With this change, test-hooks.t passes with PyPy.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 24 Dec 2010 15:22:00 +0100
parents ecf7d6e0eef0
children 600e64004eb5
line wrap: on
line diff
--- a/mercurial/hook.py	Tue Dec 28 13:31:30 2010 -0600
+++ b/mercurial/hook.py	Fri Dec 24 15:22:00 2010 +0100
@@ -92,6 +92,12 @@
     for k, v in args.iteritems():
         if hasattr(v, '__call__'):
             v = v()
+        if isinstance(v, dict):
+            # make the dictionary element order stable across Python
+            # implementations
+            v = ('{' +
+                 ', '.join('%r: %r' % i for i in sorted(v.iteritems())) +
+                 '}')
         env['HG_' + k.upper()] = v
 
     if repo: