##// END OF EJS Templates
manifestcache: only lock the repository if the debug command touch the cache...
marmoute -
r42108:fbee66c9 default
parent child Browse files
Show More
@@ -1465,45 +1465,50 b' def debuglocks(ui, repo, **opts):'
1465 1465 ], '')
1466 1466 def debugmanifestfulltextcache(ui, repo, add=None, **opts):
1467 1467 """show, clear or amend the contents of the manifest fulltext cache"""
1468 with repo.lock():
1468
1469 def getcache():
1469 1470 r = repo.manifestlog.getstorage(b'')
1470 1471 try:
1471 cache = r._fulltextcache
1472 return r._fulltextcache
1472 1473 except AttributeError:
1473 ui.warn(_(
1474 "Current revlog implementation doesn't appear to have a "
1475 'manifest fulltext cache\n'))
1476 return
1477
1478 if opts.get(r'clear'):
1474 msg = _("Current revlog implementation doesn't appear to have a "
1475 "manifest fulltext cache\n")
1476 raise error.Abort(msg)
1477
1478 if opts.get(r'clear'):
1479 with repo.lock():
1480 cache = getcache()
1479 1481 cache.clear()
1480 1482
1481 if add:
1483 if add:
1484 with repo.lock():
1482 1485 try:
1483 manifest = repo.manifestlog[r.lookup(add)]
1486 m = repo.manifestlog
1487 manifest = m[m.getstorage(b'').lookup(add)]
1484 1488 except error.LookupError as e:
1485 1489 raise error.Abort(e, hint="Check your manifest node id")
1486 1490 manifest.read() # stores revisision in cache too
1487 1491
1488 if not len(cache):
1489 ui.write(_('cache empty\n'))
1490 else:
1491 ui.write(
1492 _('cache contains %d manifest entries, in order of most to '
1493 'least recent:\n') % (len(cache),))
1494 totalsize = 0
1495 for nodeid in cache:
1496 # Use cache.get to not update the LRU order
1497 data = cache.get(nodeid)
1498 size = len(data)
1499 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
1500 ui.write(_('id: %s, size %s\n') % (
1501 hex(nodeid), util.bytecount(size)))
1502 ondisk = cache._opener.stat('manifestfulltextcache').st_size
1503 ui.write(
1504 _('total cache data size %s, on-disk %s\n') % (
1505 util.bytecount(totalsize), util.bytecount(ondisk))
1506 )
1492 cache = getcache()
1493 if not len(cache):
1494 ui.write(_('cache empty\n'))
1495 else:
1496 ui.write(
1497 _('cache contains %d manifest entries, in order of most to '
1498 'least recent:\n') % (len(cache),))
1499 totalsize = 0
1500 for nodeid in cache:
1501 # Use cache.get to not update the LRU order
1502 data = cache.get(nodeid)
1503 size = len(data)
1504 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
1505 ui.write(_('id: %s, size %s\n') % (
1506 hex(nodeid), util.bytecount(size)))
1507 ondisk = cache._opener.stat('manifestfulltextcache').st_size
1508 ui.write(
1509 _('total cache data size %s, on-disk %s\n') % (
1510 util.bytecount(totalsize), util.bytecount(ondisk))
1511 )
1507 1512
1508 1513 @command('debugmergestate', [], '')
1509 1514 def debugmergestate(ui, repo, *args):
@@ -107,3 +107,15 b' Showing the content of the caches after '
107 107
108 108 $ hg debugmanifestfulltextcache
109 109 cache empty
110
111 Adding a new persistent entry in the cache
112
113 $ hg debugmanifestfulltextcache --add 1e01206b1d2f72bd55f2a33fa8ccad74144825b7
114 cache contains 1 manifest entries, in order of most to least recent:
115 id: 1e01206b1d2f72bd55f2a33fa8ccad74144825b7, size 133 bytes
116 total cache data size 157 bytes, on-disk 157 bytes
117
118 $ hg debugmanifestfulltextcache
119 cache contains 1 manifest entries, in order of most to least recent:
120 id: 1e01206b1d2f72bd55f2a33fa8ccad74144825b7, size 133 bytes
121 total cache data size 157 bytes, on-disk 157 bytes
General Comments 0
You need to be logged in to leave comments. Login now