fsmonitor: use short list when logging notefiles

Summary:
The "fsmonitor returned" file list was made short by D9997658. Do the same
thing for notefiles.

Reviewed By: phillco

Differential Revision: D10865333

fbshipit-source-id: ff31cde04210363e6af04e5578543f1b16310b11
This commit is contained in:
Jun Wu 2018-10-29 20:24:55 -07:00 committed by Facebook Github Bot
parent df9235cb28
commit 13c490cf4e
3 changed files with 22 additions and 11 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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)