Details
Details
- Reviewers
indygreg - Group Reviewers
hg-reviewers - Commits
- rHG483de34f23b1: hook: use stringutil.pprint instead of reinventing it
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
indygreg |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/hook.py (7 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 | ||
Closed | durin42 |
encoding, | encoding, | ||||
error, | error, | ||||
extensions, | extensions, | ||||
pycompat, | pycompat, | ||||
util, | util, | ||||
) | ) | ||||
from .utils import ( | from .utils import ( | ||||
procutil, | procutil, | ||||
stringutil, | |||||
) | ) | ||||
def _pythonhook(ui, repo, htype, hname, funcname, args, throw): | def _pythonhook(ui, repo, htype, hname, funcname, args, throw): | ||||
'''call python hook. hook is callable object, looked up as | '''call python hook. hook is callable object, looked up as | ||||
name in python module. if callable returns "true", hook | name in python module. if callable returns "true", hook | ||||
fails, else passes. if hook raises exception, treated as | fails, else passes. if hook raises exception, treated as | ||||
hook failure. exception propagates if throw is "true". | hook failure. exception propagates if throw is "true". | ||||
env['HG_PENDING'] = repo.root | env['HG_PENDING'] = repo.root | ||||
env['HG_HOOKTYPE'] = htype | env['HG_HOOKTYPE'] = htype | ||||
env['HG_HOOKNAME'] = name | env['HG_HOOKNAME'] = name | ||||
for k, v in args.iteritems(): | for k, v in args.iteritems(): | ||||
if callable(v): | if callable(v): | ||||
v = v() | v = v() | ||||
if isinstance(v, dict): | if isinstance(v, dict): | ||||
# make the dictionary element order stable across Python | v = stringutil.pprint(v, bprefix=False) | ||||
# implementations | |||||
v = ('{' + | |||||
', '.join('%r: %r' % i for i in sorted(v.iteritems())) + | |||||
'}') | |||||
env['HG_' + k.upper()] = v | env['HG_' + k.upper()] = v | ||||
if repo: | if repo: | ||||
cwd = repo.root | cwd = repo.root | ||||
else: | else: | ||||
cwd = pycompat.getcwd() | cwd = pycompat.getcwd() | ||||
r = ui.system(cmd, environ=env, cwd=cwd, blockedtag='exthook-%s' % (name,)) | r = ui.system(cmd, environ=env, cwd=cwd, blockedtag='exthook-%s' % (name,)) | ||||