Patchwork D5588: watchman: disable fsmonitor when running non-interactively

login
register
mail settings
Submitter phabricator
Date Jan. 24, 2019, 5:40 p.m.
Message ID <7d656463b8aea054562f0b088775f16a@localhost.localdomain>
Download mbox | patch
Permalink /patch/37985/
State Not Applicable
Headers show

Comments

phabricator - Jan. 24, 2019, 5:40 p.m.
lothiraldan updated this revision to Diff 13413.
Herald added a subscriber: mjpieters.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5588?vs=13224&id=13413

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

AFFECTED FILES
  hgext/fsmonitor/__init__.py

CHANGE DETAILS




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

Patch

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -161,6 +161,9 @@ 
 configitem('fsmonitor', 'blacklistusers',
     default=list,
 )
+configitem('fsmonitor', 'enable_on_non_interactive',
+    default=True,
+)
 configitem('hgwatchman', 'verbose',
     default=True,
 )
@@ -778,6 +781,24 @@ 
                       'extension and has been disabled.\n') % ext)
             return
 
+    enabled = None
+    if 'HGWATCHMAN_ENABLE' in encoding.environ:
+        enabled = encoding.environ['HGWATCHMAN_ENABLE'].lower()
+
+    if enabled == 'true' or enabled == '':
+        pass
+    elif enabled == 'false':
+        ui.debug('fsmonitor: disabled through HGWATCHMAN_ENABLE env variable')
+        return
+    else:
+        interactive = ui.interactive()
+        enable_on_non_interactive = ui.configbool(
+            'fsmonitor', 'enable_on_non_interactive'
+        )
+        if not interactive and not enable_on_non_interactive:
+            ui.debug('fsmonitor: disabled for non-interactive commands')
+            return
+
     if repo.local():
         # We don't work with subrepos either.
         #