D1426: logtoprocess: add the possibility to not start a shell
lothiraldan (Boris Feld)
phabricator at mercurial-scm.org
Wed Nov 15 15:44:22 UTC 2017
lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
REVISION SUMMARY
Starting a shell on Windows means starting a console GUI window in almost all
cases. If we add a logtoprocess for commandfinish and the prompt do some hg
calls, it will create a short-lived GUI window which is annoying for end-
users.
REPOSITORY
rHG Mercurial
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
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list