Patchwork [06,of,14] cache: add a obsstoresourcebase class

login
register
mail settings
Submitter Boris Feld
Date July 9, 2017, 5:55 p.m.
Message ID <5b49f653a4a50607127e.1499622918@FB>
Download mbox | patch
Permalink /patch/22169/
State Changes Requested
Headers show

Comments

Boris Feld - July 9, 2017, 5:55 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1499458924 -7200
#      Fri Jul 07 22:22:04 2017 +0200
# Node ID 5b49f653a4a50607127e37e7511c8a8e343cc8d9
# Parent  7c41d1484f53c53d516153d19a90c331c3f87c16
# EXP-Topic obs-cache
cache: add a obsstoresourcebase class

This class provides an abstract base for cache based on the obsstore. Having
this as a separared class is useful as it could be used for the obsindexes
cache that have been discussed in June this year.

Patch

diff -r 7c41d1484f53 -r 5b49f653a4a5 mercurial/cache.py
--- a/mercurial/cache.py	Sat Jun 17 06:39:43 2017 +0200
+++ b/mercurial/cache.py	Fri Jul 07 22:22:04 2017 +0200
@@ -164,3 +164,20 @@ 
 
     def _fetchupdatedata(self, repo):
         return self._fetchchangelogdata(self._cachekey, repo.changelog)
+
+class obsstoresourcebase(incrementalcachebase):
+    """an abstract class for cache that source data from the obsstore
+
+    For this purpose it use a cache key covering obsstore
+    content provided by the obsstore itself
+    """
+
+    __metaclass__ = abc.ABCMeta
+
+    # default key used for an empty cache
+    emptykey = (0, node.nullid)
+    _cachekeyspec = 'I20s'
+    _cachename = None # used for debug message
+
+    def _fetchupdatedata(self, repo):
+        return repo.obsstore.getmarkerssince(self._cachekey)