obscache: distinct 'clear' and 'reset'
We make a difference between basic invalidatiton (or lack of loading) and
'reset' (current cache data are invalid).
We can now ensure a non-None key when we start the update. This will allow us
to "update" the existing key instead of recomputing one from scratch. This is
more efficient and less racy.
--- a/hgext3rd/evolve/obscache.py Thu May 04 21:24:02 2017 +0200
+++ b/hgext3rd/evolve/obscache.py Tue May 09 19:02:04 2017 +0200
@@ -243,9 +243,9 @@
Make sure the cache has been updated to match the repository content before using it"""
return self._data[rev]
- def clear(self):
+ def clear(self, reset=False):
"""invalidate the cache content"""
- self._cachekey = None
+ self._cachekey = emptykey if reset else None
self._data = bytearray()
def uptodate(self, repo):
@@ -261,8 +261,8 @@
self.load(repo)
valid, startrev, startidx = upgradeneeded(repo, self._cachekey)
- if not valid:
- self.clear()
+ if not valid or self._cachekey is None:
+ self.clear(reset=True)
if startrev is None and startidx is None:
return