--- a/mercurial/debugcommands.py Thu Mar 14 10:24:51 2019 +0000
+++ b/mercurial/debugcommands.py Thu Mar 14 10:43:01 2019 +0000
@@ -1465,45 +1465,50 @@
], '')
def debugmanifestfulltextcache(ui, repo, add=None, **opts):
"""show, clear or amend the contents of the manifest fulltext cache"""
- with repo.lock():
+
+ def getcache():
r = repo.manifestlog.getstorage(b'')
try:
- cache = r._fulltextcache
+ return r._fulltextcache
except AttributeError:
- ui.warn(_(
- "Current revlog implementation doesn't appear to have a "
- 'manifest fulltext cache\n'))
- return
-
- if opts.get(r'clear'):
+ msg = _("Current revlog implementation doesn't appear to have a "
+ "manifest fulltext cache\n")
+ raise error.Abort(msg)
+
+ if opts.get(r'clear'):
+ with repo.lock():
+ cache = getcache()
cache.clear()
- if add:
+ if add:
+ with repo.lock():
try:
- manifest = repo.manifestlog[r.lookup(add)]
+ m = repo.manifestlog
+ manifest = m[m.getstorage(b'').lookup(add)]
except error.LookupError as e:
raise error.Abort(e, hint="Check your manifest node id")
manifest.read() # stores revisision in cache too
- if not len(cache):
- ui.write(_('cache empty\n'))
- else:
- ui.write(
- _('cache contains %d manifest entries, in order of most to '
- 'least recent:\n') % (len(cache),))
- totalsize = 0
- for nodeid in cache:
- # Use cache.get to not update the LRU order
- data = cache.get(nodeid)
- size = len(data)
- totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
- ui.write(_('id: %s, size %s\n') % (
- hex(nodeid), util.bytecount(size)))
- ondisk = cache._opener.stat('manifestfulltextcache').st_size
- ui.write(
- _('total cache data size %s, on-disk %s\n') % (
- util.bytecount(totalsize), util.bytecount(ondisk))
- )
+ cache = getcache()
+ if not len(cache):
+ ui.write(_('cache empty\n'))
+ else:
+ ui.write(
+ _('cache contains %d manifest entries, in order of most to '
+ 'least recent:\n') % (len(cache),))
+ totalsize = 0
+ for nodeid in cache:
+ # Use cache.get to not update the LRU order
+ data = cache.get(nodeid)
+ size = len(data)
+ totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
+ ui.write(_('id: %s, size %s\n') % (
+ hex(nodeid), util.bytecount(size)))
+ ondisk = cache._opener.stat('manifestfulltextcache').st_size
+ ui.write(
+ _('total cache data size %s, on-disk %s\n') % (
+ util.bytecount(totalsize), util.bytecount(ondisk))
+ )
@command('debugmergestate', [], '')
def debugmergestate(ui, repo, *args):