Mercurial > hg
changeset 51254:f94c10334bcb
rust-index: renamed `MixedIndex` as `Index`
It is simply not mixed any more, hence the name had become a
future source of confusion.
author | Georges Racinet on incendie.racinet.fr <georges@racinet.fr> |
---|---|
date | Sun, 29 Oct 2023 12:18:03 +0100 |
parents | 96e05f1a99bd |
children | 24d3298189d7 |
files | mercurial/revlog.py mercurial/testing/revlog.py rust/hg-cpython/src/revlog.rs tests/test-rust-revlog.py |
diffstat | 4 files changed, 18 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revlog.py Sun Oct 29 23:54:05 2023 +0100 +++ b/mercurial/revlog.py Sun Oct 29 12:18:03 2023 +0100 @@ -225,9 +225,9 @@ 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 @@ 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)
--- a/mercurial/testing/revlog.py Sun Oct 29 23:54:05 2023 +0100 +++ b/mercurial/testing/revlog.py Sun Oct 29 12:18:03 2023 +0100 @@ -30,9 +30,11 @@ 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 @@ @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 @@ # 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)
--- a/rust/hg-cpython/src/revlog.rs Sun Oct 29 23:54:05 2023 +0100 +++ b/rust/hg-cpython/src/revlog.rs Sun Oct 29 12:18:03 2023 +0100 @@ -40,7 +40,7 @@ py: Python, index: PyObject, ) -> PyResult<UnsafePyLeaked<PySharedIndex>> { - let midx = index.extract::<MixedIndex>(py)?; + let midx = index.extract::<Index>(py)?; let leaked = midx.index(py).leak_immutable(); Ok(unsafe { leaked.map(py, |idx| PySharedIndex { inner: idx }) }) } @@ -85,7 +85,7 @@ } } -py_class!(pub class MixedIndex |py| { +py_class!(pub class Index |py| { @shared data index: hg::index::Index; data nt: RefCell<Option<CoreNodeTree>>; data docket: RefCell<Option<PyObject>>; @@ -98,7 +98,7 @@ _cls, data: PyObject, default_header: u32, - ) -> PyResult<MixedIndex> { + ) -> PyResult<Self> { Self::new(py, data, default_header) } @@ -598,8 +598,8 @@ } } -impl MixedIndex { - fn new(py: Python, data: PyObject, header: u32) -> PyResult<MixedIndex> { +impl Index { + fn new(py: Python, data: PyObject, header: u32) -> PyResult<Self> { // Safety: we keep the buffer around inside the class as `index_mmap` let (buf, bytes) = unsafe { mmap_keeparound(py, data)? }; @@ -1108,7 +1108,7 @@ m.add(py, "__package__", package)?; m.add(py, "__doc__", "RevLog - Rust implementations")?; - m.add_class::<MixedIndex>(py)?; + m.add_class::<Index>(py)?; m.add_class::<NodeTree>(py)?; let sys = PyModule::import(py, "sys")?;
--- a/tests/test-rust-revlog.py Sun Oct 29 23:54:05 2023 +0100 +++ b/tests/test-rust-revlog.py Sun Oct 29 12:18:03 2023 +0100 @@ -27,16 +27,16 @@ 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__