D1426: logtoprocess: add the possibility to not start a shell

lothiraldan (Boris Feld) phabricator at mercurial-scm.org
Tue Nov 28 15:36:41 EST 2017


lothiraldan updated this revision to Diff 3914.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1426?vs=3528&id=3914

REVISION DETAIL
  https://phab.mercurial-scm.org/D1426

AFFECTED FILES
  hgext/logtoprocess.py
  mercurial/configitems.py

CHANGE DETAILS

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -566,6 +566,9 @@
 coreconfigitem('logtoprocess', 'develwarn',
     default=None,
 )
+coreconfigitem('logtoprocess', 'shell',
+    default=True,
+)
 coreconfigitem('logtoprocess', 'uiblocked',
     default=None,
 )
diff --git a/hgext/logtoprocess.py b/hgext/logtoprocess.py
--- a/hgext/logtoprocess.py
+++ b/hgext/logtoprocess.py
@@ -58,14 +58,14 @@
         DETACHED_PROCESS = 0x00000008
         _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
 
-        def runshellcommand(script, env):
+        def runshellcommand(script, env, shell=True):
             # we can't use close_fds *and* redirect stdin. I'm not sure that we
             # need to because the detached process has no console connection.
             subprocess.Popen(
-                script, shell=True, env=env, close_fds=True,
+                script, shell=shell, env=env, close_fds=True,
                 creationflags=_creationflags)
     else:
-        def runshellcommand(script, env):
+        def runshellcommand(script, env, shell=True):
             # double-fork to completely detach from the parent process
             # based on http://code.activestate.com/recipes/278731
             pid = os.fork()
@@ -82,7 +82,7 @@
                 # connect stdin to devnull to make sure the subprocess can't
                 # muck up that stream for mercurial.
                 subprocess.Popen(
-                    script, shell=True, stdin=open(os.devnull, 'r'), env=env,
+                    script, shell=shell, stdin=open(os.devnull, 'r'), env=env,
                     close_fds=True, **newsession)
             finally:
                 # mission accomplished, this child needs to exit and not
@@ -124,7 +124,8 @@
                 env = dict(itertools.chain(encoding.environ.items(),
                                            msgpairs, optpairs),
                            EVENT=event, HGPID=str(os.getpid()))
-                runshellcommand(script, env)
+                shell = self.configbool('logtoprocess', 'shell')
+                runshellcommand(script, env, shell)
             return super(logtoprocessui, self).log(event, *msg, **opts)
 
     # Replace the class for this instance and all clones created from it:



To: lothiraldan, #hg-reviewers, mbthomas
Cc: yuja, mbthomas, mercurial-devel


More information about the Mercurial-devel mailing list