mercurial/debugcommands.py
changeset 38781 0a57945aaf7f
parent 38707 6b5ca1d0aa1e
child 38783 e7aa113b14f7
equal deleted inserted replaced
38780:ddb15a83ae0b 38781:0a57945aaf7f
  1444     held += report(repo.svfs, "lock", repo.lock)
  1444     held += report(repo.svfs, "lock", repo.lock)
  1445     held += report(repo.vfs, "wlock", repo.wlock)
  1445     held += report(repo.vfs, "wlock", repo.wlock)
  1446 
  1446 
  1447     return held
  1447     return held
  1448 
  1448 
       
  1449 @command('debugmanifestfulltextcache', [
       
  1450         ('', 'clear', False, _('clear the cache')),
       
  1451         ('a', 'add', '', _('add the given manifest node to the cache'),
       
  1452          _('NODE'))
       
  1453     ], '')
       
  1454 def debugmanifestfulltextcache(ui, repo, add=None, **opts):
       
  1455     """show, clear or amend the contents of the manifest fulltext cache"""
       
  1456     with repo.lock():
       
  1457         r = repo.manifestlog._revlog
       
  1458         try:
       
  1459             cache = r._fulltextcache
       
  1460         except AttributeError:
       
  1461             ui.warn(_(
       
  1462                 "Current revlog implementation doesn't appear to have a "
       
  1463                 'manifest fulltext cache\n'))
       
  1464             return
       
  1465 
       
  1466         if opts.get(r'clear'):
       
  1467             cache.clear()
       
  1468 
       
  1469         if add:
       
  1470             try:
       
  1471                 manifest = repo.manifestlog[r.lookup(add)]
       
  1472             except error.LookupError as e:
       
  1473                 raise error.Abort(e, hint="Check your manifest node id")
       
  1474             manifest.read()  # stores revisision in cache too
       
  1475 
       
  1476         if not len(cache):
       
  1477             ui.write(_('Cache empty'))
       
  1478         else:
       
  1479             ui.write(
       
  1480                 _('Cache contains %d manifest entries, in order of most to '
       
  1481                   'least recent:\n') % (len(cache),))
       
  1482             totalsize = 0
       
  1483             for nodeid in cache:
       
  1484                 # Use cache.get to not update the LRU order
       
  1485                 data = cache.get(nodeid)
       
  1486                 size = len(data)
       
  1487                 totalsize += size + 24   # 20 bytes nodeid, 4 bytes size
       
  1488                 ui.write(_('id: %s, size %s\n') % (
       
  1489                     hex(nodeid), util.bytecount(size)))
       
  1490             ondisk = cache._opener.stat('manifestfulltextcache').st_size
       
  1491             ui.write(
       
  1492                 _('Total cache data size %s, on-disk %s\n') % (
       
  1493                     util.bytecount(totalsize), util.bytecount(ondisk))
       
  1494             )
       
  1495 
  1449 @command('debugmergestate', [], '')
  1496 @command('debugmergestate', [], '')
  1450 def debugmergestate(ui, repo, *args):
  1497 def debugmergestate(ui, repo, *args):
  1451     """print merge state
  1498     """print merge state
  1452 
  1499 
  1453     Use --verbose to print out information about whether v1 or v2 merge state
  1500     Use --verbose to print out information about whether v1 or v2 merge state