diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py index 40fb8c165d..f448c5f27f 100644 --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -451,15 +451,9 @@ def overridewalk(orig, self, match, subrepos, unknown, ignored, full=True): self._ui.log("fsmonitor_status", "", fsmonitor_status="normal") if "fsmonitor_details" in getattr(self._ui, "track", ()): filelist = [e["name"] for e in result["files"]] - limit = 20 - if len(filelist) <= limit: - self._ui.log("fsmonitor_details", "watchman returned %r" % (filelist,)) - else: - self._ui.log( - "fsmonitor_details", - "watchman returned %r and %s more entries" - % (filelist[:limit], len(filelist) - limit), - ) + self._ui.log( + "fsmonitor_details", "watchman returned %s" % _reprshort(filelist) + ) # for file paths which require normalization and we encounter a case # collision, we store our own foldmap @@ -1004,3 +998,11 @@ def debugrefreshwatchmanclock(ui, repo): ui.status(_("updating watchman clock from %r to %r\n") % (ds.getclock(), clock)) ds.setclock(clock) ds.write(tr) + + +def _reprshort(filelist, limit=20): + """Like repr(filelist). But truncate it if it is too long""" + if len(filelist) <= limit: + return repr(filelist) + else: + return "%r and %s more entries" % (filelist[:limit], len(filelist) - limit) diff --git a/hgext/fsmonitor/state.py b/hgext/fsmonitor/state.py index 7b70b7b3f8..963157d866 100644 --- a/hgext/fsmonitor/state.py +++ b/hgext/fsmonitor/state.py @@ -111,8 +111,11 @@ class state(object): file.close() if "fsmonitor_details" in getattr(self._ui, "track", ()): + from . import _reprshort + self._ui.log( - "fsmonitor_details", "clock, notefiles = %r, %r" % (clock, notefiles) + "fsmonitor_details", + "clock, notefiles = %r, %s" % (clock, _reprshort(notefiles)), ) return clock, ignorehash, notefiles @@ -132,9 +135,11 @@ class state(object): def set(self, clock, ignorehash, notefiles): if "fsmonitor_details" in getattr(self._ui, "track", ()): + from . import _reprshort + self._ui.log( "fsmonitor_details", - "set clock, notefiles = %r, %r" % (clock, notefiles), + "set clock, notefiles = %r, %s" % (clock, _reprshort(notefiles)), ) if self._usetreestate: diff --git a/tests/test-fsmonitor-blackbox.t b/tests/test-fsmonitor-blackbox.t index 4c8c08fce2..d95cb7aa20 100644 --- a/tests/test-fsmonitor-blackbox.t +++ b/tests/test-fsmonitor-blackbox.t @@ -38,3 +38,7 @@ $ grep returned .hg/blackbox.log *> watchman returned ['x'] (glob) *> watchman returned [*] and 5 more entries (glob) + $ grep 'set clock, notefiles' .hg/blackbox.log + *> set clock, notefiles = '*', [] (glob) + *> set clock, notefiles = '*', ['x'] (glob) + *> set clock, notefiles = '*', [*] and 6 more entries (glob)