# HG changeset patch # User Pierre-Yves David # Date 1493829233 -7200 # Node ID 04a0eda7dea9706755ede2e8b788b4d2ec5707ba # Parent 3c7c4d92022fee0a7b2855d84d73cbc78c65d1b6 obscache: move assert earlier in the code If we are to crash, let us crash earlier. diff -r 3c7c4d92022f -r 04a0eda7dea9 hgext3rd/evolve/obscache.py --- a/hgext3rd/evolve/obscache.py Wed May 03 13:58:32 2017 +0200 +++ b/hgext3rd/evolve/obscache.py Wed May 03 18:33:53 2017 +0200 @@ -239,6 +239,17 @@ if startrev is None and startidx is None: return + # checks we never run 'update' without a lock + # + # There are a potential race condition otherwise, since the repo + # "might" have changed side the cache update above. However, this code + # will only be running in a lock so we ignore the issue for now. + # + # Lift this limitation, 'upgradeneeded' should return a bounded amount + # of changeset and markers to read with their associated cachekey. see + # 'upgradeneeded' for detail. + assert repo._currentlock(repo._lockref) is not None + # process the new changesets cl = repo.changelog if startrev is not None: @@ -290,14 +301,6 @@ if r is not None and (startrev is None or r < startrev): self._data[r] = 1 - assert repo._currentlock(repo._lockref) is not None - # XXX note that there are a potential race condition here, since the - # repo "might" have changed side the cache update above. However, this - # code will only be running in a lock so we ignore the issue for now. - # - # To work around this, 'upgradeneeded' should return a bounded amount - # of changeset and markers to read with their associated cachekey. see - # 'upgradeneeded' for detail. self._cachekey = getcachekey(repo) def save(self, repo):