Mercurial > public > mercurial-scm > hg-stable
diff rust/hg-cpython/src/revlog.rs @ 46496:5893706af3de
rust: Simplify error type for reading hex node IDs
If a string is not valid hexadecimal it?s not that useful to track the precise reason.
Differential Revision: https://phab.mercurial-scm.org/D9861
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Mon, 25 Jan 2021 12:28:39 +0100 |
parents | cadcc8c20860 |
children | 645ee7225fab |
line wrap: on
line diff
--- a/rust/hg-cpython/src/revlog.rs Mon Jan 25 12:00:23 2021 +0100 +++ b/rust/hg-cpython/src/revlog.rs Mon Jan 25 12:28:39 2021 +0100 @@ -18,7 +18,7 @@ use hg::{ nodemap::{Block, NodeMapError, NodeTree}, revlog::{nodemap::NodeMap, RevlogIndex}, - NodeError, Revision, + Revision, }; use std::cell::RefCell; @@ -468,17 +468,12 @@ match err { NodeMapError::MultipleResults => revlog_error(py), NodeMapError::RevisionNotInIndex(r) => rev_not_in_index(py, r), - NodeMapError::InvalidNodePrefix(s) => invalid_node_prefix(py, &s), + NodeMapError::InvalidNodePrefix => { + PyErr::new::<ValueError, _>(py, "Invalid node or prefix") + } } } -fn invalid_node_prefix(py: Python, ne: &NodeError) -> PyErr { - PyErr::new::<ValueError, _>( - py, - format!("Invalid node or prefix: {:?}", ne), - ) -} - /// Create the module, with __package__ given from parent pub fn init_module(py: Python, package: &str) -> PyResult<PyModule> { let dotted_name = &format!("{}.revlog", package);