Skip to content
Snippets Groups Projects
Commit fbac323eb625 authored by Yuya Nishihara's avatar Yuya Nishihara
Browse files

logtoprocess: leverage procutil.shellenviron() to stringify variables (BC)

This should make the extension more Py3 friendly. The environment variables
of the main process are copied to the dict by shellenviron().

.. bc::

   Boolean options passed to the logtoprocess extension are now formatted
   as ``0`` or ``1`` instead of ``None``, ``False``, or ``True``.
parent ff8b2886c492
No related branches found
No related tags found
No related merge requests found
......@@ -73,7 +73,7 @@
# positional arguments are listed as MSG[N] keys in the
# environment
msgpairs = (
('MSG{0:d}'.format(i), str(m))
('MSG{0:d}'.format(i), m)
for i, m in enumerate(messages, 1))
# keyword arguments get prefixed with OPT_ and uppercased
optpairs = (
......@@ -77,5 +77,5 @@
for i, m in enumerate(messages, 1))
# keyword arguments get prefixed with OPT_ and uppercased
optpairs = (
('OPT_{0}'.format(key.upper()), str(value))
('OPT_{0}'.format(key.upper()), value)
for key, value in opts.iteritems())
......@@ -81,8 +81,8 @@
for key, value in opts.iteritems())
env = dict(itertools.chain(procutil.shellenviron().items(),
msgpairs, optpairs),
EVENT=event, HGPID=str(os.getpid()))
procutil.runbgcommand(script, env, shell=True)
env = dict(itertools.chain(msgpairs, optpairs),
EVENT=event, HGPID=os.getpid())
fullenv = procutil.shellenviron(env)
procutil.runbgcommand(script, fullenv, shell=True)
return super(logtoprocessui, self).log(event, *msg, **opts)
# Replace the class for this instance and all clones created from it:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment