Comments
Patch
@@ -181,3 +181,38 @@
def _fetchupdatedata(self, repo):
return repo.obsstore.getmarkerssince(self._cachekey)
+
+class dualsourcecache(obsstoresourcebase, changelogsourcebase):
+ """An abstract class for cache that needs both changelog and obsstore
+
+ The cache key used is a combinaison of the one used for the changelog and
+ the one used for the obsstore. See inherited class for details.
+ """
+
+ __metaclass__ = abc.ABCMeta
+
+ # default key used for an empty cache
+ emptykey = (changelogsourcebase.emptykey
+ + obsstoresourcebase.emptykey)
+ _cachekeyspec = (changelogsourcebase._cachekeyspec
+ + obsstoresourcebase._cachekeyspec)
+ _cachename = None # used for debug message
+
+ def _fetchupdatedata(self, repo):
+ clkey = self._cachekey[0:2]
+ obskey = self._cachekey[2:4]
+
+ reset, revs, newclkey = self._fetchchangelogdata(clkey, repo.changelog)
+ if reset:
+ obskey = obsstoresourcebase.emptykey
+ obsreturn = repo.obsstore.getmarkerssince(obskey)
+ obsreset, obsmarkers, newobskey = obsreturn
+ if obsreset:
+ reset = True
+ clkey = changelogsourcebase.emptykey
+ clreturn = self._fetchchangelogdata(clkey, repo.changelog)
+ __, revs, newclkey = clreturn
+
+ newkey = newclkey + newobskey
+ data = (revs, obsmarkers)
+ return reset, data, newkey