diff mercurial/revlog.py @ 43581: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
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri Nov 08 10:01:10 2019 +0100
+++ b/mercurial/revlog.py	Sat Nov 09 05:54:22 2019 +0100
@@ -217,6 +217,13 @@
         self.nodemap[tup[7]] = len(self)
         super(revlogoldindex, self).append(tup)
 
+    def __delitem__(self, i):
+        if not isinstance(i, slice) or not i.stop == -1 or i.step is not None:
+            raise ValueError(b"deleting slices only supports a:-1 with step 1")
+        for r in pycompat.xrange(i.start, len(self)):
+            del self.nodemap[self[r][7]]
+        super(revlogoldindex, self).__delitem__(i)
+
     def clearcaches(self):
         self.__dict__.pop('nodemap', None)
 
@@ -2431,8 +2438,6 @@
         self._revisioncache = None
         self._chaininfocache = {}
         self._chunkclear()
-        for x in pycompat.xrange(rev, len(self)):
-            del self.nodemap[self.node(x)]
 
         del self.index[rev:-1]
         self._nodepos = None