comparison mercurial/hook.py @ 37751:483de34f23b1

hook: use stringutil.pprint instead of reinventing it Differential Revision: https://phab.mercurial-scm.org/D3360
author Augie Fackler <augie@google.com>
date Fri, 13 Apr 2018 23:56:11 -0400
parents bbd240f81ac5
children 63b7415e37a5
comparison
equal deleted inserted replaced
37750:f7194c925003 37751:483de34f23b1
19 pycompat, 19 pycompat,
20 util, 20 util,
21 ) 21 )
22 from .utils import ( 22 from .utils import (
23 procutil, 23 procutil,
24 stringutil,
24 ) 25 )
25 26
26 def _pythonhook(ui, repo, htype, hname, funcname, args, throw): 27 def _pythonhook(ui, repo, htype, hname, funcname, args, throw):
27 '''call python hook. hook is callable object, looked up as 28 '''call python hook. hook is callable object, looked up as
28 name in python module. if callable returns "true", hook 29 name in python module. if callable returns "true", hook
135 136
136 for k, v in args.iteritems(): 137 for k, v in args.iteritems():
137 if callable(v): 138 if callable(v):
138 v = v() 139 v = v()
139 if isinstance(v, dict): 140 if isinstance(v, dict):
140 # make the dictionary element order stable across Python 141 v = stringutil.pprint(v, bprefix=False)
141 # implementations
142 v = ('{' +
143 ', '.join('%r: %r' % i for i in sorted(v.iteritems())) +
144 '}')
145 env['HG_' + k.upper()] = v 142 env['HG_' + k.upper()] = v
146 143
147 if repo: 144 if repo:
148 cwd = repo.root 145 cwd = repo.root
149 else: 146 else: