Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/revlog.py @ 37494:1ce7a55b09d1
revlog: reset _nodepos after strip
When using the pure revlog parser, _nodepos is used to keep track of the
position during index scanning in the non-cached cache. If it is out of
bounds, BaseIndexObject._fix_index will assert. Since strip can actually
remove the position scanned last, make sure to reset it. Add an
assertion in the place where the invariance is clearer.
Differential Revision: https://phab.mercurial-scm.org/D3188
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Sun, 08 Apr 2018 01:08:43 +0200 |
parents | a0d71618074f |
children | 44d1959acb3b |
comparison
equal
deleted
inserted
replaced
37493:f1413e4a54a6 | 37494:1ce7a55b09d1 |
---|---|
816 n = self._nodecache | 816 n = self._nodecache |
817 i = self.index | 817 i = self.index |
818 p = self._nodepos | 818 p = self._nodepos |
819 if p is None: | 819 if p is None: |
820 p = len(i) - 2 | 820 p = len(i) - 2 |
821 else: | |
822 assert p < len(i) | |
821 for r in xrange(p, -1, -1): | 823 for r in xrange(p, -1, -1): |
822 v = i[r][7] | 824 v = i[r][7] |
823 n[v] = r | 825 n[v] = r |
824 if v == node: | 826 if v == node: |
825 self._nodepos = r - 1 | 827 self._nodepos = r - 1 |
2419 self._chunkclear() | 2421 self._chunkclear() |
2420 for x in xrange(rev, len(self)): | 2422 for x in xrange(rev, len(self)): |
2421 del self.nodemap[self.node(x)] | 2423 del self.nodemap[self.node(x)] |
2422 | 2424 |
2423 del self.index[rev:-1] | 2425 del self.index[rev:-1] |
2426 self._nodepos = None | |
2424 | 2427 |
2425 def checksize(self): | 2428 def checksize(self): |
2426 expected = 0 | 2429 expected = 0 |
2427 if len(self): | 2430 if len(self): |
2428 expected = max(0, self.end(len(self) - 1)) | 2431 expected = max(0, self.end(len(self) - 1)) |