Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 36952:b24cde12061b
debugupdatecache: also warm rev branch cache
We add basic code to have `debugupdatecache` ensure that the rev branch cache
is fully warmed. This only affects the `debugupdatecache` command, not normal
transaction operation.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 21 Feb 2018 17:21:10 +0100 |
parents | aff5996f3043 |
children | f0b6fbea00cf |
comparison
equal
deleted
inserted
replaced
36951:c92d1d3c58ee | 36952:b24cde12061b |
---|---|
1517 repo = reporef() | 1517 repo = reporef() |
1518 repo.updatecaches(tr) | 1518 repo.updatecaches(tr) |
1519 return updater | 1519 return updater |
1520 | 1520 |
1521 @unfilteredmethod | 1521 @unfilteredmethod |
1522 def updatecaches(self, tr=None): | 1522 def updatecaches(self, tr=None, full=False): |
1523 """warm appropriate caches | 1523 """warm appropriate caches |
1524 | 1524 |
1525 If this function is called after a transaction closed. The transaction | 1525 If this function is called after a transaction closed. The transaction |
1526 will be available in the 'tr' argument. This can be used to selectively | 1526 will be available in the 'tr' argument. This can be used to selectively |
1527 update caches relevant to the changes in that transaction. | 1527 update caches relevant to the changes in that transaction. |
1528 | |
1529 If 'full' is set, make sure all caches the function knows about have | |
1530 up-to-date data. Even the ones usually loaded more lazily. | |
1528 """ | 1531 """ |
1529 if tr is not None and tr.hookargs.get('source') == 'strip': | 1532 if tr is not None and tr.hookargs.get('source') == 'strip': |
1530 # During strip, many caches are invalid but | 1533 # During strip, many caches are invalid but |
1531 # later call to `destroyed` will refresh them. | 1534 # later call to `destroyed` will refresh them. |
1532 return | 1535 return |
1533 | 1536 |
1534 if tr is None or tr.changes['revs']: | 1537 if tr is None or tr.changes['revs']: |
1535 # updating the unfiltered branchmap should refresh all the others, | 1538 # updating the unfiltered branchmap should refresh all the others, |
1536 self.ui.debug('updating the branch cache\n') | 1539 self.ui.debug('updating the branch cache\n') |
1537 branchmap.updatecache(self.filtered('served')) | 1540 branchmap.updatecache(self.filtered('served')) |
1541 | |
1542 if full: | |
1543 rbc = self.revbranchcache() | |
1544 for r in self.changelog: | |
1545 rbc.branchinfo(r) | |
1546 rbc.write() | |
1538 | 1547 |
1539 def invalidatecaches(self): | 1548 def invalidatecaches(self): |
1540 | 1549 |
1541 if '_tagscache' in vars(self): | 1550 if '_tagscache' in vars(self): |
1542 # can't use delattr on proxy | 1551 # can't use delattr on proxy |