Mercurial > hg
changeset 32264:a72caf0af38e
caches: call 'repo.updatecache()' in 'repo.destroyed()'
Regenerating the cache after a 'strip' or a 'rollback' is useful. So we call the
generic cache warming function as other caches than just branchmap will be
updated there in the future.
To do so, we have to make 'repo.updatecache()' able to take no arguments. In
such cases, we reload all caches.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 02 May 2017 19:05:58 +0200 |
parents | 604d65e2c0b2 |
children | ccef71de7d41 |
files | mercurial/localrepo.py |
diffstat | 1 files changed, 12 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/localrepo.py Tue May 02 21:39:43 2017 +0200 +++ b/mercurial/localrepo.py Tue May 02 19:05:58 2017 +0200 @@ -1232,14 +1232,20 @@ return 0 @unfilteredmethod - def updatecaches(self, tr): - """warm appropriate caches after a transaction closed""" - if tr.hookargs.get('source') == 'strip': + def updatecaches(self, tr=None): + """warm appropriate caches + + If this function is called after a transaction closed. The transaction + will be available in the 'tr' argument. This can be used to selectively + update caches relevant to the changes in that transaction. + """ + if tr is not None and tr.hookargs.get('source') == 'strip': # During strip, many caches are invalid but # later call to `destroyed` will refresh them. return - if tr.changes['revs']: + if tr is None or tr.changes['revs']: + # updating the unfiltered branchmap should refresh all the others, branchmap.updatecache(self.filtered('served')) def invalidatecaches(self): @@ -1830,10 +1836,8 @@ self._phasecache.filterunknown(self) self._phasecache.write() - # update the 'served' branch cache to help read only server process - # Thanks to branchcache collaboration this is done from the nearest - # filtered subset and it is expected to be fast. - branchmap.updatecache(self.filtered('served')) + # refresh all repository caches + self.updatecaches() # Ensure the persistent tag cache is updated. Doing it now # means that the tag cache only has to worry about destroyed