Patchwork procutil: add a shim for translating shell commands to native commands

login
register
mail settings
Submitter Matt Harbison
Date June 29, 2018, 2:37 a.m.
Message ID <72286f9e324f359d6090.1530239862@Envy>
Download mbox | patch
Permalink /patch/32499/
State Accepted
Headers show

Comments

Matt Harbison - June 29, 2018, 2:37 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1530238988 14400
#      Thu Jun 28 22:23:08 2018 -0400
# Node ID 72286f9e324f359d6090ae78883428adc97037cc
# Parent  5d88fd1bc2af0af02129f0ad2b267d778349d95a
procutil: add a shim for translating shell commands to native commands
Yuya Nishihara - June 29, 2018, 11:29 a.m.
On Thu, 28 Jun 2018 22:37:42 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1530238988 14400
> #      Thu Jun 28 22:23:08 2018 -0400
> # Node ID 72286f9e324f359d6090ae78883428adc97037cc
> # Parent  5d88fd1bc2af0af02129f0ad2b267d778349d95a
> procutil: add a shim for translating shell commands to native commands

Queued, thanks.

Patch

diff --git a/mercurial/hook.py b/mercurial/hook.py
--- a/mercurial/hook.py
+++ b/mercurial/hook.py
@@ -139,9 +139,7 @@  def _exthook(ui, repo, htype, name, cmd,
             v = stringutil.pprint(v)
         env['HG_' + k.upper()] = v
 
-    if pycompat.iswindows:
-        environ = procutil.shellenviron(env)
-        cmd = util.platform.shelltocmdexe(cmd, environ)
+    cmd = procutil.shelltonative(cmd, env)
 
     ui.note(_("running hook %s: %s\n") % (name, cmd))
 
diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -317,6 +317,13 @@  def shellenviron(environ=None):
     env['HG'] = hgexecutable()
     return env
 
+if pycompat.iswindows:
+    def shelltonative(cmd, env):
+        return platform.shelltocmdexe(cmd, shellenviron(env))
+else:
+    def shelltonative(cmd, env):
+        return cmd
+
 def system(cmd, environ=None, cwd=None, out=None):
     '''enhanced shell command execution.
     run with environment maybe modified, maybe in different dir.