equal
deleted
inserted
replaced
1 use crate::ui::utf8_to_local; |
1 use crate::ui::utf8_to_local; |
2 use crate::ui::UiError; |
2 use crate::ui::UiError; |
3 use hg::errors::{HgError, IoErrorContext}; |
3 use format_bytes::format_bytes; |
4 use hg::operations::FindRootError; |
4 use hg::errors::HgError; |
|
5 use hg::repo::RepoFindError; |
5 use hg::revlog::revlog::RevlogError; |
6 use hg::revlog::revlog::RevlogError; |
|
7 use hg::utils::files::get_bytes_from_path; |
6 use std::convert::From; |
8 use std::convert::From; |
7 |
9 |
8 /// The kind of command error |
10 /// The kind of command error |
9 #[derive(Debug)] |
11 #[derive(Debug)] |
10 pub enum CommandError { |
12 pub enum CommandError { |
46 // too. |
48 // too. |
47 CommandError::abort("") |
49 CommandError::abort("") |
48 } |
50 } |
49 } |
51 } |
50 |
52 |
51 impl From<FindRootError> for CommandError { |
53 impl From<RepoFindError> for CommandError { |
52 fn from(err: FindRootError) -> Self { |
54 fn from(error: RepoFindError) -> Self { |
53 match err { |
55 match error { |
54 FindRootError::RootNotFound(path) => CommandError::abort(format!( |
56 RepoFindError::NotFoundInCurrentDirectoryOrAncestors { |
55 "no repository found in '{}' (.hg not found)!", |
57 current_directory, |
56 path.display() |
58 } => CommandError::Abort { |
57 )), |
59 message: format_bytes!( |
58 FindRootError::GetCurrentDirError(error) => HgError::IoError { |
60 b"no repository found in '{}' (.hg not found)!", |
59 error, |
61 get_bytes_from_path(current_directory) |
60 context: IoErrorContext::CurrentDir, |
62 ), |
61 } |
63 }, |
62 .into(), |
64 RepoFindError::Other(error) => error.into(), |
63 } |
65 } |
64 } |
66 } |
65 } |
67 } |
66 |
68 |
67 impl From<(RevlogError, &str)> for CommandError { |
69 impl From<(RevlogError, &str)> for CommandError { |