changeset 2359:ff635fa59a25

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 12 May 2017 20:28:09 +0200
parents d8ea60fcfbc9
children 89938bebc6f9
files hgext3rd/evolve/obscache.py
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)