[PATCH] fsmonitor: issue debug messages when we fall back to core status

Boris Feld boris.feld at octobus.net
Tue Nov 28 20:30:18 UTC 2017


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1511884854 18000
#      Tue Nov 28 11:00:54 2017 -0500
# Node ID 1c6858cefe1701c27b459c6b5647b7b023f229b5
# Parent  8287df8b7be545fdafa22b771012ac65f6264d12
# EXP-Topic fsmonitor-debug
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 1c6858cefe17
fsmonitor: issue debug messages when we fall back to core status

Having more information about when and why fsmonitor bails out help when
looking into status performance.

diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py
+++ b/hgext/fsmonitor/__init__.py
@@ -224,16 +224,21 @@ def overridewalk(orig, self, match, subr
     Whenever full is False, ignored is False, and the Watchman client is
     available, use Watchman combined with saved state to possibly return only a
     subset of files.'''
-    def bail():
+    def bail(reason):
+        self._ui.debug('fsmonitor: fallback to core status, %s\n' % reason)
         return orig(match, subrepos, unknown, ignored, full=True)
 
-    if full or ignored or not self._watchmanclient.available():
-        return bail()
+    if full:
+        return bail('full rewalk requested')
+    if ignored:
+        return bail('listing ignored files')
+    if not self._watchmanclient.available():
+        return bail('client unavailable')
     state = self._fsmonitorstate
     clock, ignorehash, notefiles = state.get()
     if not clock:
         if state.walk_on_invalidate:
-            return bail()
+            return bail('no clock')
         # Initial NULL clock value, see
         # https://facebook.github.io/watchman/docs/clockspec.html
         clock = 'c:0:0'
@@ -263,7 +268,7 @@ def overridewalk(orig, self, match, subr
         if _hashignore(ignore) != ignorehash and clock != 'c:0:0':
             # ignore list changed -- can't rely on Watchman state any more
             if state.walk_on_invalidate:
-                return bail()
+                return bail('ignore rules changed')
             notefiles = []
             clock = 'c:0:0'
     else:
@@ -338,7 +343,7 @@ def overridewalk(orig, self, match, subr
     except Exception as ex:
         _handleunavailable(self._ui, state, ex)
         self._watchmanclient.clearconnection()
-        return bail()
+        return bail('exception during run')
     else:
         # We need to propagate the last observed clock up so that we
         # can use it for our next query
@@ -346,7 +351,7 @@ def overridewalk(orig, self, match, subr
         if result['is_fresh_instance']:
             if state.walk_on_invalidate:
                 state.invalidate()
-                return bail()
+                return bail('fresh instance')
             fresh_instance = True
             # Ignore any prior noteable files from the state info
             notefiles = []


More information about the Mercurial-devel mailing list