changeset 2333:adf114c767ab

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 09 May 2017 19:02:04 +0200
parents 77c184c80e3e
children b31ef65a846a
files hgext3rd/evolve/obscache.py
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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