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.
--- 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