From patchwork Tue May 2 23:43:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4,of,8] caches: call 'repo.updatecache()' in 'repo.destroyed()' From: Pierre-Yves David X-Patchwork-Id: 20363 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Wed, 03 May 2017 01:43:41 +0200 # HG changeset patch # User Pierre-Yves David # Date 1493744758 -7200 # Tue May 02 19:05:58 2017 +0200 # Branch stable # Node ID a3dc2747c4e0eea11d6fce071d444e93bcde50c3 # Parent a98df6dbb264bd89889cd43f04bc6ddf6f9df142 # EXP-Topic obscache # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r a3dc2747c4e0 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. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1260,14 +1260,20 @@ class localrepository(object): 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): @@ -1858,10 +1864,8 @@ class localrepository(object): 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