Show More
@@ -20,9 +20,9 b' use crate::utils::hg_path::{HgPath, HgPa' | |||||
20 |
|
20 | |||
21 | const METADATA_DELIMITER: [u8; 2] = [b'\x01', b'\n']; |
|
21 | const METADATA_DELIMITER: [u8; 2] = [b'\x01', b'\n']; | |
22 |
|
22 | |||
23 | /// Kind of error encountered by `CatRev` |
|
23 | /// Error type for `cat` | |
24 | #[derive(Debug)] |
|
24 | #[derive(Debug)] | |
25 |
pub enum CatRevError |
|
25 | pub enum CatRevError { | |
26 | /// Error when reading a `revlog` file. |
|
26 | /// Error when reading a `revlog` file. | |
27 | IoError(std::io::Error), |
|
27 | IoError(std::io::Error), | |
28 | /// The revision has not been found. |
|
28 | /// The revision has not been found. | |
@@ -37,34 +37,20 b' pub enum CatRevErrorKind {' | |||||
37 | UnknowRevlogDataFormat(u8), |
|
37 | UnknowRevlogDataFormat(u8), | |
38 | } |
|
38 | } | |
39 |
|
39 | |||
40 | /// A `CatRev` error |
|
|||
41 | #[derive(Debug)] |
|
|||
42 | pub struct CatRevError { |
|
|||
43 | /// Kind of error encountered by `CatRev` |
|
|||
44 | pub kind: CatRevErrorKind, |
|
|||
45 | } |
|
|||
46 |
|
||||
47 | impl From<CatRevErrorKind> for CatRevError { |
|
|||
48 | fn from(kind: CatRevErrorKind) -> Self { |
|
|||
49 | CatRevError { kind } |
|
|||
50 | } |
|
|||
51 | } |
|
|||
52 |
|
||||
53 | impl From<RevlogError> for CatRevError { |
|
40 | impl From<RevlogError> for CatRevError { | |
54 | fn from(err: RevlogError) -> Self { |
|
41 | fn from(err: RevlogError) -> Self { | |
55 | match err { |
|
42 | match err { | |
56 |
RevlogError::IoError(err) => CatRevError |
|
43 | RevlogError::IoError(err) => CatRevError::IoError(err), | |
57 | RevlogError::UnsuportedVersion(version) => { |
|
44 | RevlogError::UnsuportedVersion(version) => { | |
58 |
CatRevError |
|
45 | CatRevError::UnsuportedRevlogVersion(version) | |
59 | } |
|
46 | } | |
60 |
RevlogError::InvalidRevision => CatRevError |
|
47 | RevlogError::InvalidRevision => CatRevError::InvalidRevision, | |
61 |
RevlogError::AmbiguousPrefix => CatRevError |
|
48 | RevlogError::AmbiguousPrefix => CatRevError::AmbiguousPrefix, | |
62 |
RevlogError::Corrupted => CatRevError |
|
49 | RevlogError::Corrupted => CatRevError::CorruptedRevlog, | |
63 | RevlogError::UnknowDataFormat(format) => { |
|
50 | RevlogError::UnknowDataFormat(format) => { | |
64 |
CatRevError |
|
51 | CatRevError::UnknowRevlogDataFormat(format) | |
65 | } |
|
52 | } | |
66 | } |
|
53 | } | |
67 | .into() |
|
|||
68 | } |
|
54 | } | |
69 | } |
|
55 | } | |
70 |
|
56 | |||
@@ -83,7 +69,7 b' pub fn cat(' | |||||
83 | let manifest = Manifest::open(repo)?; |
|
69 | let manifest = Manifest::open(repo)?; | |
84 | let changelog_entry = changelog.get_rev(rev)?; |
|
70 | let changelog_entry = changelog.get_rev(rev)?; | |
85 | let manifest_node = Node::from_hex(&changelog_entry.manifest_node()?) |
|
71 | let manifest_node = Node::from_hex(&changelog_entry.manifest_node()?) | |
86 |
.map_err(|_| CatRevError |
|
72 | .map_err(|_| CatRevError::CorruptedRevlog)?; | |
87 | let manifest_entry = manifest.get_node(manifest_node.into())?; |
|
73 | let manifest_entry = manifest.get_node(manifest_node.into())?; | |
88 | let mut bytes = vec![]; |
|
74 | let mut bytes = vec![]; | |
89 |
|
75 | |||
@@ -96,7 +82,7 b' pub fn cat(' | |||||
96 | let file_log = |
|
82 | let file_log = | |
97 | Revlog::open(repo, &index_path, Some(&data_path))?; |
|
83 | Revlog::open(repo, &index_path, Some(&data_path))?; | |
98 | let file_node = Node::from_hex(node_bytes) |
|
84 | let file_node = Node::from_hex(node_bytes) | |
99 |
.map_err(|_| CatRevError |
|
85 | .map_err(|_| CatRevError::CorruptedRevlog)?; | |
100 | let file_rev = file_log.get_node_rev(file_node.into())?; |
|
86 | let file_rev = file_log.get_node_rev(file_node.into())?; | |
101 | let data = file_log.get_rev_data(file_rev)?; |
|
87 | let data = file_log.get_rev_data(file_rev)?; | |
102 | if data.starts_with(&METADATA_DELIMITER) { |
|
88 | if data.starts_with(&METADATA_DELIMITER) { |
@@ -15,9 +15,9 b' pub enum DebugDataKind {' | |||||
15 | Manifest, |
|
15 | Manifest, | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | /// Kind of error encountered by DebugData |
|
18 | /// Error type for `debug_data` | |
19 | #[derive(Debug)] |
|
19 | #[derive(Debug)] | |
20 |
pub enum DebugDataError |
|
20 | pub enum DebugDataError { | |
21 | /// Error when reading a `revlog` file. |
|
21 | /// Error when reading a `revlog` file. | |
22 | IoError(std::io::Error), |
|
22 | IoError(std::io::Error), | |
23 | /// The revision has not been found. |
|
23 | /// The revision has not been found. | |
@@ -32,45 +32,26 b' pub enum DebugDataErrorKind {' | |||||
32 | UnknowRevlogDataFormat(u8), |
|
32 | UnknowRevlogDataFormat(u8), | |
33 | } |
|
33 | } | |
34 |
|
34 | |||
35 | /// A DebugData error |
|
|||
36 | #[derive(Debug)] |
|
|||
37 | pub struct DebugDataError { |
|
|||
38 | /// Kind of error encountered by DebugData |
|
|||
39 | pub kind: DebugDataErrorKind, |
|
|||
40 | } |
|
|||
41 |
|
||||
42 | impl From<DebugDataErrorKind> for DebugDataError { |
|
|||
43 | fn from(kind: DebugDataErrorKind) -> Self { |
|
|||
44 | DebugDataError { kind } |
|
|||
45 | } |
|
|||
46 | } |
|
|||
47 |
|
||||
48 | impl From<std::io::Error> for DebugDataError { |
|
35 | impl From<std::io::Error> for DebugDataError { | |
49 | fn from(err: std::io::Error) -> Self { |
|
36 | fn from(err: std::io::Error) -> Self { | |
50 |
|
|
37 | DebugDataError::IoError(err) | |
51 | DebugDataError { kind } |
|
|||
52 | } |
|
38 | } | |
53 | } |
|
39 | } | |
54 |
|
40 | |||
55 | impl From<RevlogError> for DebugDataError { |
|
41 | impl From<RevlogError> for DebugDataError { | |
56 | fn from(err: RevlogError) -> Self { |
|
42 | fn from(err: RevlogError) -> Self { | |
57 | match err { |
|
43 | match err { | |
58 |
RevlogError::IoError(err) => DebugDataError |
|
44 | RevlogError::IoError(err) => DebugDataError::IoError(err), | |
59 | RevlogError::UnsuportedVersion(version) => { |
|
45 | RevlogError::UnsuportedVersion(version) => { | |
60 |
DebugDataError |
|
46 | DebugDataError::UnsuportedRevlogVersion(version) | |
61 | } |
|
|||
62 | RevlogError::InvalidRevision => { |
|
|||
63 | DebugDataErrorKind::InvalidRevision |
|
|||
64 | } |
|
47 | } | |
65 | RevlogError::AmbiguousPrefix => { |
|
48 | RevlogError::InvalidRevision => DebugDataError::InvalidRevision, | |
66 | DebugDataErrorKind::AmbiguousPrefix |
|
49 | RevlogError::AmbiguousPrefix => DebugDataError::AmbiguousPrefix, | |
67 | } |
|
50 | RevlogError::Corrupted => DebugDataError::CorruptedRevlog, | |
68 | RevlogError::Corrupted => DebugDataErrorKind::CorruptedRevlog, |
|
|||
69 | RevlogError::UnknowDataFormat(format) => { |
|
51 | RevlogError::UnknowDataFormat(format) => { | |
70 |
DebugDataError |
|
52 | DebugDataError::UnknowRevlogDataFormat(format) | |
71 | } |
|
53 | } | |
72 | } |
|
54 | } | |
73 | .into() |
|
|||
74 | } |
|
55 | } | |
75 | } |
|
56 | } | |
76 |
|
57 |
@@ -1,9 +1,8 b'' | |||||
1 | use std::fmt; |
|
|||
2 |
|
|
1 | use std::path::{Path, PathBuf}; | |
3 |
|
2 | |||
4 | /// Kind of error encoutered by FindRoot |
|
3 | /// Error type for `find_root` | |
5 | #[derive(Debug)] |
|
4 | #[derive(Debug)] | |
6 |
pub enum FindRootError |
|
5 | pub enum FindRootError { | |
7 | /// Root of the repository has not been found |
|
6 | /// Root of the repository has not been found | |
8 | /// Contains the current directory used by FindRoot |
|
7 | /// Contains the current directory used by FindRoot | |
9 | RootNotFound(PathBuf), |
|
8 | RootNotFound(PathBuf), | |
@@ -12,28 +11,12 b' pub enum FindRootErrorKind {' | |||||
12 | GetCurrentDirError(std::io::Error), |
|
11 | GetCurrentDirError(std::io::Error), | |
13 | } |
|
12 | } | |
14 |
|
13 | |||
15 | /// A FindRoot error |
|
|||
16 | #[derive(Debug)] |
|
|||
17 | pub struct FindRootError { |
|
|||
18 | /// Kind of error encoutered by FindRoot |
|
|||
19 | pub kind: FindRootErrorKind, |
|
|||
20 | } |
|
|||
21 |
|
||||
22 | impl std::error::Error for FindRootError {} |
|
|||
23 |
|
||||
24 | impl fmt::Display for FindRootError { |
|
|||
25 | fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { |
|
|||
26 | unimplemented!() |
|
|||
27 | } |
|
|||
28 | } |
|
|||
29 |
|
||||
30 | /// Find the root of the repository |
|
14 | /// Find the root of the repository | |
31 | /// by searching for a .hg directory in the processβ current directory and its |
|
15 | /// by searching for a .hg directory in the processβ current directory and its | |
32 | /// ancestors |
|
16 | /// ancestors | |
33 | pub fn find_root() -> Result<PathBuf, FindRootError> { |
|
17 | pub fn find_root() -> Result<PathBuf, FindRootError> { | |
34 |
let current_dir = std::env::current_dir() |
|
18 | let current_dir = std::env::current_dir() | |
35 |
|
|
19 | .map_err(|e| FindRootError::GetCurrentDirError(e))?; | |
36 | })?; |
|
|||
37 | Ok(find_root_from_path(¤t_dir)?.into()) |
|
20 | Ok(find_root_from_path(¤t_dir)?.into()) | |
38 | } |
|
21 | } | |
39 |
|
22 | |||
@@ -48,9 +31,7 b' pub fn find_root_from_path(start: &Path)' | |||||
48 | return Ok(ancestor); |
|
31 | return Ok(ancestor); | |
49 | } |
|
32 | } | |
50 | } |
|
33 | } | |
51 | Err(FindRootError { |
|
34 | Err(FindRootError::RootNotFound(start.into())) | |
52 | kind: FindRootErrorKind::RootNotFound(start.into()), |
|
|||
53 | }) |
|
|||
54 | } |
|
35 | } | |
55 |
|
36 | |||
56 | #[cfg(test)] |
|
37 | #[cfg(test)] | |
@@ -68,10 +49,8 b' mod tests {' | |||||
68 |
|
49 | |||
69 | // TODO do something better |
|
50 | // TODO do something better | |
70 | assert!(match err { |
|
51 | assert!(match err { | |
71 | FindRootError { kind } => match kind { |
|
52 | FindRootError::RootNotFound(p) => p == path.to_path_buf(), | |
72 | FindRootErrorKind::RootNotFound(p) => p == path.to_path_buf(), |
|
53 | _ => false, | |
73 | _ => false, |
|
|||
74 | }, |
|
|||
75 | }) |
|
54 | }) | |
76 | } |
|
55 | } | |
77 |
|
56 |
@@ -16,34 +16,18 b' use crate::{DirstateParseError, EntrySta' | |||||
16 | use rayon::prelude::*; |
|
16 | use rayon::prelude::*; | |
17 | use std::convert::From; |
|
17 | use std::convert::From; | |
18 |
|
18 | |||
19 | /// Kind of error encountered by `ListDirstateTrackedFiles` |
|
19 | /// Error type for `Dirstate` methods | |
20 | #[derive(Debug)] |
|
20 | #[derive(Debug)] | |
21 |
pub enum ListDirstateTrackedFilesError |
|
21 | pub enum ListDirstateTrackedFilesError { | |
22 | /// Error when reading the `dirstate` file |
|
22 | /// Error when reading the `dirstate` file | |
23 | IoError(std::io::Error), |
|
23 | IoError(std::io::Error), | |
24 | /// Error when parsing the `dirstate` file |
|
24 | /// Error when parsing the `dirstate` file | |
25 | ParseError(DirstateParseError), |
|
25 | ParseError(DirstateParseError), | |
26 | } |
|
26 | } | |
27 |
|
27 | |||
28 | /// A `ListDirstateTrackedFiles` error |
|
|||
29 | #[derive(Debug)] |
|
|||
30 | pub struct ListDirstateTrackedFilesError { |
|
|||
31 | /// Kind of error encountered by `ListDirstateTrackedFiles` |
|
|||
32 | pub kind: ListDirstateTrackedFilesErrorKind, |
|
|||
33 | } |
|
|||
34 |
|
||||
35 | impl From<ListDirstateTrackedFilesErrorKind> |
|
|||
36 | for ListDirstateTrackedFilesError |
|
|||
37 | { |
|
|||
38 | fn from(kind: ListDirstateTrackedFilesErrorKind) -> Self { |
|
|||
39 | ListDirstateTrackedFilesError { kind } |
|
|||
40 | } |
|
|||
41 | } |
|
|||
42 |
|
||||
43 | impl From<std::io::Error> for ListDirstateTrackedFilesError { |
|
28 | impl From<std::io::Error> for ListDirstateTrackedFilesError { | |
44 | fn from(err: std::io::Error) -> Self { |
|
29 | fn from(err: std::io::Error) -> Self { | |
45 |
|
|
30 | ListDirstateTrackedFilesError::IoError(err) | |
46 | ListDirstateTrackedFilesError { kind } |
|
|||
47 | } |
|
31 | } | |
48 | } |
|
32 | } | |
49 |
|
33 | |||
@@ -64,7 +48,7 b' impl Dirstate {' | |||||
64 | &self, |
|
48 | &self, | |
65 | ) -> Result<Vec<&HgPath>, ListDirstateTrackedFilesError> { |
|
49 | ) -> Result<Vec<&HgPath>, ListDirstateTrackedFilesError> { | |
66 | let (_, entries, _) = parse_dirstate(&self.content) |
|
50 | let (_, entries, _) = parse_dirstate(&self.content) | |
67 |
.map_err(ListDirstateTrackedFilesError |
|
51 | .map_err(ListDirstateTrackedFilesError::ParseError)?; | |
68 | let mut files: Vec<&HgPath> = entries |
|
52 | let mut files: Vec<&HgPath> = entries | |
69 | .into_iter() |
|
53 | .into_iter() | |
70 | .filter_map(|(path, entry)| match entry.state { |
|
54 | .filter_map(|(path, entry)| match entry.state { | |
@@ -77,9 +61,9 b' impl Dirstate {' | |||||
77 | } |
|
61 | } | |
78 | } |
|
62 | } | |
79 |
|
63 | |||
80 |
/// |
|
64 | /// Error type `list_rev_tracked_files` | |
81 | #[derive(Debug)] |
|
65 | #[derive(Debug)] | |
82 |
pub enum ListRevTrackedFilesError |
|
66 | pub enum ListRevTrackedFilesError { | |
83 | /// Error when reading a `revlog` file. |
|
67 | /// Error when reading a `revlog` file. | |
84 | IoError(std::io::Error), |
|
68 | IoError(std::io::Error), | |
85 | /// The revision has not been found. |
|
69 | /// The revision has not been found. | |
@@ -94,42 +78,28 b' pub enum ListRevTrackedFilesErrorKind {' | |||||
94 | UnknowRevlogDataFormat(u8), |
|
78 | UnknowRevlogDataFormat(u8), | |
95 | } |
|
79 | } | |
96 |
|
80 | |||
97 | /// A `ListRevTrackedFiles` error |
|
|||
98 | #[derive(Debug)] |
|
|||
99 | pub struct ListRevTrackedFilesError { |
|
|||
100 | /// Kind of error encountered by `ListRevTrackedFiles` |
|
|||
101 | pub kind: ListRevTrackedFilesErrorKind, |
|
|||
102 | } |
|
|||
103 |
|
||||
104 | impl From<ListRevTrackedFilesErrorKind> for ListRevTrackedFilesError { |
|
|||
105 | fn from(kind: ListRevTrackedFilesErrorKind) -> Self { |
|
|||
106 | ListRevTrackedFilesError { kind } |
|
|||
107 | } |
|
|||
108 | } |
|
|||
109 |
|
||||
110 | impl From<RevlogError> for ListRevTrackedFilesError { |
|
81 | impl From<RevlogError> for ListRevTrackedFilesError { | |
111 | fn from(err: RevlogError) -> Self { |
|
82 | fn from(err: RevlogError) -> Self { | |
112 | match err { |
|
83 | match err { | |
113 | RevlogError::IoError(err) => { |
|
84 | RevlogError::IoError(err) => { | |
114 |
ListRevTrackedFilesError |
|
85 | ListRevTrackedFilesError::IoError(err) | |
115 | } |
|
86 | } | |
116 | RevlogError::UnsuportedVersion(version) => { |
|
87 | RevlogError::UnsuportedVersion(version) => { | |
117 |
ListRevTrackedFilesError |
|
88 | ListRevTrackedFilesError::UnsuportedRevlogVersion(version) | |
118 | } |
|
89 | } | |
119 | RevlogError::InvalidRevision => { |
|
90 | RevlogError::InvalidRevision => { | |
120 |
ListRevTrackedFilesError |
|
91 | ListRevTrackedFilesError::InvalidRevision | |
121 | } |
|
92 | } | |
122 | RevlogError::AmbiguousPrefix => { |
|
93 | RevlogError::AmbiguousPrefix => { | |
123 |
ListRevTrackedFilesError |
|
94 | ListRevTrackedFilesError::AmbiguousPrefix | |
124 | } |
|
95 | } | |
125 | RevlogError::Corrupted => { |
|
96 | RevlogError::Corrupted => { | |
126 |
ListRevTrackedFilesError |
|
97 | ListRevTrackedFilesError::CorruptedRevlog | |
127 | } |
|
98 | } | |
128 | RevlogError::UnknowDataFormat(format) => { |
|
99 | RevlogError::UnknowDataFormat(format) => { | |
129 |
ListRevTrackedFilesError |
|
100 | ListRevTrackedFilesError::UnknowRevlogDataFormat(format) | |
130 | } |
|
101 | } | |
131 | } |
|
102 | } | |
132 | .into() |
|
|||
133 | } |
|
103 | } | |
134 | } |
|
104 | } | |
135 |
|
105 | |||
@@ -143,7 +113,7 b' pub fn list_rev_tracked_files(' | |||||
143 | let manifest = Manifest::open(repo)?; |
|
113 | let manifest = Manifest::open(repo)?; | |
144 | let changelog_entry = changelog.get_rev(rev)?; |
|
114 | let changelog_entry = changelog.get_rev(rev)?; | |
145 | let manifest_node = Node::from_hex(&changelog_entry.manifest_node()?) |
|
115 | let manifest_node = Node::from_hex(&changelog_entry.manifest_node()?) | |
146 |
.or(Err(ListRevTrackedFilesError |
|
116 | .or(Err(ListRevTrackedFilesError::CorruptedRevlog))?; | |
147 | let manifest_entry = manifest.get_node(manifest_node.into())?; |
|
117 | let manifest_entry = manifest.get_node(manifest_node.into())?; | |
148 | Ok(FilesForRev(manifest_entry)) |
|
118 | Ok(FilesForRev(manifest_entry)) | |
149 | } |
|
119 | } |
@@ -7,17 +7,10 b' mod debugdata;' | |||||
7 | mod dirstate_status; |
|
7 | mod dirstate_status; | |
8 | mod find_root; |
|
8 | mod find_root; | |
9 | mod list_tracked_files; |
|
9 | mod list_tracked_files; | |
10 |
pub use cat::{cat, CatRevError |
|
10 | pub use cat::{cat, CatRevError}; | |
11 | pub use debugdata::{ |
|
11 | pub use debugdata::{debug_data, DebugDataError, DebugDataKind}; | |
12 | debug_data, DebugDataError, DebugDataErrorKind, DebugDataKind, |
|
12 | pub use find_root::{find_root, find_root_from_path, FindRootError}; | |
13 | }; |
|
|||
14 | pub use find_root::{ |
|
|||
15 | find_root, find_root_from_path, FindRootError, FindRootErrorKind, |
|
|||
16 | }; |
|
|||
17 | pub use list_tracked_files::{ |
|
13 | pub use list_tracked_files::{ | |
18 | list_rev_tracked_files, FilesForRev, ListRevTrackedFilesError, |
|
14 | list_rev_tracked_files, FilesForRev, ListRevTrackedFilesError, | |
19 | ListRevTrackedFilesErrorKind, |
|
|||
20 | }; |
|
15 | }; | |
21 | pub use list_tracked_files::{ |
|
16 | pub use list_tracked_files::{Dirstate, ListDirstateTrackedFilesError}; | |
22 | Dirstate, ListDirstateTrackedFilesError, ListDirstateTrackedFilesErrorKind, |
|
|||
23 | }; |
|
@@ -1,8 +1,8 b'' | |||||
1 | use crate::commands::Command; |
|
1 | use crate::commands::Command; | |
2 |
use crate::error:: |
|
2 | use crate::error::CommandError; | |
3 | use crate::ui::utf8_to_local; |
|
3 | use crate::ui::utf8_to_local; | |
4 | use crate::ui::Ui; |
|
4 | use crate::ui::Ui; | |
5 |
use hg::operations::{cat, CatRevError |
|
5 | use hg::operations::{cat, CatRevError}; | |
6 | use hg::repo::Repo; |
|
6 | use hg::repo::Repo; | |
7 | use hg::utils::hg_path::HgPathBuf; |
|
7 | use hg::utils::hg_path::HgPathBuf; | |
8 | use micro_timer::timed; |
|
8 | use micro_timer::timed; | |
@@ -34,16 +34,16 b" impl<'a> Command for CatCommand<'a> {" | |||||
34 | let repo = Repo::find()?; |
|
34 | let repo = Repo::find()?; | |
35 | repo.check_requirements()?; |
|
35 | repo.check_requirements()?; | |
36 | let cwd = std::env::current_dir() |
|
36 | let cwd = std::env::current_dir() | |
37 |
.or_else(|e| Err(CommandError |
|
37 | .or_else(|e| Err(CommandError::CurrentDirNotFound(e)))?; | |
38 |
|
38 | |||
39 | let mut files = vec![]; |
|
39 | let mut files = vec![]; | |
40 | for file in self.files.iter() { |
|
40 | for file in self.files.iter() { | |
41 | let normalized = cwd.join(&file); |
|
41 | let normalized = cwd.join(&file); | |
42 | let stripped = normalized |
|
42 | let stripped = normalized | |
43 | .strip_prefix(&repo.working_directory_path()) |
|
43 | .strip_prefix(&repo.working_directory_path()) | |
44 |
.or(Err(CommandError |
|
44 | .or(Err(CommandError::Abort(None)))?; | |
45 | let hg_file = HgPathBuf::try_from(stripped.to_path_buf()) |
|
45 | let hg_file = HgPathBuf::try_from(stripped.to_path_buf()) | |
46 |
.or(Err(CommandError |
|
46 | .or(Err(CommandError::Abort(None)))?; | |
47 | files.push(hg_file); |
|
47 | files.push(hg_file); | |
48 | } |
|
48 | } | |
49 |
|
49 | |||
@@ -53,53 +53,51 b" impl<'a> Command for CatCommand<'a> {" | |||||
53 | .map_err(|e| map_rev_error(rev, e))?; |
|
53 | .map_err(|e| map_rev_error(rev, e))?; | |
54 | self.display(ui, &data) |
|
54 | self.display(ui, &data) | |
55 | } |
|
55 | } | |
56 |
None => Err(CommandError |
|
56 | None => Err(CommandError::Unimplemented.into()), | |
57 | } |
|
57 | } | |
58 | } |
|
58 | } | |
59 | } |
|
59 | } | |
60 |
|
60 | |||
61 |
/// Convert `CatRevError |
|
61 | /// Convert `CatRevError` to `CommandError` | |
62 | fn map_rev_error(rev: &str, err: CatRevError) -> CommandError { |
|
62 | fn map_rev_error(rev: &str, err: CatRevError) -> CommandError { | |
63 |
|
|
63 | match err { | |
64 | kind: match err.kind { |
|
64 | CatRevError::IoError(err) => CommandError::Abort(Some( | |
65 | CatRevErrorKind::IoError(err) => CommandErrorKind::Abort(Some( |
|
65 | utf8_to_local(&format!("abort: {}\n", err)).into(), | |
66 | utf8_to_local(&format!("abort: {}\n", err)).into(), |
|
66 | )), | |
67 | )), |
|
67 | CatRevError::InvalidRevision => CommandError::Abort(Some( | |
68 | CatRevErrorKind::InvalidRevision => CommandErrorKind::Abort(Some( |
|
68 | utf8_to_local(&format!( | |
|
69 | "abort: invalid revision identifier {}\n", | |||
|
70 | rev | |||
|
71 | )) | |||
|
72 | .into(), | |||
|
73 | )), | |||
|
74 | CatRevError::AmbiguousPrefix => CommandError::Abort(Some( | |||
|
75 | utf8_to_local(&format!( | |||
|
76 | "abort: ambiguous revision identifier {}\n", | |||
|
77 | rev | |||
|
78 | )) | |||
|
79 | .into(), | |||
|
80 | )), | |||
|
81 | CatRevError::UnsuportedRevlogVersion(version) => { | |||
|
82 | CommandError::Abort(Some( | |||
69 | utf8_to_local(&format!( |
|
83 | utf8_to_local(&format!( | |
70 |
"abort: |
|
84 | "abort: unsupported revlog version {}\n", | |
71 |
|
|
85 | version | |
72 | )) |
|
|||
73 | .into(), |
|
|||
74 | )), |
|
|||
75 | CatRevErrorKind::AmbiguousPrefix => CommandErrorKind::Abort(Some( |
|
|||
76 | utf8_to_local(&format!( |
|
|||
77 | "abort: ambiguous revision identifier {}\n", |
|
|||
78 | rev |
|
|||
79 | )) |
|
86 | )) | |
80 | .into(), |
|
87 | .into(), | |
81 |
)) |
|
88 | )) | |
82 | CatRevErrorKind::UnsuportedRevlogVersion(version) => { |
|
89 | } | |
83 | CommandErrorKind::Abort(Some( |
|
90 | CatRevError::CorruptedRevlog => { | |
84 | utf8_to_local(&format!( |
|
91 | CommandError::Abort(Some("abort: corrupted revlog\n".into())) | |
85 | "abort: unsupported revlog version {}\n", |
|
92 | } | |
86 | version |
|
93 | CatRevError::UnknowRevlogDataFormat(format) => { | |
87 | )) |
|
94 | CommandError::Abort(Some( | |
88 | .into(), |
|
95 | utf8_to_local(&format!( | |
|
96 | "abort: unknow revlog dataformat {:?}\n", | |||
|
97 | format | |||
89 | )) |
|
98 | )) | |
90 |
|
|
99 | .into(), | |
91 | CatRevErrorKind::CorruptedRevlog => CommandErrorKind::Abort(Some( |
|
100 | )) | |
92 | "abort: corrupted revlog\n".into(), |
|
101 | } | |
93 | )), |
|
|||
94 | CatRevErrorKind::UnknowRevlogDataFormat(format) => { |
|
|||
95 | CommandErrorKind::Abort(Some( |
|
|||
96 | utf8_to_local(&format!( |
|
|||
97 | "abort: unknow revlog dataformat {:?}\n", |
|
|||
98 | format |
|
|||
99 | )) |
|
|||
100 | .into(), |
|
|||
101 | )) |
|
|||
102 | } |
|
|||
103 | }, |
|
|||
104 | } |
|
102 | } | |
105 | } |
|
103 | } |
@@ -1,10 +1,8 b'' | |||||
1 | use crate::commands::Command; |
|
1 | use crate::commands::Command; | |
2 |
use crate::error:: |
|
2 | use crate::error::CommandError; | |
3 | use crate::ui::utf8_to_local; |
|
3 | use crate::ui::utf8_to_local; | |
4 | use crate::ui::Ui; |
|
4 | use crate::ui::Ui; | |
5 | use hg::operations::{ |
|
5 | use hg::operations::{debug_data, DebugDataError, DebugDataKind}; | |
6 | debug_data, DebugDataError, DebugDataErrorKind, DebugDataKind, |
|
|||
7 | }; |
|
|||
8 | use hg::repo::Repo; |
|
6 | use hg::repo::Repo; | |
9 | use micro_timer::timed; |
|
7 | use micro_timer::timed; | |
10 |
|
8 | |||
@@ -40,52 +38,44 b" impl<'a> Command for DebugDataCommand<'a" | |||||
40 |
|
38 | |||
41 | /// Convert operation errors to command errors |
|
39 | /// Convert operation errors to command errors | |
42 | fn to_command_error(rev: &str, err: DebugDataError) -> CommandError { |
|
40 | fn to_command_error(rev: &str, err: DebugDataError) -> CommandError { | |
43 |
match err |
|
41 | match err { | |
44 |
DebugDataError |
|
42 | DebugDataError::IoError(err) => CommandError::Abort(Some( | |
45 | kind: CommandErrorKind::Abort(Some( |
|
43 | utf8_to_local(&format!("abort: {}\n", err)).into(), | |
46 | utf8_to_local(&format!("abort: {}\n", err)).into(), |
|
44 | )), | |
47 | )), |
|
45 | DebugDataError::InvalidRevision => CommandError::Abort(Some( | |
48 | }, |
|
46 | utf8_to_local(&format!( | |
49 | DebugDataErrorKind::InvalidRevision => CommandError { |
|
47 | "abort: invalid revision identifier{}\n", | |
50 | kind: CommandErrorKind::Abort(Some( |
|
48 | rev | |
51 | utf8_to_local(&format!( |
|
49 | )) | |
52 | "abort: invalid revision identifier{}\n", |
|
50 | .into(), | |
53 | rev |
|
51 | )), | |
54 | )) |
|
52 | DebugDataError::AmbiguousPrefix => CommandError::Abort(Some( | |
55 | .into(), |
|
53 | utf8_to_local(&format!( | |
56 | )), |
|
54 | "abort: ambiguous revision identifier{}\n", | |
57 | }, |
|
55 | rev | |
58 | DebugDataErrorKind::AmbiguousPrefix => CommandError { |
|
56 | )) | |
59 | kind: CommandErrorKind::Abort(Some( |
|
57 | .into(), | |
60 | utf8_to_local(&format!( |
|
58 | )), | |
61 | "abort: ambiguous revision identifier{}\n", |
|
59 | DebugDataError::UnsuportedRevlogVersion(version) => { | |
62 | rev |
|
60 | CommandError::Abort(Some( | |
63 | )) |
|
|||
64 | .into(), |
|
|||
65 | )), |
|
|||
66 | }, |
|
|||
67 | DebugDataErrorKind::UnsuportedRevlogVersion(version) => CommandError { |
|
|||
68 | kind: CommandErrorKind::Abort(Some( |
|
|||
69 | utf8_to_local(&format!( |
|
61 | utf8_to_local(&format!( | |
70 | "abort: unsupported revlog version {}\n", |
|
62 | "abort: unsupported revlog version {}\n", | |
71 | version |
|
63 | version | |
72 | )) |
|
64 | )) | |
73 | .into(), |
|
65 | .into(), | |
74 |
)) |
|
66 | )) | |
75 |
} |
|
67 | } | |
76 |
DebugDataError |
|
68 | DebugDataError::CorruptedRevlog => { | |
77 |
|
|
69 | CommandError::Abort(Some("abort: corrupted revlog\n".into())) | |
78 | "abort: corrupted revlog\n".into(), |
|
70 | } | |
79 | )), |
|
71 | DebugDataError::UnknowRevlogDataFormat(format) => { | |
80 | }, |
|
72 | CommandError::Abort(Some( | |
81 | DebugDataErrorKind::UnknowRevlogDataFormat(format) => CommandError { |
|
|||
82 | kind: CommandErrorKind::Abort(Some( |
|
|||
83 | utf8_to_local(&format!( |
|
73 | utf8_to_local(&format!( | |
84 | "abort: unknow revlog dataformat {:?}\n", |
|
74 | "abort: unknow revlog dataformat {:?}\n", | |
85 | format |
|
75 | format | |
86 | )) |
|
76 | )) | |
87 | .into(), |
|
77 | .into(), | |
88 |
)) |
|
78 | )) | |
89 |
} |
|
79 | } | |
90 | } |
|
80 | } | |
91 | } |
|
81 | } |
@@ -1,14 +1,9 b'' | |||||
1 | use crate::commands::Command; |
|
1 | use crate::commands::Command; | |
2 |
use crate::error:: |
|
2 | use crate::error::CommandError; | |
3 | use crate::ui::utf8_to_local; |
|
3 | use crate::ui::utf8_to_local; | |
4 | use crate::ui::Ui; |
|
4 | use crate::ui::Ui; | |
5 | use hg::operations::{ |
|
5 | use hg::operations::{list_rev_tracked_files, ListRevTrackedFilesError}; | |
6 | list_rev_tracked_files, ListRevTrackedFilesError, |
|
6 | use hg::operations::{Dirstate, ListDirstateTrackedFilesError}; | |
7 | ListRevTrackedFilesErrorKind, |
|
|||
8 | }; |
|
|||
9 | use hg::operations::{ |
|
|||
10 | Dirstate, ListDirstateTrackedFilesError, ListDirstateTrackedFilesErrorKind, |
|
|||
11 | }; |
|
|||
12 | use hg::repo::Repo; |
|
7 | use hg::repo::Repo; | |
13 | use hg::utils::files::{get_bytes_from_path, relativize_path}; |
|
8 | use hg::utils::files::{get_bytes_from_path, relativize_path}; | |
14 | use hg::utils::hg_path::{HgPath, HgPathBuf}; |
|
9 | use hg::utils::hg_path::{HgPath, HgPathBuf}; | |
@@ -35,7 +30,7 b" impl<'a> FilesCommand<'a> {" | |||||
35 | files: impl IntoIterator<Item = &'a HgPath>, |
|
30 | files: impl IntoIterator<Item = &'a HgPath>, | |
36 | ) -> Result<(), CommandError> { |
|
31 | ) -> Result<(), CommandError> { | |
37 | let cwd = std::env::current_dir() |
|
32 | let cwd = std::env::current_dir() | |
38 |
.or_else(|e| Err(CommandError |
|
33 | .or_else(|e| Err(CommandError::CurrentDirNotFound(e)))?; | |
39 | let rooted_cwd = cwd |
|
34 | let rooted_cwd = cwd | |
40 | .strip_prefix(repo.working_directory_path()) |
|
35 | .strip_prefix(repo.working_directory_path()) | |
41 | .expect("cwd was already checked within the repository"); |
|
36 | .expect("cwd was already checked within the repository"); | |
@@ -68,75 +63,65 b" impl<'a> Command for FilesCommand<'a> {" | |||||
68 | } |
|
63 | } | |
69 | } |
|
64 | } | |
70 |
|
65 | |||
71 |
/// Convert `ListRevTrackedFilesError |
|
66 | /// Convert `ListRevTrackedFilesError` to `CommandError` | |
72 | fn map_rev_error(rev: &str, err: ListRevTrackedFilesError) -> CommandError { |
|
67 | fn map_rev_error(rev: &str, err: ListRevTrackedFilesError) -> CommandError { | |
73 |
|
|
68 | match err { | |
74 | kind: match err.kind { |
|
69 | ListRevTrackedFilesError::IoError(err) => CommandError::Abort(Some( | |
75 | ListRevTrackedFilesErrorKind::IoError(err) => { |
|
70 | utf8_to_local(&format!("abort: {}\n", err)).into(), | |
76 | CommandErrorKind::Abort(Some( |
|
71 | )), | |
77 | utf8_to_local(&format!("abort: {}\n", err)).into(), |
|
72 | ListRevTrackedFilesError::InvalidRevision => { | |
|
73 | CommandError::Abort(Some( | |||
|
74 | utf8_to_local(&format!( | |||
|
75 | "abort: invalid revision identifier {}\n", | |||
|
76 | rev | |||
78 | )) |
|
77 | )) | |
79 |
|
|
78 | .into(), | |
80 | ListRevTrackedFilesErrorKind::InvalidRevision => { |
|
79 | )) | |
81 | CommandErrorKind::Abort(Some( |
|
80 | } | |
82 | utf8_to_local(&format!( |
|
81 | ListRevTrackedFilesError::AmbiguousPrefix => { | |
83 | "abort: invalid revision identifier {}\n", |
|
82 | CommandError::Abort(Some( | |
84 | rev |
|
83 | utf8_to_local(&format!( | |
85 | )) |
|
84 | "abort: ambiguous revision identifier {}\n", | |
86 |
|
|
85 | rev | |
87 | )) |
|
|||
88 | } |
|
|||
89 | ListRevTrackedFilesErrorKind::AmbiguousPrefix => { |
|
|||
90 | CommandErrorKind::Abort(Some( |
|
|||
91 | utf8_to_local(&format!( |
|
|||
92 | "abort: ambiguous revision identifier {}\n", |
|
|||
93 | rev |
|
|||
94 | )) |
|
|||
95 | .into(), |
|
|||
96 | )) |
|
86 | )) | |
97 |
|
|
87 | .into(), | |
98 | ListRevTrackedFilesErrorKind::UnsuportedRevlogVersion(version) => { |
|
88 | )) | |
99 | CommandErrorKind::Abort(Some( |
|
89 | } | |
100 | utf8_to_local(&format!( |
|
90 | ListRevTrackedFilesError::UnsuportedRevlogVersion(version) => { | |
101 | "abort: unsupported revlog version {}\n", |
|
91 | CommandError::Abort(Some( | |
102 | version |
|
92 | utf8_to_local(&format!( | |
103 | )) |
|
93 | "abort: unsupported revlog version {}\n", | |
104 |
|
|
94 | version | |
105 | )) |
|
95 | )) | |
106 |
|
|
96 | .into(), | |
107 | ListRevTrackedFilesErrorKind::CorruptedRevlog => { |
|
97 | )) | |
108 | CommandErrorKind::Abort(Some( |
|
98 | } | |
109 | "abort: corrupted revlog\n".into(), |
|
99 | ListRevTrackedFilesError::CorruptedRevlog => { | |
|
100 | CommandError::Abort(Some("abort: corrupted revlog\n".into())) | |||
|
101 | } | |||
|
102 | ListRevTrackedFilesError::UnknowRevlogDataFormat(format) => { | |||
|
103 | CommandError::Abort(Some( | |||
|
104 | utf8_to_local(&format!( | |||
|
105 | "abort: unknow revlog dataformat {:?}\n", | |||
|
106 | format | |||
110 | )) |
|
107 | )) | |
111 |
|
|
108 | .into(), | |
112 | ListRevTrackedFilesErrorKind::UnknowRevlogDataFormat(format) => { |
|
109 | )) | |
113 | CommandErrorKind::Abort(Some( |
|
110 | } | |
114 | utf8_to_local(&format!( |
|
|||
115 | "abort: unknow revlog dataformat {:?}\n", |
|
|||
116 | format |
|
|||
117 | )) |
|
|||
118 | .into(), |
|
|||
119 | )) |
|
|||
120 | } |
|
|||
121 | }, |
|
|||
122 | } |
|
111 | } | |
123 | } |
|
112 | } | |
124 |
|
113 | |||
125 | /// Convert `ListDirstateTrackedFilesError` to `CommandError` |
|
114 | /// Convert `ListDirstateTrackedFilesError` to `CommandError` | |
126 | fn map_dirstate_error(err: ListDirstateTrackedFilesError) -> CommandError { |
|
115 | fn map_dirstate_error(err: ListDirstateTrackedFilesError) -> CommandError { | |
127 |
|
|
116 | match err { | |
128 | kind: match err.kind { |
|
117 | ListDirstateTrackedFilesError::IoError(err) => CommandError::Abort( | |
129 | ListDirstateTrackedFilesErrorKind::IoError(err) => { |
|
118 | Some(utf8_to_local(&format!("abort: {}\n", err)).into()), | |
130 | CommandErrorKind::Abort(Some( |
|
119 | ), | |
131 | utf8_to_local(&format!("abort: {}\n", err)).into(), |
|
120 | ListDirstateTrackedFilesError::ParseError(_) => { | |
132 | )) |
|
121 | CommandError::Abort(Some( | |
133 | } |
|
122 | // TODO find a better error message | |
134 | ListDirstateTrackedFilesErrorKind::ParseError(_) => { |
|
123 | b"abort: parse error\n".to_vec(), | |
135 | CommandErrorKind::Abort(Some( |
|
124 | )) | |
136 | // TODO find a better error message |
|
125 | } | |
137 | b"abort: parse error\n".to_vec(), |
|
|||
138 | )) |
|
|||
139 | } |
|
|||
140 | }, |
|
|||
141 | } |
|
126 | } | |
142 | } |
|
127 | } |
@@ -1,7 +1,7 b'' | |||||
1 | use crate::exitcode; |
|
1 | use crate::exitcode; | |
2 | use crate::ui::UiError; |
|
2 | use crate::ui::UiError; | |
3 | use format_bytes::format_bytes; |
|
3 | use format_bytes::format_bytes; | |
4 |
use hg::operations:: |
|
4 | use hg::operations::FindRootError; | |
5 | use hg::requirements::RequirementsError; |
|
5 | use hg::requirements::RequirementsError; | |
6 | use hg::utils::files::get_bytes_from_path; |
|
6 | use hg::utils::files::get_bytes_from_path; | |
7 | use std::convert::From; |
|
7 | use std::convert::From; | |
@@ -9,7 +9,7 b' use std::path::PathBuf;' | |||||
9 |
|
9 | |||
10 | /// The kind of command error |
|
10 | /// The kind of command error | |
11 | #[derive(Debug)] |
|
11 | #[derive(Debug)] | |
12 |
pub enum CommandError |
|
12 | pub enum CommandError { | |
13 | /// The root of the repository cannot be found |
|
13 | /// The root of the repository cannot be found | |
14 | RootNotFound(PathBuf), |
|
14 | RootNotFound(PathBuf), | |
15 | /// The current directory cannot be found |
|
15 | /// The current directory cannot be found | |
@@ -26,99 +26,76 b' pub enum CommandErrorKind {' | |||||
26 | Unimplemented, |
|
26 | Unimplemented, | |
27 | } |
|
27 | } | |
28 |
|
28 | |||
29 |
impl CommandError |
|
29 | impl CommandError { | |
30 | pub fn get_exit_code(&self) -> exitcode::ExitCode { |
|
30 | pub fn get_exit_code(&self) -> exitcode::ExitCode { | |
31 | match self { |
|
31 | match self { | |
32 |
CommandError |
|
32 | CommandError::RootNotFound(_) => exitcode::ABORT, | |
33 |
CommandError |
|
33 | CommandError::CurrentDirNotFound(_) => exitcode::ABORT, | |
34 |
CommandError |
|
34 | CommandError::RequirementsError( | |
35 | RequirementsError::Unsupported { .. }, |
|
35 | RequirementsError::Unsupported { .. }, | |
36 | ) => exitcode::UNIMPLEMENTED_COMMAND, |
|
36 | ) => exitcode::UNIMPLEMENTED_COMMAND, | |
37 |
CommandError |
|
37 | CommandError::RequirementsError(_) => exitcode::ABORT, | |
38 |
CommandError |
|
38 | CommandError::StdoutError => exitcode::ABORT, | |
39 |
CommandError |
|
39 | CommandError::StderrError => exitcode::ABORT, | |
40 |
CommandError |
|
40 | CommandError::Abort(_) => exitcode::ABORT, | |
41 |
CommandError |
|
41 | CommandError::Unimplemented => exitcode::UNIMPLEMENTED_COMMAND, | |
42 | } |
|
42 | } | |
43 | } |
|
43 | } | |
44 |
|
44 | |||
45 |
/// Return the message corresponding to the error |
|
45 | /// Return the message corresponding to the error if any | |
46 | pub fn get_error_message_bytes(&self) -> Option<Vec<u8>> { |
|
46 | pub fn get_error_message_bytes(&self) -> Option<Vec<u8>> { | |
47 | match self { |
|
47 | match self { | |
48 |
CommandError |
|
48 | CommandError::RootNotFound(path) => { | |
49 | let bytes = get_bytes_from_path(path); |
|
49 | let bytes = get_bytes_from_path(path); | |
50 | Some(format_bytes!( |
|
50 | Some(format_bytes!( | |
51 | b"abort: no repository found in '{}' (.hg not found)!\n", |
|
51 | b"abort: no repository found in '{}' (.hg not found)!\n", | |
52 | bytes.as_slice() |
|
52 | bytes.as_slice() | |
53 | )) |
|
53 | )) | |
54 | } |
|
54 | } | |
55 |
CommandError |
|
55 | CommandError::CurrentDirNotFound(e) => Some(format_bytes!( | |
56 | b"abort: error getting current working directory: {}\n", |
|
56 | b"abort: error getting current working directory: {}\n", | |
57 | e.to_string().as_bytes(), |
|
57 | e.to_string().as_bytes(), | |
58 | )), |
|
58 | )), | |
59 |
CommandError |
|
59 | CommandError::RequirementsError(RequirementsError::Corrupted) => { | |
60 | RequirementsError::Corrupted, |
|
60 | Some( | |
61 | ) => Some( |
|
61 | "abort: .hg/requires is corrupted\n".as_bytes().to_owned(), | |
62 | "abort: .hg/requires is corrupted\n".as_bytes().to_owned(), |
|
62 | ) | |
63 |
|
|
63 | } | |
64 |
CommandError |
|
64 | CommandError::Abort(message) => message.to_owned(), | |
65 | _ => None, |
|
65 | _ => None, | |
66 | } |
|
66 | } | |
67 | } |
|
67 | } | |
68 | } |
|
|||
69 |
|
68 | |||
70 | /// The error type for the Command trait |
|
|||
71 | #[derive(Debug)] |
|
|||
72 | pub struct CommandError { |
|
|||
73 | pub kind: CommandErrorKind, |
|
|||
74 | } |
|
|||
75 |
|
||||
76 | impl CommandError { |
|
|||
77 | /// Exist the process with the corresponding exit code. |
|
69 | /// Exist the process with the corresponding exit code. | |
78 | pub fn exit(&self) { |
|
70 | pub fn exit(&self) { | |
79 |
std::process::exit(self. |
|
71 | std::process::exit(self.get_exit_code()) | |
80 | } |
|
|||
81 |
|
||||
82 | /// Return the message corresponding to the command error if any |
|
|||
83 | pub fn get_error_message_bytes(&self) -> Option<Vec<u8>> { |
|
|||
84 | self.kind.get_error_message_bytes() |
|
|||
85 | } |
|
|||
86 | } |
|
|||
87 |
|
||||
88 | impl From<CommandErrorKind> for CommandError { |
|
|||
89 | fn from(kind: CommandErrorKind) -> Self { |
|
|||
90 | CommandError { kind } |
|
|||
91 | } |
|
72 | } | |
92 | } |
|
73 | } | |
93 |
|
74 | |||
94 | impl From<UiError> for CommandError { |
|
75 | impl From<UiError> for CommandError { | |
95 | fn from(error: UiError) -> Self { |
|
76 | fn from(error: UiError) -> Self { | |
96 |
|
|
77 | match error { | |
97 | kind: match error { |
|
78 | UiError::StdoutError(_) => CommandError::StdoutError, | |
98 |
|
|
79 | UiError::StderrError(_) => CommandError::StderrError, | |
99 | UiError::StderrError(_) => CommandErrorKind::StderrError, |
|
|||
100 | }, |
|
|||
101 | } |
|
80 | } | |
102 | } |
|
81 | } | |
103 | } |
|
82 | } | |
104 |
|
83 | |||
105 | impl From<FindRootError> for CommandError { |
|
84 | impl From<FindRootError> for CommandError { | |
106 | fn from(err: FindRootError) -> Self { |
|
85 | fn from(err: FindRootError) -> Self { | |
107 |
match err |
|
86 | match err { | |
108 |
FindRootError |
|
87 | FindRootError::RootNotFound(path) => { | |
109 |
|
|
88 | CommandError::RootNotFound(path) | |
110 |
} |
|
89 | } | |
111 |
FindRootError |
|
90 | FindRootError::GetCurrentDirError(e) => { | |
112 |
|
|
91 | CommandError::CurrentDirNotFound(e) | |
113 |
} |
|
92 | } | |
114 | } |
|
93 | } | |
115 | } |
|
94 | } | |
116 | } |
|
95 | } | |
117 |
|
96 | |||
118 | impl From<RequirementsError> for CommandError { |
|
97 | impl From<RequirementsError> for CommandError { | |
119 | fn from(err: RequirementsError) -> Self { |
|
98 | fn from(err: RequirementsError) -> Self { | |
120 |
CommandError |
|
99 | CommandError::RequirementsError(err) | |
121 | kind: CommandErrorKind::RequirementsError(err), |
|
|||
122 | } |
|
|||
123 | } |
|
100 | } | |
124 | } |
|
101 | } |
General Comments 0
You need to be logged in to leave comments.
Login now