D8158: rust-nodemap: add binding for `nodemap_data_all`
Alphare created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial BRANCH default 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 @@ -251,6 +251,10 @@ } } +def nodemap_data_all(&self) -> PyResult { +self.inner_nodemap_data_all(py) +} + }); @@ -311,6 +315,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 { +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
D8158: rust-nodemap: add binding for `nodemap_data_all`
marmoute updated this revision to Diff 20377. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8158?vs=20333&id=20377 BRANCH default 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 { +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 { +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
D8158: rust-nodemap: add binding for `nodemap_data_all`
Alphare updated this revision to Diff 20657. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D8158?vs=20377&id=20657 BRANCH default 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 { +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 { +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
D8158: rust-nodemap: add binding for `nodemap_data_all`
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 { +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 { +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