diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -225,9 +225,9 @@ else: parse_index_v1_nodemap = None -def parse_index_v1_mixed(data, inline, default_header): +def parse_index_v1_rust(data, inline, default_header): cache = (0, data) if inline else None - return rustrevlog.MixedIndex(data, default_header), cache + return rustrevlog.Index(data, default_header), cache # corresponds to uncompressed length of indexformatng (2 gigs, 4-byte @@ -1699,7 +1699,7 @@ class revlog: self._parse_index = parse_index_v1_nodemap elif use_rust_index: self._parse_index = functools.partial( - parse_index_v1_mixed, default_header=new_header + parse_index_v1_rust, default_header=new_header ) try: d = self._parse_index(index_data, self._inline) diff --git a/mercurial/testing/revlog.py b/mercurial/testing/revlog.py --- a/mercurial/testing/revlog.py +++ b/mercurial/testing/revlog.py @@ -30,9 +30,11 @@ except ImportError: cparsers = None try: - from ..rustext.revlog import MixedIndex # pytype: disable=import-error + from ..rustext.revlog import ( # pytype: disable=import-error + Index as RustIndex, + ) except ImportError: - MixedIndex = None + RustIndex = None @unittest.skipIf( @@ -47,7 +49,7 @@ class RevlogBasedTestBase(unittest.TestC @unittest.skipIf( - MixedIndex is None, + RustIndex is None, 'The Rust index is not available. It is needed for this test.', ) class RustRevlogBasedTestBase(unittest.TestCase): @@ -57,4 +59,4 @@ class RustRevlogBasedTestBase(unittest.T # not inheriting RevlogBasedTestCase to avoid having a # `parseindex` method that would be shadowed by future subclasses # this duplication will soon be removed - return MixedIndex(data, REVLOGV1) + return RustIndex(data, REVLOGV1) diff --git a/rust/hg-cpython/src/revlog.rs b/rust/hg-cpython/src/revlog.rs --- a/rust/hg-cpython/src/revlog.rs +++ b/rust/hg-cpython/src/revlog.rs @@ -40,7 +40,7 @@ pub(crate) fn py_rust_index_to_graph( py: Python, index: PyObject, ) -> PyResult> { - let midx = index.extract::(py)?; + let midx = index.extract::(py)?; let leaked = midx.index(py).leak_immutable(); Ok(unsafe { leaked.map(py, |idx| PySharedIndex { inner: idx }) }) } @@ -85,7 +85,7 @@ impl RevlogIndex for PySharedIndex { } } -py_class!(pub class MixedIndex |py| { +py_class!(pub class Index |py| { @shared data index: hg::index::Index; data nt: RefCell>; data docket: RefCell>; @@ -98,7 +98,7 @@ py_class!(pub class MixedIndex |py| { _cls, data: PyObject, default_header: u32, - ) -> PyResult { + ) -> PyResult { Self::new(py, data, default_header) } @@ -598,8 +598,8 @@ impl<'p> SnapshotsCache for PySnapshotsC } } -impl MixedIndex { - fn new(py: Python, data: PyObject, header: u32) -> PyResult { +impl Index { + fn new(py: Python, data: PyObject, header: u32) -> PyResult { // Safety: we keep the buffer around inside the class as `index_mmap` let (buf, bytes) = unsafe { mmap_keeparound(py, data)? }; @@ -1108,7 +1108,7 @@ pub fn init_module(py: Python, package: m.add(py, "__package__", package)?; m.add(py, "__doc__", "RevLog - Rust implementations")?; - m.add_class::(py)?; + m.add_class::(py)?; m.add_class::(py)?; let sys = PyModule::import(py, "sys")?; diff --git a/tests/test-rust-revlog.py b/tests/test-rust-revlog.py --- a/tests/test-rust-revlog.py +++ b/tests/test-rust-revlog.py @@ -27,16 +27,16 @@ header = struct.unpack(">I", revlogtesti class RustRevlogIndexTest(revlogtesting.RevlogBasedTestBase): def test_heads(self): idx = self.parseindex() - rustidx = revlog.MixedIndex(revlogtesting.data_non_inlined, header) + rustidx = revlog.Index(revlogtesting.data_non_inlined, header) self.assertEqual(rustidx.headrevs(), idx.headrevs()) def test_len(self): idx = self.parseindex() - rustidx = revlog.MixedIndex(revlogtesting.data_non_inlined, header) + rustidx = revlog.Index(revlogtesting.data_non_inlined, header) self.assertEqual(len(rustidx), len(idx)) def test_ancestors(self): - rustidx = revlog.MixedIndex(revlogtesting.data_non_inlined, header) + rustidx = revlog.Index(revlogtesting.data_non_inlined, header) lazy = LazyAncestors(rustidx, [3], 0, True) # we have two more references to the index: # - in its inner iterator for __contains__ and __bool__