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).
--- 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)