diff mercurial/testing/revlog.py @ 52436:cf5b47b885b1

testing: stop skipping all Python tests of Rust revlog This base class was not adapted for the introduction of `InnerRevlog`, which also stopped exposing an `Index` class from `rustext`. As a consequence, `test-rust-ancestor.py` was always skipped (and would have been slightly broken). We remove the skipping conditions from `rustancestorstest`, as they now contradict or repeat those of the base class. Also, `LazyAncestors` objects apparently hold only one reference to the inner revlog (they had previously two references on the Rust index). What matters most of course is the return to `start_count` in these tests, i.e., that there is no memory leak nor double frees. In the Python test, we conflate the presence of the `pyo3_rustext` package with that of `rustext`, as we do not plan to support building one and not the other (we hope to convert fully to PyO3 soon). The skipping is actually done by the base test class.
author Georges Racinet <georges.racinet@cloudcrane.io>
date Sat, 30 Nov 2024 19:12:02 +0100
parents f4733654f144
children 07740bd86fd9
line wrap: on
line diff
--- a/mercurial/testing/revlog.py	Fri Nov 29 22:55:30 2024 +0100
+++ b/mercurial/testing/revlog.py	Sat Nov 30 19:12:02 2024 +0100
@@ -23,7 +23,10 @@
     b'\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 )
 
-from ..revlogutils.constants import REVLOGV1
+from ..revlogutils.constants import (
+    KIND_CHANGELOG,
+)
+from .. import revlog
 
 
 try:
@@ -32,11 +35,13 @@
     cparsers = None
 
 try:
-    from ..rustext.revlog import (  # pytype: disable=import-error
-        Index as RustIndex,
+    from ..rustext import (  # pytype: disable=import-error
+        revlog as rust_revlog,
     )
+
+    rust_revlog.__name__  # force actual import
 except ImportError:
-    RustIndex = None
+    rust_revlog = None
 
 
 @unittest.skipIf(
@@ -51,14 +56,38 @@
 
 
 @unittest.skipIf(
-    RustIndex is None,
-    'The Rust index is not available. It is needed for this test.',
+    rust_revlog is None,
+    'The Rust revlog module is not available. It is needed for this test.',
 )
 class RustRevlogBasedTestBase(unittest.TestCase):
-    def parserustindex(self, data=None):
+    # defaults
+    revlog_data_config = revlog.DataConfig()
+    revlog_delta_config = revlog.DeltaConfig()
+    revlog_feature_config = revlog.FeatureConfig()
+
+    def make_inner_revlog(
+        self, data=None, vfs_is_readonly=True, kind=KIND_CHANGELOG
+    ):
         if data is None:
             data = data_non_inlined
-        # not inheriting RevlogBasedTestCase to avoid having a
-        # `parseindex` method that would be shadowed by future subclasses
-        # this duplication will soon be removed
-        return RustIndex(data, REVLOGV1)
+
+        return rust_revlog.InnerRevlog(
+            vfs_base=b"Just a path",
+            fncache=None,  # might be enough for now
+            vfs_is_readonly=vfs_is_readonly,
+            index_data=data,
+            index_file=b'test.i',
+            data_file=b'test.d',
+            sidedata_file=None,
+            inline=False,
+            data_config=self.revlog_data_config,
+            delta_config=self.revlog_delta_config,
+            feature_config=self.revlog_feature_config,
+            chunk_cache=None,
+            default_compression_header=None,
+            revlog_type=kind,
+            use_persistent_nodemap=False,  # until we cook one.
+        )
+
+    def parserustindex(self, data=None):
+        return revlog.RustIndexProxy(self.make_inner_revlog(data=data))