chgserver: use util.shellenviron
authorJun Wu <quark@fb.com>
Tue, 10 Jan 2017 06:58:51 +0800
changeset 30737 2957409449ac
parent 30736 d9e5b0aeeb90
child 30738 a45c0f42271f
chgserver: use util.shellenviron This avoids code duplication.
mercurial/chgserver.py
--- a/mercurial/chgserver.py	Tue Jan 10 06:58:02 2017 +0800
+++ b/mercurial/chgserver.py	Tue Jan 10 06:58:51 2017 +0800
@@ -231,19 +231,8 @@
                 or self.fout.fileno() != util.stdout.fileno()):
                 return super(chgui, self).system(cmd, environ, cwd, onerr,
                                                  errprefix)
-            # copied from mercurial/util.py:system()
             self.flush()
-            def py2shell(val):
-                if val is None or val is False:
-                    return '0'
-                if val is True:
-                    return '1'
-                return str(val)
-            env = encoding.environ.copy()
-            if environ:
-                env.update((k, py2shell(v)) for k, v in environ.iteritems())
-            env['HG'] = util.hgexecutable()
-            rc = self._csystem(cmd, env, cwd)
+            rc = self._csystem(cmd, util.shellenviron(environ), cwd)
             if rc and onerr:
                 errmsg = '%s %s' % (os.path.basename(cmd.split(None, 1)[0]),
                                     util.explainexit(rc)[0])