# HG changeset patch # User Boris Feld <boris.f...@octobus.net> # Date 1499458959 -7200 # Fri Jul 07 22:22:39 2017 +0200 # Node ID 5d3e659c979aa428ba44b138cfac30b7cca28fb3 # Parent 5b49f653a4a50607127e37e7511c8a8e343cc8d9 # EXP-Topic obs-cache cache: introduce a dualsourcebase class
This abstract class cover the case where cache are computed from data contained in the changelog -and- the obsstore. diff -r 5b49f653a4a5 -r 5d3e659c979a mercurial/cache.py --- a/mercurial/cache.py Fri Jul 07 22:22:04 2017 +0200 +++ b/mercurial/cache.py Fri Jul 07 22:22:39 2017 +0200 @@ -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 _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel