comparison mercurial/localrepo.py @ 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 2b6692df1bdf
comparison
equal deleted inserted replaced
32263:604d65e2c0b2 32264:a72caf0af38e
1230 # invalidated. 1230 # invalidated.
1231 self.destroyed() 1231 self.destroyed()
1232 return 0 1232 return 0
1233 1233
1234 @unfilteredmethod 1234 @unfilteredmethod
1235 def updatecaches(self, tr): 1235 def updatecaches(self, tr=None):
1236 """warm appropriate caches after a transaction closed""" 1236 """warm appropriate caches
1237 if tr.hookargs.get('source') == 'strip': 1237
1238 If this function is called after a transaction closed. The transaction
1239 will be available in the 'tr' argument. This can be used to selectively
1240 update caches relevant to the changes in that transaction.
1241 """
1242 if tr is not None and tr.hookargs.get('source') == 'strip':
1238 # During strip, many caches are invalid but 1243 # During strip, many caches are invalid but
1239 # later call to `destroyed` will refresh them. 1244 # later call to `destroyed` will refresh them.
1240 return 1245 return
1241 1246
1242 if tr.changes['revs']: 1247 if tr is None or tr.changes['revs']:
1248 # updating the unfiltered branchmap should refresh all the others,
1243 branchmap.updatecache(self.filtered('served')) 1249 branchmap.updatecache(self.filtered('served'))
1244 1250
1245 def invalidatecaches(self): 1251 def invalidatecaches(self):
1246 1252
1247 if '_tagscache' in vars(self): 1253 if '_tagscache' in vars(self):
1828 # causing it to reload next time it is accessed, or simply filter 1834 # causing it to reload next time it is accessed, or simply filter
1829 # the removed nodes now and write the updated cache. 1835 # the removed nodes now and write the updated cache.
1830 self._phasecache.filterunknown(self) 1836 self._phasecache.filterunknown(self)
1831 self._phasecache.write() 1837 self._phasecache.write()
1832 1838
1833 # update the 'served' branch cache to help read only server process 1839 # refresh all repository caches
1834 # Thanks to branchcache collaboration this is done from the nearest 1840 self.updatecaches()
1835 # filtered subset and it is expected to be fast.
1836 branchmap.updatecache(self.filtered('served'))
1837 1841
1838 # Ensure the persistent tag cache is updated. Doing it now 1842 # Ensure the persistent tag cache is updated. Doing it now
1839 # means that the tag cache only has to worry about destroyed 1843 # means that the tag cache only has to worry about destroyed
1840 # heads immediately after a strip/rollback. That in turn 1844 # heads immediately after a strip/rollback. That in turn
1841 # guarantees that "cachetip == currenttip" (comparing both rev 1845 # guarantees that "cachetip == currenttip" (comparing both rev