Show More
@@ -28,17 +28,28 b' where' | |||||
28 | C: FromIterator<Revision>, |
|
28 | C: FromIterator<Revision>, | |
29 | I: RevlogIndex, |
|
29 | I: RevlogIndex, | |
30 | { |
|
30 | { | |
|
31 | rev_pyiter_collect_or_else(py, revs, index, |r| { | |||
|
32 | PyErr::new::<GraphError, _>(py, ("InvalidRevision", r.0)) | |||
|
33 | }) | |||
|
34 | } | |||
|
35 | ||||
|
36 | /// Same as [`rev_pyiter_collect`], giving control on returned errors | |||
|
37 | pub fn rev_pyiter_collect_or_else<C, I>( | |||
|
38 | py: Python, | |||
|
39 | revs: &PyObject, | |||
|
40 | index: &I, | |||
|
41 | invalid_rev_error: impl FnOnce(PyRevision) -> PyErr + Copy, | |||
|
42 | ) -> PyResult<C> | |||
|
43 | where | |||
|
44 | C: FromIterator<Revision>, | |||
|
45 | I: RevlogIndex, | |||
|
46 | { | |||
31 | revs.iter(py)? |
|
47 | revs.iter(py)? | |
32 | .map(|r| { |
|
48 | .map(|r| { | |
33 | r.and_then(|o| match o.extract::<PyRevision>(py) { |
|
49 | r.and_then(|o| match o.extract::<PyRevision>(py) { | |
34 | Ok(r) => index |
|
50 | Ok(r) => index | |
35 | .check_revision(UncheckedRevision(r.0)) |
|
51 | .check_revision(UncheckedRevision(r.0)) | |
36 |
.ok_or_else(|| |
|
52 | .ok_or_else(|| invalid_rev_error(r)), | |
37 | PyErr::new::<GraphError, _>( |
|
|||
38 | py, |
|
|||
39 | ("InvalidRevision", r.0), |
|
|||
40 | ) |
|
|||
41 | }), |
|
|||
42 | Err(e) => Err(e), |
|
53 | Err(e) => Err(e), | |
43 | }) |
|
54 | }) | |
44 | }) |
|
55 | }) |
General Comments 0
You need to be logged in to leave comments.
Login now