Mercurial > public > mercurial-scm > hg-stable
changeset 52865:c6707e112d96
rust-pyo3-dirstate: exceptions for dirstate errors
author | Georges Racinet <georges.racinet@cloudcrane.io> |
---|---|
date | Wed, 29 Jan 2025 14:03:24 +0100 |
parents | 6b3b69b32a41 |
children | 4e5efcaa7e60 |
files | rust/hg-pyo3/src/exceptions.rs |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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") +}