355 |
355 |
356 } |
356 } |
357 |
357 |
358 /// slice planned chunk read to reach a density threshold |
358 /// slice planned chunk read to reach a density threshold |
359 def slicechunktodensity(&self, *args, **kw) -> PyResult<PyObject> { |
359 def slicechunktodensity(&self, *args, **kw) -> PyResult<PyObject> { |
360 self.call_cindex(py, "slicechunktodensity", args, kw) |
360 let rust_res = self.inner_slicechunktodensity( |
|
361 py, |
|
362 args.get_item(py, 0), |
|
363 args.get_item(py, 1).extract(py)?, |
|
364 args.get_item(py, 2).extract(py)? |
|
365 )?; |
|
366 |
|
367 let c_res = self.call_cindex(py, "slicechunktodensity", args, kw)?; |
|
368 assert_eq!( |
|
369 rust_res.len(), |
|
370 c_res.len(py)?, |
|
371 "chunks differ {:?} {}", |
|
372 rust_res, c_res |
|
373 ); |
|
374 for (i, chunk) in rust_res.iter().enumerate() { |
|
375 let c_chunk = c_res.get_item(py, i)?; |
|
376 assert_eq!( |
|
377 chunk.len(), |
|
378 c_chunk.len(py)?, |
|
379 "chunk {} length differ {:?} {}", |
|
380 i, |
|
381 chunk, |
|
382 c_res |
|
383 ); |
|
384 for (j, rev) in chunk.iter().enumerate() { |
|
385 let c_chunk: BaseRevision |
|
386 = c_chunk.get_item(py, j)?.extract(py)?; |
|
387 assert_eq!(c_chunk, rev.0); |
|
388 } |
|
389 } |
|
390 Ok(c_res) |
361 } |
391 } |
362 |
392 |
363 /// stats for the index |
393 /// stats for the index |
364 def stats(&self, *args, **kw) -> PyResult<PyObject> { |
394 def stats(&self, *args, **kw) -> PyResult<PyObject> { |
365 self.call_cindex(py, "stats", args, kw) |
395 self.call_cindex(py, "stats", args, kw) |
817 .iter() |
847 .iter() |
818 .map(|r| PyRevision::from(*r).into_py_object(py).into_object()) |
848 .map(|r| PyRevision::from(*r).into_py_object(py).into_object()) |
819 .collect(); |
849 .collect(); |
820 Ok(PyList::new(py, &as_vec).into_object()) |
850 Ok(PyList::new(py, &as_vec).into_object()) |
821 } |
851 } |
|
852 |
|
853 fn inner_slicechunktodensity( |
|
854 &self, |
|
855 py: Python, |
|
856 revs: PyObject, |
|
857 target_density: f64, |
|
858 min_gap_size: usize, |
|
859 ) -> PyResult<Vec<Vec<Revision>>> { |
|
860 let index = &mut *self.index(py).borrow_mut(); |
|
861 let revs: Vec<_> = rev_pyiter_collect(py, &revs, index)?; |
|
862 Ok(index.slice_chunk_to_density(&revs, target_density, min_gap_size)) |
|
863 } |
822 } |
864 } |
823 |
865 |
824 fn revlog_error(py: Python) -> PyErr { |
866 fn revlog_error(py: Python) -> PyErr { |
825 match py |
867 match py |
826 .import("mercurial.error") |
868 .import("mercurial.error") |