##// 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 def debugmanifestfulltextcache(ui, repo, add=None, **opts):
1466 def debugmanifestfulltextcache(ui, repo, add=None, **opts):
1467 """show, clear or amend the contents of the manifest fulltext cache"""
1467 """show, clear or amend the contents of the manifest fulltext cache"""
1468 with repo.lock():
1468
1469 def getcache():
1469 r = repo.manifestlog.getstorage(b'')
1470 r = repo.manifestlog.getstorage(b'')
1470 try:
1471 try:
1471 cache = r._fulltextcache
1472 return r._fulltextcache
1472 except AttributeError:
1473 except AttributeError:
1473 ui.warn(_(
1474 msg = _("Current revlog implementation doesn't appear to have a "
1474 "Current revlog implementation doesn't appear to have a "
1475 "manifest fulltext cache\n")
1475 'manifest fulltext cache\n'))
1476 raise error.Abort(msg)
1476 return
1477
1477
1478 if opts.get(r'clear'):
1478 if opts.get(r'clear'):
1479 with repo.lock():
1480 cache = getcache()
1479 cache.clear()
1481 cache.clear()
1480
1482
1481 if add:
1483 if add:
1484 with repo.lock():
1482 try:
1485 try:
1483 manifest = repo.manifestlog[r.lookup(add)]
1486 m = repo.manifestlog
1487 manifest = m[m.getstorage(b'').lookup(add)]
1484 except error.LookupError as e:
1488 except error.LookupError as e:
1485 raise error.Abort(e, hint="Check your manifest node id")
1489 raise error.Abort(e, hint="Check your manifest node id")
1486 manifest.read() # stores revisision in cache too
1490 manifest.read() # stores revisision in cache too
1487
1491
1488 if not len(cache):
1492 cache = getcache()
1489 ui.write(_('cache empty\n'))
1493 if not len(cache):
1490 else:
1494 ui.write(_('cache empty\n'))
1491 ui.write(
1495 else:
1492 _('cache contains %d manifest entries, in order of most to '
1496 ui.write(
1493 'least recent:\n') % (len(cache),))
1497 _('cache contains %d manifest entries, in order of most to '
1494 totalsize = 0
1498 'least recent:\n') % (len(cache),))
1495 for nodeid in cache:
1499 totalsize = 0
1496 # Use cache.get to not update the LRU order
1500 for nodeid in cache:
1497 data = cache.get(nodeid)
1501 # Use cache.get to not update the LRU order
1498 size = len(data)
1502 data = cache.get(nodeid)
1499 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
1503 size = len(data)
1500 ui.write(_('id: %s, size %s\n') % (
1504 totalsize += size + 24 # 20 bytes nodeid, 4 bytes size
1501 hex(nodeid), util.bytecount(size)))
1505 ui.write(_('id: %s, size %s\n') % (
1502 ondisk = cache._opener.stat('manifestfulltextcache').st_size
1506 hex(nodeid), util.bytecount(size)))
1503 ui.write(
1507 ondisk = cache._opener.stat('manifestfulltextcache').st_size
1504 _('total cache data size %s, on-disk %s\n') % (
1508 ui.write(
1505 util.bytecount(totalsize), util.bytecount(ondisk))
1509 _('total cache data size %s, on-disk %s\n') % (
1506 )
1510 util.bytecount(totalsize), util.bytecount(ondisk))
1511 )
1507
1512
1508 @command('debugmergestate', [], '')
1513 @command('debugmergestate', [], '')
1509 def debugmergestate(ui, repo, *args):
1514 def debugmergestate(ui, repo, *args):
@@ -107,3 +107,15 b' Showing the content of the caches after '
107
107
108 $ hg debugmanifestfulltextcache
108 $ hg debugmanifestfulltextcache
109 cache empty
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