diff -r 2e2033081274 -r 252d1bdba33d rust/rhg/src/commands/debugdata.rs --- a/rust/rhg/src/commands/debugdata.rs Tue Jan 26 20:05:37 2021 +0100 +++ b/rust/rhg/src/commands/debugdata.rs Tue Jan 26 20:31:26 2021 +0100 @@ -1,8 +1,7 @@ use crate::commands::Command; use crate::error::CommandError; -use crate::ui::utf8_to_local; use crate::ui::Ui; -use hg::operations::{debug_data, DebugDataError, DebugDataKind}; +use hg::operations::{debug_data, DebugDataKind}; use hg::repo::Repo; use micro_timer::timed; @@ -26,7 +25,7 @@ fn run(&self, ui: &Ui) -> Result<(), CommandError> { let repo = Repo::find()?; let data = debug_data(&repo, self.rev, self.kind) - .map_err(|e| to_command_error(self.rev, e))?; + .map_err(|e| (e, self.rev))?; let mut stdout = ui.stdout_buffer(); stdout.write_all(&data)?; @@ -35,47 +34,3 @@ Ok(()) } } - -/// Convert operation errors to command errors -fn to_command_error(rev: &str, err: DebugDataError) -> CommandError { - match err { - DebugDataError::IoError(err) => CommandError::Abort(Some( - utf8_to_local(&format!("abort: {}\n", err)).into(), - )), - DebugDataError::InvalidRevision => CommandError::Abort(Some( - utf8_to_local(&format!( - "abort: invalid revision identifier{}\n", - rev - )) - .into(), - )), - DebugDataError::AmbiguousPrefix => CommandError::Abort(Some( - utf8_to_local(&format!( - "abort: ambiguous revision identifier{}\n", - rev - )) - .into(), - )), - DebugDataError::UnsuportedRevlogVersion(version) => { - CommandError::Abort(Some( - utf8_to_local(&format!( - "abort: unsupported revlog version {}\n", - version - )) - .into(), - )) - } - DebugDataError::CorruptedRevlog => { - CommandError::Abort(Some("abort: corrupted revlog\n".into())) - } - DebugDataError::UnknowRevlogDataFormat(format) => { - CommandError::Abort(Some( - utf8_to_local(&format!( - "abort: unknow revlog dataformat {:?}\n", - format - )) - .into(), - )) - } - } -}