obscache: makes dualsourcecache compatible with obshashrange cache needs
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 12 May 2017 20:28:09 +0200
changeset 2359 ff635fa59a25
parent 2358 d8ea60fcfbc9
child 2360 89938bebc6f9
obscache: makes dualsourcecache compatible with obshashrange cache needs The goal of the abstract method is to be reusable. So we make sure it is reusable.
hgext3rd/evolve/obscache.py
--- a/hgext3rd/evolve/obscache.py	Fri May 12 21:20:40 2017 +0200
+++ b/hgext3rd/evolve/obscache.py	Fri May 12 20:28:09 2017 +0200
@@ -141,6 +141,7 @@
     emptykey = (node.nullrev, node.nullid, 0, 0, node.nullid)
 
     def __init__(self):
+        super(dualsourcecache, self).__init__()
         self._cachekey = None
 
     def _updatefrom(self, repo, revs, obsmarkers):
@@ -160,6 +161,16 @@
         # /!\ IMPORTANT /!\
         # You must overide this method to actually
         self._cachekey = self.emptykey if reset else None
+        s = super(dualsourcecache, self)
+        if util.safehasattr(s, 'clear') and callable(s.clear):
+            s.clear()
+
+    def load(self, repo):
+        """Load data from disk
+
+        Do not forget to restore the "cachekey" attribute while doing so.
+        """
+        raise NotImplementedError
 
     # Useful public function (no need to override them)
 
@@ -180,6 +191,7 @@
         """update the cache with new repository data
 
         The update will be incremental when possible"""
+        repo = repo.unfiltered()
         # If we do not have any data, try loading from disk
         if self._cachekey is None:
             self.load(repo)