Show More
@@ -15,7 +15,7 b' use cpython::{' | |||||
15 | PyResult, PyString, PyTuple, Python, PythonObject, ToPyObject, |
|
15 | PyResult, PyString, PyTuple, Python, PythonObject, ToPyObject, | |
16 | }; |
|
16 | }; | |
17 | use hg::{ |
|
17 | use hg::{ | |
18 | nodemap::{NodeMapError, NodeTree}, |
|
18 | nodemap::{Block, NodeMapError, NodeTree}, | |
19 | revlog::{nodemap::NodeMap, RevlogIndex}, |
|
19 | revlog::{nodemap::NodeMap, RevlogIndex}, | |
20 | NodeError, Revision, |
|
20 | NodeError, Revision, | |
21 | }; |
|
21 | }; | |
@@ -35,6 +35,7 b' pub(crate) fn pyindex_to_graph(' | |||||
35 | py_class!(pub class MixedIndex |py| { |
|
35 | py_class!(pub class MixedIndex |py| { | |
36 | data cindex: RefCell<cindex::Index>; |
|
36 | data cindex: RefCell<cindex::Index>; | |
37 | data nt: RefCell<Option<NodeTree>>; |
|
37 | data nt: RefCell<Option<NodeTree>>; | |
|
38 | data docket: RefCell<Option<PyObject>>; | |||
38 |
|
39 | |||
39 | def __new__(_cls, cindex: PyObject) -> PyResult<MixedIndex> { |
|
40 | def __new__(_cls, cindex: PyObject) -> PyResult<MixedIndex> { | |
40 | Self::new(py, cindex) |
|
41 | Self::new(py, cindex) | |
@@ -264,6 +265,9 b' py_class!(pub class MixedIndex |py| {' | |||||
264 | self.inner_nodemap_data_all(py) |
|
265 | self.inner_nodemap_data_all(py) | |
265 | } |
|
266 | } | |
266 |
|
267 | |||
|
268 | def nodemap_data_incremental(&self) -> PyResult<PyObject> { | |||
|
269 | self.inner_nodemap_data_incremental(py) | |||
|
270 | } | |||
267 |
|
271 | |||
268 | }); |
|
272 | }); | |
269 |
|
273 | |||
@@ -273,6 +277,7 b' impl MixedIndex {' | |||||
273 | py, |
|
277 | py, | |
274 | RefCell::new(cindex::Index::new(py, cindex)?), |
|
278 | RefCell::new(cindex::Index::new(py, cindex)?), | |
275 | RefCell::new(None), |
|
279 | RefCell::new(None), | |
|
280 | RefCell::new(None), | |||
276 | ) |
|
281 | ) | |
277 | } |
|
282 | } | |
278 |
|
283 | |||
@@ -347,6 +352,28 b' impl MixedIndex {' | |||||
347 | let bytes = PyBytes::new(py, &bytes); |
|
352 | let bytes = PyBytes::new(py, &bytes); | |
348 | Ok(bytes) |
|
353 | Ok(bytes) | |
349 | } |
|
354 | } | |
|
355 | ||||
|
356 | /// Returns the last saved docket along with the size of any changed data | |||
|
357 | /// (in number of blocks), and said data as bytes. | |||
|
358 | fn inner_nodemap_data_incremental( | |||
|
359 | &self, | |||
|
360 | py: Python, | |||
|
361 | ) -> PyResult<PyObject> { | |||
|
362 | let docket = self.docket(py).borrow(); | |||
|
363 | let docket = match docket.as_ref() { | |||
|
364 | Some(d) => d, | |||
|
365 | None => return Ok(py.None()), | |||
|
366 | }; | |||
|
367 | ||||
|
368 | let node_tree = self.get_nodetree(py)?.borrow_mut().take().unwrap(); | |||
|
369 | let masked_blocks = node_tree.masked_readonly_blocks(); | |||
|
370 | let (_, data) = node_tree.into_readonly_and_added_bytes(); | |||
|
371 | let changed = masked_blocks * std::mem::size_of::<Block>(); | |||
|
372 | ||||
|
373 | Ok((docket, changed, PyBytes::new(py, &data)) | |||
|
374 | .to_py_object(py) | |||
|
375 | .into_object()) | |||
|
376 | } | |||
350 | } |
|
377 | } | |
351 |
|
378 | |||
352 | fn revlog_error(py: Python) -> PyErr { |
|
379 | fn revlog_error(py: Python) -> PyErr { |
General Comments 0
You need to be logged in to leave comments.
Login now