Mercurial > evolve
changeset 2352:dd8471e54708
obcache: move _checkkey on the class
We'll extract a smaller data agnostic class but we need to gather all method on
it first.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 12 May 2017 18:56:42 +0200 |
parents | 1bec5ee99674 |
children | 393cbaf0d294 |
files | hgext3rd/evolve/obscache.py |
diffstat | 1 files changed, 21 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obscache.py Fri May 12 18:52:59 2017 +0200 +++ b/hgext3rd/evolve/obscache.py Fri May 12 18:56:42 2017 +0200 @@ -88,24 +88,6 @@ emptykey = (node.nullrev, node.nullid, 0, 0, node.nullid) -def _checkkey(changelog, obsstore, key): - """internal function""" - if key is None: - return None - - ### Is the cache valid ? - keytiprev, keytipnode, keyobslength, keyobssize, keyobskey = key - # check for changelog strip - tiprev = len(changelog) - 1 - if (tiprev < keytiprev - or changelog.node(keytiprev) != keytipnode): - return None - # check for obsstore strip - obssize, obskey = obsstore.cachekey(index=keyobssize) - if obskey != keyobskey: - return None - return tiprev, obssize, obskey - # XXX copied as is from Mercurial 4.2 and added the "offset" parameters @util.nogc def _readmarkers(data, offset=None): @@ -197,10 +179,29 @@ self._cachekey = emptykey if reset else None self._data = bytearray() + def _checkkey(self, changelog, obsstore): + """internal function""" + key = self._cachekey + if key is None: + return None + + ### Is the cache valid ? + keytiprev, keytipnode, keyobslength, keyobssize, keyobskey = key + # check for changelog strip + tiprev = len(changelog) - 1 + if (tiprev < keytiprev + or changelog.node(keytiprev) != keytipnode): + return None + # check for obsstore strip + obssize, obskey = obsstore.cachekey(index=keyobssize) + if obskey != keyobskey: + return None + return tiprev, obssize, obskey + def uptodate(self, repo): if self._cachekey is None: self.load(repo) - status = _checkkey(repo.changelog, repo.obsstore, self._cachekey) + status = self._checkkey(repo.changelog, repo.obsstore) return (status is not None and status[0] == self._cachekey[0] # tiprev and status[1] == self._cachekey[3]) # obssize @@ -225,7 +226,7 @@ reset = False - status = _checkkey(cl, obsstore, key) + status = self._checkkey(cl, obsstore) if status is None: reset = True key = emptykey