comparison mercurial/debugcommands.py @ 41958:1fe278aa4ad5

manifestcache: support multiple cache addition in one debug command run This is more practical.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 15 Mar 2019 13:52:56 +0000
parents b74ef67573e5
children e3307243d188
comparison
equal deleted inserted replaced
41957:131d0b7c3940 41958:1fe278aa4ad5
1458 1458
1459 return held 1459 return held
1460 1460
1461 @command('debugmanifestfulltextcache', [ 1461 @command('debugmanifestfulltextcache', [
1462 ('', 'clear', False, _('clear the cache')), 1462 ('', 'clear', False, _('clear the cache')),
1463 ('a', 'add', '', _('add the given manifest node to the cache'), 1463 ('a', 'add', [], _('add the given manifest nodes to the cache'),
1464 _('NODE')) 1464 _('NODE'))
1465 ], '') 1465 ], '')
1466 def debugmanifestfulltextcache(ui, repo, add=None, **opts): 1466 def debugmanifestfulltextcache(ui, repo, add=(), **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 1468
1469 def getcache(): 1469 def getcache():
1470 r = repo.manifestlog.getstorage(b'') 1470 r = repo.manifestlog.getstorage(b'')
1471 try: 1471 try:
1481 cache.clear(clear_persisted_data=True) 1481 cache.clear(clear_persisted_data=True)
1482 return 1482 return
1483 1483
1484 if add: 1484 if add:
1485 with repo.lock(): 1485 with repo.lock():
1486 try: 1486 m = repo.manifestlog
1487 m = repo.manifestlog 1487 store = m.getstorage(b'')
1488 manifest = m[m.getstorage(b'').lookup(add)] 1488 for n in add:
1489 except error.LookupError as e: 1489 try:
1490 raise error.Abort(e, hint="Check your manifest node id") 1490 manifest = m[store.lookup(n)]
1491 manifest.read() # stores revisision in cache too 1491 except error.LookupError as e:
1492 raise error.Abort(e, hint="Check your manifest node id")
1493 manifest.read() # stores revisision in cache too
1492 return 1494 return
1493 1495
1494 cache = getcache() 1496 cache = getcache()
1495 if not len(cache): 1497 if not len(cache):
1496 ui.write(_('cache empty\n')) 1498 ui.write(_('cache empty\n'))