24 py: Python, |
23 py: Python, |
25 revs: PyList, |
24 revs: PyList, |
26 children_count: PyDict, |
25 children_count: PyDict, |
27 target_rev: Revision, |
26 target_rev: Revision, |
28 rev_info: PyObject, |
27 rev_info: PyObject, |
29 is_ancestor: PyObject, |
|
30 ) -> PyResult<PyDict> { |
28 ) -> PyResult<PyDict> { |
31 let revs: PyResult<_> = |
29 let revs: PyResult<_> = |
32 revs.iter(py).map(|r| Ok(r.extract(py)?)).collect(); |
30 revs.iter(py).map(|r| Ok(r.extract(py)?)).collect(); |
33 |
|
34 // Wrap the `is_ancestor` python callback as a Rust closure |
|
35 // |
|
36 // No errors are expected from the Python side, and they will should only |
|
37 // happens in case of programing error or severe data corruption. Such |
|
38 // errors will raise panic and the rust-cpython harness will turn them into |
|
39 // Python exception. |
|
40 let is_ancestor_wrap = |anc: Revision, desc: Revision| -> bool { |
|
41 is_ancestor |
|
42 .call(py, (anc, desc), None) |
|
43 .expect( |
|
44 "rust-copy-tracing: python call to `is_ancestor` \ |
|
45 failed", |
|
46 ) |
|
47 .cast_into::<PyBool>(py) |
|
48 .expect( |
|
49 "rust-copy-tracing: python call to `is_ancestor` \ |
|
50 returned unexpected non-Bool value", |
|
51 ) |
|
52 .is_true() |
|
53 }; |
|
54 |
31 |
55 // Wrap the `rev_info_maker` python callback as a Rust closure |
32 // Wrap the `rev_info_maker` python callback as a Rust closure |
56 // |
33 // |
57 // No errors are expected from the Python side, and they will should only |
34 // No errors are expected from the Python side, and they will should only |
58 // happens in case of programing error or severe data corruption. Such |
35 // happens in case of programing error or severe data corruption. Such |