Patchwork [2,of,8] chgserver: use util.shellenviron

login
register
mail settings
Submitter Jun Wu
Date Jan. 9, 2017, 11:12 p.m.
Message ID <603c1d614690ab594f24.1484003542@x1c>
Download mbox | patch
Permalink /patch/18153/
State Accepted
Headers show

Comments

Jun Wu - Jan. 9, 2017, 11:12 p.m.
# HG changeset patch
# User Jun Wu <quark@fb.com>
# Date 1484002731 -28800
#      Tue Jan 10 06:58:51 2017 +0800
# Node ID 603c1d614690ab594f240f4daf198f34c1714f62
# Parent  25760899b0ad12660b6a9e8c7b928dd2c334ec80
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r 603c1d614690
chgserver: use util.shellenviron

This avoids code duplication.

Patch

diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py
--- a/mercurial/chgserver.py
+++ b/mercurial/chgserver.py
@@ -232,17 +232,6 @@  def _newchgui(srcui, csystem):
                 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]),