Closed by commit rHGb581231ae9d1: rust-nodemap: add binding for `nodemap_data_all` (authored by gracinet). This revision was automatically updated to reflect the committed changes. This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8158?vs=20657&id=20696 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D8158/new/ REVISION DETAIL https://phab.mercurial-scm.org/D8158 AFFECTED FILES rust/hg-cpython/src/revlog.rs CHANGE DETAILS 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 @@ -260,6 +260,10 @@ } } + def nodemap_data_all(&self) -> PyResult<PyBytes> { + self.inner_nodemap_data_all(py) + } + }); @@ -320,6 +324,29 @@ 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(); + let (readonly, bytes) = nodemap.into_readonly_and_added_bytes(); + + // If there's anything readonly, we need to build the data again from + // scratch + let bytes = if readonly.len() > 0 { + let mut nt = NodeTree::load_bytes(Box::new(vec![]), 0); + self.fill_nodemap(py, &mut nt)?; + + let (readonly, bytes) = nt.into_readonly_and_added_bytes(); + assert_eq!(readonly.len(), 0); + + bytes + } else { + bytes + }; + + let bytes = PyBytes::new(py, &bytes); + Ok(bytes) + } } fn revlog_error(py: Python) -> PyErr { To: Alphare, #hg-reviewers Cc: mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel