# HG changeset patch # User Pierre-Yves David # Date 1494349324 -7200 # Node ID adf114c767ab6dd0c58127f79ec354048d724931 # Parent 77c184c80e3ef27b10f590222034daa6f312ce83 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. diff -r 77c184c80e3e -r adf114c767ab hgext3rd/evolve/obscache.py --- 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