Mercurial > public > mercurial-scm > hg
diff rust/hg-cpython/src/revlog.rs @ 51188:13f58ce70299
rust-revlog: teach the revlog opening code to read the repo options
This will become necessary as we start writing revlog data from Rust.
author | Rapha?l Gom?s <rgomes@octobus.net> |
---|---|
date | Mon, 18 Sep 2023 17:11:11 +0200 |
parents | 6ec8387eb0be |
children | 65c9032e2e5a |
line wrap: on
line diff
--- a/rust/hg-cpython/src/revlog.rs Tue Jun 27 17:34:51 2023 +0200 +++ b/rust/hg-cpython/src/revlog.rs Mon Sep 18 17:11:11 2023 +0200 @@ -17,6 +17,7 @@ PyObject, PyResult, PyString, PyTuple, Python, PythonObject, ToPyObject, }; use hg::{ + index::IndexHeader, nodemap::{Block, NodeMapError, NodeTree}, revlog::{nodemap::NodeMap, NodePrefix, RevlogIndex}, BaseRevision, Revision, UncheckedRevision, @@ -47,9 +48,10 @@ def __new__( _cls, cindex: PyObject, - data: PyObject + data: PyObject, + default_header: u32, ) -> PyResult<MixedIndex> { - Self::new(py, cindex, data) + Self::new(py, cindex, data, default_header) } /// Compatibility layer used for Python consumers needing access to the C index @@ -364,6 +366,7 @@ py: Python, cindex: PyObject, 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)? }; @@ -371,7 +374,15 @@ Self::create_instance( py, RefCell::new(cindex::Index::new(py, cindex)?), - RefCell::new(hg::index::Index::new(bytes).unwrap()), + RefCell::new( + hg::index::Index::new( + bytes, + IndexHeader::parse(&header.to_be_bytes()) + .expect("default header is broken") + .unwrap(), + ) + .unwrap(), + ), RefCell::new(None), RefCell::new(None), RefCell::new(None),