# HG changeset patch # User Pierre-Yves David # Date 1494616802 -7200 # Node ID 9b68e65fad4f13c1bd3a7e51d398746662a2d7f3 # Parent 2ceb122fcc33aedddde2b778b3980b2a2b794bd0 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. diff -r 2ceb122fcc33 -r 9b68e65fad4f hgext3rd/evolve/obsdiscovery.py --- 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