watchman: add verbose config knob
authorBoris Feld <boris.feld@octobus.net>
Fri, 21 Dec 2018 17:12:31 +0100
changeset 41488 18adb747a332
parent 41487 fa471151d269
child 41489 5125f0a9728b
watchman: add verbose config knob This new config knob allows to silent watchman log and warning messages when watchman is unavailable. Differential Revision: https://phab.mercurial-scm.org/D5586
hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py	Tue Jan 29 22:59:15 2019 -0800
+++ b/hgext/fsmonitor/__init__.py	Fri Dec 21 17:12:31 2018 +0100
@@ -161,6 +161,9 @@
 configitem('fsmonitor', 'blacklistusers',
     default=list,
 )
+configitem('hgwatchman', 'verbose',
+    default=True,
+)
 configitem('experimental', 'fsmonitor.transaction_notify',
     default=False,
 )
@@ -172,11 +175,14 @@
 def _handleunavailable(ui, state, ex):
     """Exception handler for Watchman interaction exceptions"""
     if isinstance(ex, watchmanclient.Unavailable):
-        if ex.warn:
+        # experimental config: hgwatchman.verbose
+        if ex.warn and ui.configbool('hgwatchman', 'verbose'):
             ui.warn(str(ex) + '\n')
         if ex.invalidate:
             state.invalidate()
-        ui.log('fsmonitor', 'Watchman unavailable: %s\n', ex.msg)
+        # experimental config: hgwatchman.verbose
+        if ui.configbool('hgwatchman','verbose'):
+            ui.log('fsmonitor', 'Watchman unavailable: %s\n', ex.msg)
     else:
         ui.log('fsmonitor', 'Watchman exception: %s\n', ex)