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

login
register
mail settings
Submitter phabricator
Date Dec. 15, 2017, 10:11 a.m.
Message ID <differential-rev-PHID-DREV-fknnhceglb7kvhmywtru-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26298/
State New
Headers show

Comments

phabricator - Dec. 15, 2017, 10:11 a.m.
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




To: lothiraldan, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 15, 2017, 2:01 p.m.
yuja added a comment.


  > but could have other side-effects so it kept under a config knob.
  
  My two cents, `experimental.*` might be better if the config knob exists as
  a workaround for an unknown bug.

INLINE COMMENTS

> logtoprocess.py:66
> +            if createconsole:
> +                creationflags = subprocess.CREATE_NEW_CONSOLE
> +            else:

Can we add `CREATE_NEW_PROCESS_GROUP` ?

REPOSITORY
  rHG Mercurial

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

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

Patch

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