diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -226,8 +226,8 @@ else: def parse_index_v1_mixed(data, inline, default_header): - index, cache = parse_index_v1(data, inline) - return rustrevlog.MixedIndex(index, data, default_header), cache + cache = (0, data) if inline else None + return rustrevlog.MixedIndex(data, default_header), cache # corresponds to uncompressed length of indexformatng (2 gigs, 4-byte diff --git a/mercurial/testing/revlog.py b/mercurial/testing/revlog.py --- a/mercurial/testing/revlog.py +++ b/mercurial/testing/revlog.py @@ -57,5 +57,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 - cindex = cparsers.parse_index2(data, False)[0] - return MixedIndex(cindex, data, REVLOGV1) + return MixedIndex(data, REVLOGV1) diff --git a/rust/hg-cpython/src/cindex.rs b/rust/hg-cpython/src/cindex.rs --- a/rust/hg-cpython/src/cindex.rs +++ b/rust/hg-cpython/src/cindex.rs @@ -9,7 +9,7 @@ //! //! Ideally, we should use an Index entirely implemented in Rust, //! but this will take some time to get there. - +#![allow(dead_code)] use cpython::{ exc::ImportError, exc::TypeError, ObjectProtocol, PyClone, PyErr, PyObject, PyResult, PyTuple, Python, PythonObject, 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 @@ -6,7 +6,6 @@ // GNU General Public License version 2 or any later version. use crate::{ - cindex, conversion::{rev_pyiter_collect, rev_pyiter_collect_or_else}, utils::{node_from_py_bytes, node_from_py_object}, PyRevision, @@ -87,7 +86,6 @@ impl RevlogIndex for PySharedIndex { } py_class!(pub class MixedIndex |py| { - data cindex: RefCell; @shared data index: hg::index::Index; data nt: RefCell>; data docket: RefCell>; @@ -98,11 +96,10 @@ py_class!(pub class MixedIndex |py| { def __new__( _cls, - cindex: PyObject, data: PyObject, default_header: u32, ) -> PyResult { - Self::new(py, cindex, data, default_header) + Self::new(py, data, default_header) } /// Compatibility layer used for Python consumers needing access to the C index @@ -111,11 +108,11 @@ py_class!(pub class MixedIndex |py| { /// that may need to build a custom `nodetree`, based on a specified revset. /// With a Rust implementation of the nodemap, we will be able to get rid of /// this, by exposing our own standalone nodemap class, - /// ready to accept `MixedIndex`. - def get_cindex(&self) -> PyResult { + /// ready to accept `Index`. +/* def get_cindex(&self) -> PyResult { Ok(self.cindex(py).borrow().inner().clone_ref(py)) } - +*/ // Index API involving nodemap, as defined in mercurial/pure/parsers.py /// Return Revision if found, raises a bare `error.RevlogError` @@ -602,18 +599,12 @@ impl<'p> SnapshotsCache for PySnapshotsC } impl MixedIndex { - fn new( - py: Python, - cindex: PyObject, - data: PyObject, - header: u32, - ) -> PyResult { + 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)? }; Self::create_instance( py, - RefCell::new(cindex::Index::new(py, cindex)?), hg::index::Index::new( bytes, IndexHeader::parse(&header.to_be_bytes()) @@ -666,10 +657,6 @@ impl MixedIndex { Ok(self.nt(py)) } - pub fn clone_cindex(&self, py: Python) -> cindex::Index { - self.cindex(py).borrow().clone_ref(py) - } - /// Returns the full nodemap bytes to be written as-is to disk fn inner_nodemap_data_all(&self, py: Python) -> PyResult { let nodemap = self.get_nodetree(py)?.borrow_mut().take().unwrap(); 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,24 +27,16 @@ header = struct.unpack(">I", revlogtesti class RustRevlogIndexTest(revlogtesting.RevlogBasedTestBase): def test_heads(self): idx = self.parseindex() - rustidx = revlog.MixedIndex(idx, revlogtesting.data_non_inlined, header) + rustidx = revlog.MixedIndex(revlogtesting.data_non_inlined, header) self.assertEqual(rustidx.headrevs(), idx.headrevs()) - def test_get_cindex(self): - # drop me once we no longer need the method for shortest node - idx = self.parseindex() - rustidx = revlog.MixedIndex(idx, revlogtesting.data_non_inlined, header) - cidx = rustidx.get_cindex() - self.assertTrue(idx is cidx) - def test_len(self): idx = self.parseindex() - rustidx = revlog.MixedIndex(idx, revlogtesting.data_non_inlined, header) + rustidx = revlog.MixedIndex(revlogtesting.data_non_inlined, header) self.assertEqual(len(rustidx), len(idx)) def test_ancestors(self): - idx = self.parseindex() - rustidx = revlog.MixedIndex(idx, revlogtesting.data_non_inlined, header) + rustidx = revlog.MixedIndex(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__ diff --git a/tests/test-verify.t b/tests/test-verify.t --- a/tests/test-verify.t +++ b/tests/test-verify.t @@ -311,7 +311,8 @@ test revlog corruption $ cat start b > .hg/store/data/a.i $ hg verify -q - a@1: broken revlog! (index a is corrupted) + a@1: broken revlog! (index a is corrupted) (no-rust !) + a@1: broken revlog! (abort: unexpected inline revlog length) (rust !) warning: orphan data file 'data/a.i' not checking dirstate because of previous errors 1 warnings encountered!