[PATCH default] fsmonitor: prevent command window pop-up when used with gui application

Olivier Trempe oliviertrempe at gmail.com
Fri Jul 15 13:42:04 EDT 2016


# HG changeset patch
# User Olivier Trempe <otrempe>
# Date 1468247986 14400
#      Mon Jul 11 10:39:46 2016 -0400
# Node ID 0d3510a5c2fa6eec7ade62f73adf7d976a30edec
# Parent  9d02bed8477bec7f679d6aeb5b1dd8bcdb80f64d
fsmonitor: prevent command window pop-up when used with gui application

diff -r 9d02bed8477b -r 0d3510a5c2fa hgext/fsmonitor/pywatchman/__init__.py
--- a/hgext/fsmonitor/pywatchman/__init__.py	Tue Jul 12 22:26:04 2016 -0700
+++ b/hgext/fsmonitor/pywatchman/__init__.py	Mon Jul 11 10:39:46 2016 -0400
@@ -600,10 +600,18 @@
 
         cmd = ['watchman', '--output-encoding=bser', 'get-sockname']
         try:
+
+            # if invoked via an application with a graphical user interface,
+            # this call will cause a brief command window pop-up.
+            # Using the flag STARTF_USESHOWWINDOW to avoid this behavior.
+            startupinfo = subprocess.STARTUPINFO()
+            startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+
             p = subprocess.Popen(cmd,
                                  stdout=subprocess.PIPE,
                                  stderr=subprocess.PIPE,
-                                 close_fds=os.name != 'nt')
+                                 close_fds=os.name != 'nt',
+                                 startupinfo=startupinfo)
         except OSError as e:
             raise WatchmanError('"watchman" executable not in PATH (%s)', e)
 


More information about the Mercurial-devel mailing list