obsrangecache: raise programming error when using an unwarmed cache
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 17 May 2017 12:27:13 +0200
changeset 2393 2a194fe1a557
parent 2392 6be71b8f3408
child 2394 1b3a797c4586
obsrangecache: raise programming error when using an unwarmed cache This will provide a better experience for developer using this the cache.
hgext3rd/evolve/obsdiscovery.py
--- a/hgext3rd/evolve/obsdiscovery.py	Wed May 17 13:27:29 2017 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Wed May 17 12:27:13 2017 +0200
@@ -441,12 +441,14 @@
             del self._con
 
     def get(self, rangeid):
-        # revision should be covered by out tiprev
-        # XXX should be a programming error
+        # revision should be covered by the tiprev
         #
         # XXX there are issue with cache warming, we hack around it for now
         if not getattr(self, '_updating', False):
-            assert rangeid[0] <= self._cachekey[0]
+            if self._cachekey[0] < rangeid[0]:
+                msg = ('using unwarmed obshashrangecache (%s %s)'
+                       % (rangeid[0], self._cachekey[0]))
+                raise error.ProgrammingError(msg)
 
         value = self._data.get(rangeid)
         if value is None and self._con is not None: