obsstore: also guard agains changing object in '_checkkey'
authorPierre-Yves David <pierre-yves.david@octobus.net>
Thu, 11 May 2017 17:00:55 +0200
changeset 2347 24bf0e3d84e3
parent 2346 34c6382dbb82
child 2349 521a18a10a06
obsstore: also guard agains changing object in '_checkkey' The 'upgradeneeded' function needs to be able to pass the object it fetched once.
hgext3rd/evolve/obscache.py
--- a/hgext3rd/evolve/obscache.py	Thu May 11 16:58:43 2017 +0200
+++ b/hgext3rd/evolve/obscache.py	Thu May 11 17:00:55 2017 +0200
@@ -107,7 +107,7 @@
 
     reset = False
 
-    status = _checkkey(repo, key)
+    status = _checkkey(cl, obsstore, key)
     if status is None:
         reset = True
         key = emptykey
@@ -144,7 +144,7 @@
 
     return reset, revs, markers, (obssize, obskey)
 
-def _checkkey(repo, key):
+def _checkkey(changelog, obsstore, key):
     """internal function"""
     if key is None:
         return None
@@ -152,13 +152,12 @@
     ### Is the cache valid ?
     keytiprev, keytipnode, keyobslength, keyobssize, keyobskey = key
     # check for changelog strip
-    cl = repo.changelog
-    tiprev = len(cl) - 1
+    tiprev = len(changelog) - 1
     if (tiprev < keytiprev
-            or cl.node(keytiprev) != keytipnode):
+            or changelog.node(keytiprev) != keytipnode):
         return None
     # check for obsstore strip
-    obssize, obskey = repo.obsstore.cachekey(index=keyobssize)
+    obssize, obskey = obsstore.cachekey(index=keyobssize)
     if obskey != keyobskey:
         return None
     return tiprev, obssize, obskey
@@ -257,7 +256,7 @@
     def uptodate(self, repo):
         if self._cachekey is None:
             self.load(repo)
-        status = _checkkey(repo, self._cachekey)
+        status = _checkkey(repo.changelog, repo.obsstore, self._cachekey)
         return (status is not None
                 and status[0] == self._cachekey[0] # tiprev
                 and status[1] == self._cachekey[3]) # obssize