##// END OF EJS Templates
rust-nodemap: add binding for `nodemap_data_all`...
Georges Racinet -
r44995:b581231a default
parent child Browse files
Show More
@@ -260,6 +260,10 b' py_class!(pub class MixedIndex |py| {'
260 }
260 }
261 }
261 }
262
262
263 def nodemap_data_all(&self) -> PyResult<PyBytes> {
264 self.inner_nodemap_data_all(py)
265 }
266
263
267
264 });
268 });
265
269
@@ -320,6 +324,29 b' impl MixedIndex {'
320 pub fn clone_cindex(&self, py: Python) -> cindex::Index {
324 pub fn clone_cindex(&self, py: Python) -> cindex::Index {
321 self.cindex(py).borrow().clone_ref(py)
325 self.cindex(py).borrow().clone_ref(py)
322 }
326 }
327
328 /// Returns the full nodemap bytes to be written as-is to disk
329 fn inner_nodemap_data_all(&self, py: Python) -> PyResult<PyBytes> {
330 let nodemap = self.get_nodetree(py)?.borrow_mut().take().unwrap();
331 let (readonly, bytes) = nodemap.into_readonly_and_added_bytes();
332
333 // If there's anything readonly, we need to build the data again from
334 // scratch
335 let bytes = if readonly.len() > 0 {
336 let mut nt = NodeTree::load_bytes(Box::new(vec![]), 0);
337 self.fill_nodemap(py, &mut nt)?;
338
339 let (readonly, bytes) = nt.into_readonly_and_added_bytes();
340 assert_eq!(readonly.len(), 0);
341
342 bytes
343 } else {
344 bytes
345 };
346
347 let bytes = PyBytes::new(py, &bytes);
348 Ok(bytes)
349 }
323 }
350 }
324
351
325 fn revlog_error(py: Python) -> PyErr {
352 fn revlog_error(py: Python) -> PyErr {
General Comments 0
You need to be logged in to leave comments. Login now