D1701: logtoprocess: add the possibility to not popup a console

lothiraldan (Boris Feld) phabricator at mercurial-scm.org
Fri Dec 15 10:11:05 UTC 2017


lothiraldan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Starting a subprocess on Windows with `DETACHED_PROCESS |
  CREATE_NEW_PROCESS_GROUP` as startup info 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.
  
  Creating a subprocess with `CREATE_CONSOLE` instead seems to no start a
  console window but could have other side-effects so it kept under a config
  knob.

REPOSITORY
  rHG Mercurial

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

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
@@ -569,6 +569,9 @@
 coreconfigitem('logtoprocess', 'uiblocked',
     default=None,
 )
+coreconfigitem('logtoprocess', 'windows-create-console',
+    default=False,
+)
 coreconfigitem('merge', 'checkunknown',
     default='abort',
 )
diff --git a/hgext/logtoprocess.py b/hgext/logtoprocess.py
--- a/hgext/logtoprocess.py
+++ b/hgext/logtoprocess.py
@@ -59,11 +59,19 @@
         _creationflags = DETACHED_PROCESS | subprocess.CREATE_NEW_PROCESS_GROUP
 
         def runshellcommand(script, env, ui):
+
+            createconsole = ui.configbool("logtoprocess", "windows-create-console")
+
+            if createconsole:
+                creationflags = subprocess.CREATE_NEW_CONSOLE
+            else:
+                creationflags = _creationflags
+
             # 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,
-                creationflags=_creationflags)
+                creationflags=creationflags)
     else:
         def runshellcommand(script, env, ui):
             # double-fork to completely detach from the parent process



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


More information about the Mercurial-devel mailing list