# HG changeset patch # User Pierre-Yves David # Date 1494349992 -7200 # Node ID b31ef65a846a0a8cb4efac61b65366935c34d525 # Parent adf114c767ab6dd0c58127f79ec354048d724931 obscache: update the cache key in place Instead of computing the key in place, we update the existing one using the data used for the incremental update of the content. This will help reaching purely incremental cache eventually. The 'getcachekey' function is dropped as it is no longer used. diff -r adf114c767ab -r b31ef65a846a hgext3rd/evolve/obscache.py --- a/hgext3rd/evolve/obscache.py Tue May 09 19:02:04 2017 +0200 +++ b/hgext3rd/evolve/obscache.py Tue May 09 19:13:12 2017 +0200 @@ -88,29 +88,6 @@ emptykey = (node.nullrev, node.nullid, 0, 0, node.nullid) -def getcachekey(repo): - """get a cache key covering the changesets and obsmarkers content - - IT contains the following data. Combined with 'upgradeneeded' it allows to - do iterative upgrade for cache depending of theses two data. - - The cache key parts are" - - tip-rev, - - tip-node, - - obsstore-length (nb markers), - - obsstore-file-size (in bytes), - - obsstore "cache key" - """ - assert repo.filtername is None - cl = repo.changelog - index, key = repo.obsstore.cachekey() - tiprev = len(cl) - 1 - return (tiprev, - cl.node(tiprev), - len(repo.obsstore), - index, - key) - def upgradeneeded(repo, key): """return (valid, start-rev, start-obs-idx) @@ -227,6 +204,11 @@ def __init__(self, repo): self._vfs = repo.vfs + # cache key covering the changesets and obsmarkers content + # + # It contains the following data. Combined with 'upgradeneeded' it allows to + # do iterative upgrade for cache depending of theses two pieces of data. + # # The cache key parts are" # - tip-rev, # - tip-node, @@ -292,7 +274,16 @@ markers = markersfrom(repo.obsstore, self._cachekey[3], startidx) self._updatemarkers(repo, markers) - self._cachekey = getcachekey(repo) + # update the key from the new data + key = list(self._cachekey) + if startrev is not None: + key[0] = len(cl) - 1 + key[1] = cl.node(key[0]) + if startidx is not None: + key[2] += len(markers) + # XXX still a small race here if repo is not locked + key[3], key[4] = repo.obsstore.cachekey() + self._cachekey = tuple(key) def _updaterevs(self, repo, revs): """update the cache with new revisions