Mercurial > public > mercurial-scm > hg
diff rust/hg-cpython/src/exceptions.rs @ 48519:35ebe6f824be
hg-cpython: use ancestor iterator impls from vcsgraph
Differential Revision: https://phab.mercurial-scm.org/D11947
author | pacien <pacien.trangirard@pacien.net> |
---|---|
date | Tue, 16 Nov 2021 18:54:05 +0100 |
parents | f96b28aa4b79 |
children | 3aca98a35727 |
line wrap: on
line diff
--- a/rust/hg-cpython/src/exceptions.rs Fri Dec 10 15:27:22 2021 +0100 +++ b/rust/hg-cpython/src/exceptions.rs Tue Nov 16 18:54:05 2021 +0100 @@ -37,6 +37,32 @@ } } } + + pub fn pynew_from_vcsgraph( + py: Python, + inner: vcsgraph::graph::GraphReadError, + ) -> PyErr { + match inner { + vcsgraph::graph::GraphReadError::InconsistentGraphData => { + GraphError::new(py, "InconsistentGraphData") + } + vcsgraph::graph::GraphReadError::InvalidKey => { + GraphError::new(py, "ParentOutOfRange") + } + vcsgraph::graph::GraphReadError::KeyedInvalidKey(r) => { + GraphError::new(py, ("ParentOutOfRange", r)) + } + vcsgraph::graph::GraphReadError::WorkingDirectoryUnsupported => { + match py + .import("mercurial.error") + .and_then(|m| m.get(py, "WdirUnsupported")) + { + Err(e) => e, + Ok(cls) => PyErr::from_instance(py, cls), + } + } + } + } } py_exception!(rustext, HgPathPyError, RuntimeError);