Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-cpython/src/revlog.rs @ 51274:96e05f1a99bd
rust-index: stop instantiating a C Index
The only missing piece was the `cache` to be returned from
`revlog.parse_index_v1_mixed`, and it really seems that it is
essentially repetition of the input, if `inline` is `True`.
Not worth a Rust implementation (C implementation is probably there
for historical reasons).
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Sun, 29 Oct 2023 23:54:05 +0100 |
parents | 0409bd6ba663 |
children | f94c10334bcb |
line wrap: on
line diff
--- a/rust/hg-cpython/src/revlog.rs Mon Oct 30 21:28:30 2023 +0100 +++ b/rust/hg-cpython/src/revlog.rs Sun Oct 29 23:54:05 2023 +0100 @@ -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 @@ } py_class!(pub class MixedIndex |py| { - data cindex: RefCell<cindex::Index>; @shared data index: hg::index::Index; data nt: RefCell<Option<CoreNodeTree>>; data docket: RefCell<Option<PyObject>>; @@ -98,11 +96,10 @@ def __new__( _cls, - cindex: PyObject, data: PyObject, default_header: u32, ) -> PyResult<MixedIndex> { - 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 @@ /// 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<PyObject> { + /// ready to accept `Index`. +/* def get_cindex(&self) -> PyResult<PyObject> { 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 MixedIndex { - fn new( - py: Python, - cindex: PyObject, - data: PyObject, - header: u32, - ) -> PyResult<MixedIndex> { + fn new(py: Python, data: PyObject, header: u32) -> PyResult<MixedIndex> { // 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 @@ 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<PyBytes> { let nodemap = self.get_nodetree(py)?.borrow_mut().take().unwrap();