Patchwork [3,of,7,STABLE] hgclient: pass shell=True to subprocess.Popen on Windows for hg.bat

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Jan. 21, 2015, 3:10 p.m.
Message ID <e176f1ffa9a37351e357.1421853050@juju>
Download mbox | patch
Permalink /patch/7525/
State Deferred
Headers show

Comments

Katsunori FUJIWARA - Jan. 21, 2015, 3:10 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1421852826 -32400
#      Thu Jan 22 00:07:06 2015 +0900
# Branch stable
# Node ID e176f1ffa9a37351e357ea5551595a008c391890
# Parent  5b976dff532a83b97b4b76a3b95898b3638d040f
hgclient: pass shell=True to subprocess.Popen on Windows for hg.bat

"CreateProcess", underlying API of "subprocess.Popen" on Windows,
doesn't execute "hg.bat" as "hg" command, if "shell=False" (default)
is passed to "subprocess.Popen", regardless of PATHEXT configuration.

API document of "subprocess.Popen" says that batch files can be
executed without "shell=True", but it seems to mean that they can be
so only if ".bat" extension isn't omitted in the command line.

This patch passes "shell=True" to "subprocess.Popen" on Windows
environment for "hg.bat" invocation.

On Windows environment, "shell=True" should be safe enough, because
command line elements other than the repository path (for "-R path")
are fixed.

Patch

diff --git a/contrib/hgclient.py b/contrib/hgclient.py
--- a/contrib/hgclient.py
+++ b/contrib/hgclient.py
@@ -8,7 +8,8 @@  def connectpipe(path=None):
         cmdline += ['-R', path]
 
     server = subprocess.Popen(cmdline, stdin=subprocess.PIPE,
-                              stdout=subprocess.PIPE)
+                              stdout=subprocess.PIPE,
+                              shell=os.name == 'nt')
 
     return server