Mercurial > evolve
changeset 2364:9b68e65fad4f
obshashrange: "update" the cache on each transaction close
Right now the "update" does not really file the cache, but it will detect
invalid situation and clean them.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 12 May 2017 21:20:02 +0200 |
parents | 2ceb122fcc33 |
children | 4b8b7fd135eb |
files | hgext3rd/evolve/obsdiscovery.py |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obsdiscovery.py Fri May 12 20:52:19 2017 +0200 +++ b/hgext3rd/evolve/obsdiscovery.py Fri May 12 21:20:02 2017 +0200 @@ -596,6 +596,27 @@ self.obsstore.rangeobshashcache.clear() super(obshashrepo, self).destroyed() + def transaction(self, *args, **kwargs): + tr = super(obshashrepo, self).transaction(*args, **kwargs) + reporef = weakref.ref(self) + + def _warmcache(tr): + repo = reporef() + if repo is None: + return + if not repo.ui.configbool('experimental', 'obshashrange', False): + return + repo = repo.unfiltered() + # As pointed in 'obscache.update', we could have the changelog + # and the obsstore in charge of updating the cache when new + # items goes it. The tranaction logic would then only be + # involved for the 'pending' and final writing on disk. + self.obsstore.rangeobshashcache.update(repo) + self.obsstore.rangeobshashcache.save(repo) + + tr.addpostclose('warmcache-obscacherange', _warmcache) + return tr + repo.__class__ = obshashrepo ### wire protocol commands