comparison 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
comparison
equal deleted inserted replaced
51259:633408a0f2e2 51260:7eea2e4109ae
19 b'\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1' 19 b'\x00\x00\x00\x03\x00\x00\x00\x02\xff\xff\xff\xff\x12\xcb\xeby1'
20 b'\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00' 20 b'\xb6\r\x98B\xcb\x07\xbd`\x8f\x92\xd9\xc4\x84\xbdK\x00\x00\x00'
21 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00' 21 b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
22 ) 22 )
23 23
24 from ..revlogutils.constants import REVLOGV1
25
24 26
25 try: 27 try:
26 from ..cext import parsers as cparsers # pytype: disable=import-error 28 from ..cext import parsers as cparsers # pytype: disable=import-error
27 except ImportError: 29 except ImportError:
28 cparsers = None 30 cparsers = None
31
32 try:
33 from ..rustext.revlog import MixedIndex # pytype: disable=import-error
34 except ImportError:
35 MixedIndex = None
29 36
30 37
31 @unittest.skipIf( 38 @unittest.skipIf(
32 cparsers is None, 39 cparsers is None,
33 'The C version of the "parsers" module is not available. It is needed for this test.', 40 'The C version of the "parsers" module is not available. It is needed for this test.',
34 ) 41 )
35 class RevlogBasedTestBase(unittest.TestCase): 42 class RevlogBasedTestBase(unittest.TestCase):
36 def parseindex(self): 43 def parseindex(self, data=None):
37 return cparsers.parse_index2(data_non_inlined, False)[0] 44 if data is None:
45 data = data_non_inlined
46 return cparsers.parse_index2(data, False)[0]
47
48 def parserustindex(self, data=None):
49 if data is None:
50 data = data_non_inlined
51 cindex = self.parseindex(data=data)
52 return MixedIndex(cindex, data, REVLOGV1)