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

logtoprocess: rewrite dict building in py3-compatible way

parent fbac323eb625
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,5 @@
from __future__ import absolute_import
import itertools
import os
......@@ -38,5 +37,8 @@
import os
from mercurial import (
pycompat,
)
from mercurial.utils import (
procutil,
)
......@@ -70,5 +72,9 @@
messages = (formatted,) + msg[1:]
else:
messages = msg
env = {
b'EVENT': event,
b'HGPID': os.getpid(),
}
# positional arguments are listed as MSG[N] keys in the
# environment
......@@ -73,6 +79,4 @@
# positional arguments are listed as MSG[N] keys in the
# environment
msgpairs = (
('MSG{0:d}'.format(i), m)
for i, m in enumerate(messages, 1))
env.update((b'MSG%d' % i, m) for i, m in enumerate(messages, 1))
# keyword arguments get prefixed with OPT_ and uppercased
......@@ -78,9 +82,6 @@
# keyword arguments get prefixed with OPT_ and uppercased
optpairs = (
('OPT_{0}'.format(key.upper()), value)
for key, value in opts.iteritems())
env = dict(itertools.chain(msgpairs, optpairs),
EVENT=event, HGPID=os.getpid())
env.update((b'OPT_%s' % key.upper(), value)
for key, value in pycompat.byteskwargs(opts).items())
fullenv = procutil.shellenviron(env)
procutil.runbgcommand(script, fullenv, shell=True)
return super(logtoprocessui, self).log(event, *msg, **opts)
......
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