diff mercurial/testing/revlog.py @ 51260:7eea2e4109ae

rust-index: using the `hg::index::Index` in ancestors iterator and lazy set Since there is no Rust implementation for REVLOGV2/CHANGELOGv2, we declare them to be incompatible with Rust, hence indexes in these formats will use the implementations from Python `mercurial.ancestor`. If this is an unacceptable performance hit for current users of these formats, we can later on add Rust implementations based on the C index for them or implement these formats for the Rust indexes. Among the challenges that we had to meet, we wanted to avoid taking the GIL each time the inner (vcsgraph) iterator has to call the parents function. This would probably still be acceptable in terms of performance with `AncestorsIterator`, but not with `LazyAncestors` nor for the upcoming change in `MissingAncestors`. Hence we enclose the reference to the index in a `PySharedRef`, leading to more rigourous checking of mutations, which does pass now that there no logically immutable methods of `hg::index::Index` that take a mutable reference as input.
author Georges Racinet <georges.racinet@octobus.net>
date Fri, 27 Oct 2023 22:11:05 +0200
parents 6000f5b25c9b
children 03fdd4d7b5bd
line wrap: on
line diff
--- a/mercurial/testing/revlog.py	Fri Oct 27 23:29:29 2023 +0200
+++ b/mercurial/testing/revlog.py	Fri Oct 27 22:11:05 2023 +0200
@@ -21,17 +21,32 @@
     b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 )
 
+from ..revlogutils.constants import REVLOGV1
+
 
 try:
     from ..cext import parsers as cparsers  # pytype: disable=import-error
 except ImportError:
     cparsers = None
 
+try:
+    from ..rustext.revlog import MixedIndex  # pytype: disable=import-error
+except ImportError:
+    MixedIndex = None
+
 
 @unittest.skipIf(
     cparsers is None,
     'The C version of the "parsers" module is not available. It is needed for this test.',
 )
 class RevlogBasedTestBase(unittest.TestCase):
-    def parseindex(self):
-        return cparsers.parse_index2(data_non_inlined, False)[0]
+    def parseindex(self, data=None):
+        if data is None:
+            data = data_non_inlined
+        return cparsers.parse_index2(data, False)[0]
+
+    def parserustindex(self, data=None):
+        if data is None:
+            data = data_non_inlined
+        cindex = self.parseindex(data=data)
+        return MixedIndex(cindex, data, REVLOGV1)