stablerange: warm cache on transaction (if obshashrange is enabled)
If we plan to use it (obshashrange is enabled) we better keep it up to date. If
a transaction adds node, we update the cache (this should also update the on
disk version).
--- a/hgext3rd/evolve/stablerange.py Fri Mar 24 16:05:28 2017 +0100
+++ b/hgext3rd/evolve/stablerange.py Fri Mar 24 15:56:57 2017 +0100
@@ -11,6 +11,7 @@
import heapq
import math
import sqlite3
+import weakref
from mercurial import (
commands,
@@ -885,4 +886,21 @@
if 'stablerange' in vars(self):
del self.stablerange
+ def transaction(self, *args, **kwargs):
+ tr = super(stablerangerepo, self).transaction(*args, **kwargs)
+ if not repo.ui.configbool('experimental', 'obshashrange', False):
+ return tr
+ reporef = weakref.ref(self)
+
+ def _warmcache(tr):
+ repo = reporef()
+ if repo is None:
+ return
+ if 'node' in tr.hookargs:
+ # new nodes !
+ repo.stablerange.warmup(repo)
+
+ tr.addpostclose('warmcache-stablerange', _warmcache)
+ return tr
+
repo.__class__ = stablerangerepo