Mercurial > public > mercurial-scm > hg
comparison mercurial/revlog.py @ 43533:642433629e20
revlog: deal with nodemap deletion within the index
Since the nodemap data now live in the index, it should be the index
responsibility to ensure the data are up to date.
The C version of the index is already dealing with such deletion.
This work is part of a refactoring to unify the revlog index and the nodemap.
This unification prepare the use of a persistent nodemap.
Differential Revision: https://phab.mercurial-scm.org/D7321
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sat, 09 Nov 2019 05:54:22 +0100 |
parents | dcf9826c8d8c |
children | 0c659fc20207 |
comparison
equal
deleted
inserted
replaced
43532:53581e220ba3 | 43533:642433629e20 |
---|---|
214 return nodemap | 214 return nodemap |
215 | 215 |
216 def append(self, tup): | 216 def append(self, tup): |
217 self.nodemap[tup[7]] = len(self) | 217 self.nodemap[tup[7]] = len(self) |
218 super(revlogoldindex, self).append(tup) | 218 super(revlogoldindex, self).append(tup) |
219 | |
220 def __delitem__(self, i): | |
221 if not isinstance(i, slice) or not i.stop == -1 or i.step is not None: | |
222 raise ValueError(b"deleting slices only supports a:-1 with step 1") | |
223 for r in pycompat.xrange(i.start, len(self)): | |
224 del self.nodemap[self[r][7]] | |
225 super(revlogoldindex, self).__delitem__(i) | |
219 | 226 |
220 def clearcaches(self): | 227 def clearcaches(self): |
221 self.__dict__.pop('nodemap', None) | 228 self.__dict__.pop('nodemap', None) |
222 | 229 |
223 def __getitem__(self, i): | 230 def __getitem__(self, i): |
2429 | 2436 |
2430 # then reset internal state in memory to forget those revisions | 2437 # then reset internal state in memory to forget those revisions |
2431 self._revisioncache = None | 2438 self._revisioncache = None |
2432 self._chaininfocache = {} | 2439 self._chaininfocache = {} |
2433 self._chunkclear() | 2440 self._chunkclear() |
2434 for x in pycompat.xrange(rev, len(self)): | |
2435 del self.nodemap[self.node(x)] | |
2436 | 2441 |
2437 del self.index[rev:-1] | 2442 del self.index[rev:-1] |
2438 self._nodepos = None | 2443 self._nodepos = None |
2439 | 2444 |
2440 def checksize(self): | 2445 def checksize(self): |