Mercurial > evolve
changeset 2346:34c6382dbb82
obscache: guard from changing changelog or obsstore object
We access these object once to make sure they will never change through the
function (and their content will be fixed).
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 11 May 2017 16:58:43 +0200 |
parents | 406c1a57b4ee |
children | 24bf0e3d84e3 |
files | hgext3rd/evolve/obscache.py |
diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/evolve/obscache.py Thu May 11 16:45:13 2017 +0200 +++ b/hgext3rd/evolve/obscache.py Thu May 11 16:58:43 2017 +0200 @@ -99,7 +99,11 @@ up to date. """ - # XXX we need to ensure we use the same changelog and obsstore through the processing + # We need to ensure we use the same changelog and obsstore through the + # processing. Otherwise some invalidation could update the object and their + # content after we computed the cache key. + cl = repo.changelog + obsstore = repo.obsstore reset = False @@ -107,8 +111,8 @@ if status is None: reset = True key = emptykey - obssize, obskey = repo.obsstore.cachekey() - tiprev = len(repo.changelog) - 1 + obssize, obskey = obsstore.cachekey() + tiprev = len(cl) - 1 else: tiprev, obssize, obskey = status @@ -122,7 +126,7 @@ # any new changesets ? revs = () if keytiprev < tiprev: - revs = list(repo.changelog.revs(start=keytiprev + 1, stop=tiprev)) + revs = list(cl.revs(start=keytiprev + 1, stop=tiprev)) # any new markers markers = () @@ -136,7 +140,7 @@ # In pratice the cache is only updated after each transaction within a # lock. So we should be fine. We could enforce this with a new repository # requirement (or fix the race, that is not too hard). - markers = markersfrom(repo.obsstore, keyobssize, keyobslength) + markers = markersfrom(obsstore, keyobssize, keyobslength) return reset, revs, markers, (obssize, obskey)