diff -r 6b3b69b32a41 -r c6707e112d96 rust/hg-pyo3/src/exceptions.rs --- a/rust/hg-pyo3/src/exceptions.rs Wed Jan 29 13:49:29 2025 +0100 +++ b/rust/hg-pyo3/src/exceptions.rs Wed Jan 29 14:03:24 2025 +0100 @@ -1,7 +1,9 @@ -use pyo3::exceptions::{PyRuntimeError, PyValueError}; +use pyo3::exceptions::{PyOSError, PyRuntimeError, PyValueError}; use pyo3::import_exception; use pyo3::{create_exception, PyErr}; +use hg::dirstate::{on_disk::DirstateV2ParseError, DirstateError}; + use hg::revlog::nodemap::NodeMapError; use hg::UncheckedRevision; @@ -85,3 +87,13 @@ // in `hg::GraphError`. The C index always raises this simple ValueError. PyValueError::new_err("parent out of range") } + +#[allow(dead_code)] +pub fn dirstate_error(err: DirstateError) -> PyErr { + PyOSError::new_err(format!("Dirstate error: {:?}", err)) +} + +#[allow(dead_code)] +pub fn dirstate_v2_error(_err: DirstateV2ParseError) -> PyErr { + PyValueError::new_err("corrupted dirstate-v2") +}