obcache: move empty on the class
We'll extract a smaller data agnostic class but we need to gather all method on
it first.
--- a/hgext3rd/evolve/obscache.py Fri May 12 18:56:42 2017 +0200
+++ b/hgext3rd/evolve/obscache.py Fri May 12 18:56:56 2017 +0200
@@ -86,8 +86,6 @@
return obsstore
-emptykey = (node.nullrev, node.nullid, 0, 0, node.nullid)
-
# XXX copied as is from Mercurial 4.2 and added the "offset" parameters
@util.nogc
def _readmarkers(data, offset=None):
@@ -151,6 +149,8 @@
_filepath = 'cache/evoext-obscache-00'
_headerformat = '>q20sQQ20s'
+ emptykey = (node.nullrev, node.nullid, 0, 0, node.nullid)
+
def __init__(self, repo):
self._vfs = repo.vfs
# cache key covering the changesets and obsmarkers content
@@ -176,7 +176,7 @@
def clear(self, reset=False):
"""invalidate the cache content"""
- self._cachekey = emptykey if reset else None
+ self._cachekey = self.emptykey if reset else None
self._data = bytearray()
def _checkkey(self, changelog, obsstore):
@@ -229,7 +229,7 @@
status = self._checkkey(cl, obsstore)
if status is None:
reset = True
- key = emptykey
+ key = self.emptykey
obssize, obskey = obsstore.cachekey()
tiprev = len(cl) - 1
else:
@@ -353,7 +353,7 @@
data = repo.vfs.tryread(self._filepath)
if not data:
- self._cachekey = emptykey
+ self._cachekey = self.emptykey
self._data = bytearray()
else:
headersize = struct.calcsize(self._headerformat)