Mercurial > public > mercurial-scm > hg
diff rust/rhg/src/error.rs @ 46440:776b97179c06
rust: Remove DirstateParseError and ListDirstateTrackedFilesError
Use HgError instead.
Differential Revision: https://phab.mercurial-scm.org/D9894
author | Simon Sapin <simon.sapin@octobus.net> |
---|---|
date | Wed, 27 Jan 2021 14:00:21 +0100 |
parents | b274aa2f20fd |
children | 741e36f472a5 |
line wrap: on
line diff
--- a/rust/rhg/src/error.rs Wed Jan 27 13:41:28 2021 +0100 +++ b/rust/rhg/src/error.rs Wed Jan 27 14:00:21 2021 +0100 @@ -2,7 +2,8 @@ use crate::ui::utf8_to_local; use crate::ui::UiError; use format_bytes::format_bytes; -use hg::operations::{FindRootError, ListDirstateTrackedFilesError}; +use hg::errors::HgError; +use hg::operations::FindRootError; use hg::requirements::RequirementsError; use hg::revlog::revlog::RevlogError; use hg::utils::files::get_bytes_from_path; @@ -27,6 +28,9 @@ Abort(Option<Vec<u8>>), /// A mercurial capability as not been implemented. Unimplemented, + /// Common cases + #[from] + Other(HgError), } impl CommandError { @@ -42,6 +46,10 @@ CommandError::StderrError => exitcode::ABORT, CommandError::Abort(_) => exitcode::ABORT, CommandError::Unimplemented => exitcode::UNIMPLEMENTED_COMMAND, + CommandError::Other(HgError::UnsupportedFeature(_)) => { + exitcode::UNIMPLEMENTED_COMMAND + } + CommandError::Other(_) => exitcode::ABORT, } } @@ -141,21 +149,3 @@ } } } - -impl From<ListDirstateTrackedFilesError> for CommandError { - fn from(err: ListDirstateTrackedFilesError) -> Self { - match err { - ListDirstateTrackedFilesError::IoError(err) => { - CommandError::Abort(Some( - utf8_to_local(&format!("abort: {}\n", err)).into(), - )) - } - ListDirstateTrackedFilesError::ParseError(_) => { - CommandError::Abort(Some( - // TODO find a better error message - b"abort: parse error\n".to_vec(), - )) - } - } - } -}