changeset 2393:2a194fe1a557

obsrangecache: raise programming error when using an unwarmed cache This will provide a better experience for developer using this the cache.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 17 May 2017 12:27:13 +0200
parents 6be71b8f3408
children 1b3a797c4586
files hgext3rd/evolve/obsdiscovery.py
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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: