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

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Wed Jan 21 09:10:50 CST 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at 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.

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
 


More information about the Mercurial-devel mailing list