Show More
@@ -17,6 +17,7 b' use crate::utils::SliceExt;' | |||||
17 | use format_bytes::{write_bytes, DisplayBytes}; |
|
17 | use format_bytes::{write_bytes, DisplayBytes}; | |
18 | use std::collections::HashSet; |
|
18 | use std::collections::HashSet; | |
19 | use std::env; |
|
19 | use std::env; | |
|
20 | use std::fmt; | |||
20 | use std::path::{Path, PathBuf}; |
|
21 | use std::path::{Path, PathBuf}; | |
21 | use std::str; |
|
22 | use std::str; | |
22 |
|
23 | |||
@@ -68,6 +69,21 b' pub struct ConfigValueParseError {' | |||||
68 | pub expected_type: &'static str, |
|
69 | pub expected_type: &'static str, | |
69 | } |
|
70 | } | |
70 |
|
71 | |||
|
72 | impl fmt::Display for ConfigValueParseError { | |||
|
73 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |||
|
74 | // TODO: add origin and line number information, here and in | |||
|
75 | // corresponding python code | |||
|
76 | write!( | |||
|
77 | f, | |||
|
78 | "config error: {}.{} is not a {} ('{}')", | |||
|
79 | String::from_utf8_lossy(&self.section), | |||
|
80 | String::from_utf8_lossy(&self.item), | |||
|
81 | self.expected_type, | |||
|
82 | String::from_utf8_lossy(&self.value) | |||
|
83 | ) | |||
|
84 | } | |||
|
85 | } | |||
|
86 | ||||
71 | impl Config { |
|
87 | impl Config { | |
72 | /// Load system and user configuration from various files. |
|
88 | /// Load system and user configuration from various files. | |
73 | /// |
|
89 | /// |
@@ -88,25 +88,7 b' impl fmt::Display for HgError {' | |||||
88 | HgError::UnsupportedFeature(explanation) => { |
|
88 | HgError::UnsupportedFeature(explanation) => { | |
89 | write!(f, "unsupported feature: {}", explanation) |
|
89 | write!(f, "unsupported feature: {}", explanation) | |
90 | } |
|
90 | } | |
91 |
HgError::ConfigValueParseError( |
|
91 | HgError::ConfigValueParseError(error) => error.fmt(f), | |
92 | origin: _, |
|
|||
93 | line: _, |
|
|||
94 | section, |
|
|||
95 | item, |
|
|||
96 | value, |
|
|||
97 | expected_type, |
|
|||
98 | }) => { |
|
|||
99 | // TODO: add origin and line number information, here and in |
|
|||
100 | // corresponding python code |
|
|||
101 | write!( |
|
|||
102 | f, |
|
|||
103 | "config error: {}.{} is not a {} ('{}')", |
|
|||
104 | String::from_utf8_lossy(section), |
|
|||
105 | String::from_utf8_lossy(item), |
|
|||
106 | expected_type, |
|
|||
107 | String::from_utf8_lossy(value) |
|
|||
108 | ) |
|
|||
109 | } |
|
|||
110 | } |
|
92 | } | |
111 | } |
|
93 | } | |
112 | } |
|
94 | } |
@@ -17,7 +17,8 b' pub use dirstate::{' | |||||
17 | dirstate_map::DirstateMap, |
|
17 | dirstate_map::DirstateMap, | |
18 | parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, |
|
18 | parsers::{pack_dirstate, parse_dirstate, PARENT_SIZE}, | |
19 | status::{ |
|
19 | status::{ | |
20 |
status, BadMatch, BadType, DirstateStatus, StatusError, |
|
20 | status, BadMatch, BadType, DirstateStatus, HgPathCow, StatusError, | |
|
21 | StatusOptions, | |||
21 | }, |
|
22 | }, | |
22 | CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, |
|
23 | CopyMap, CopyMapIter, DirstateEntry, DirstateParents, EntryState, | |
23 | StateMap, StateMapIter, |
|
24 | StateMap, StateMapIter, |
@@ -2,11 +2,12 b' use crate::ui::utf8_to_local;' | |||||
2 | use crate::ui::UiError; |
|
2 | use crate::ui::UiError; | |
3 | use crate::NoRepoInCwdError; |
|
3 | use crate::NoRepoInCwdError; | |
4 | use format_bytes::format_bytes; |
|
4 | use format_bytes::format_bytes; | |
5 | use hg::config::{ConfigError, ConfigParseError}; |
|
5 | use hg::config::{ConfigError, ConfigParseError, ConfigValueParseError}; | |
6 | use hg::errors::HgError; |
|
6 | use hg::errors::HgError; | |
7 | use hg::repo::RepoError; |
|
7 | use hg::repo::RepoError; | |
8 | use hg::revlog::revlog::RevlogError; |
|
8 | use hg::revlog::revlog::RevlogError; | |
9 | use hg::utils::files::get_bytes_from_path; |
|
9 | use hg::utils::files::get_bytes_from_path; | |
|
10 | use hg::{DirstateError, DirstateMapError, StatusError}; | |||
10 | use std::convert::From; |
|
11 | use std::convert::From; | |
11 |
|
12 | |||
12 | /// The kind of command error |
|
13 | /// The kind of command error | |
@@ -61,6 +62,12 b' impl From<HgError> for CommandError {' | |||||
61 | } |
|
62 | } | |
62 | } |
|
63 | } | |
63 |
|
64 | |||
|
65 | impl From<ConfigValueParseError> for CommandError { | |||
|
66 | fn from(error: ConfigValueParseError) -> Self { | |||
|
67 | CommandError::abort(error.to_string()) | |||
|
68 | } | |||
|
69 | } | |||
|
70 | ||||
64 | impl From<UiError> for CommandError { |
|
71 | impl From<UiError> for CommandError { | |
65 | fn from(_error: UiError) -> Self { |
|
72 | fn from(_error: UiError) -> Self { | |
66 | // If we already failed writing to stdout or stderr, |
|
73 | // If we already failed writing to stdout or stderr, | |
@@ -144,3 +151,24 b' impl From<(RevlogError, &str)> for Comma' | |||||
144 | } |
|
151 | } | |
145 | } |
|
152 | } | |
146 | } |
|
153 | } | |
|
154 | ||||
|
155 | impl From<StatusError> for CommandError { | |||
|
156 | fn from(error: StatusError) -> Self { | |||
|
157 | CommandError::abort(format!("{}", error)) | |||
|
158 | } | |||
|
159 | } | |||
|
160 | ||||
|
161 | impl From<DirstateMapError> for CommandError { | |||
|
162 | fn from(error: DirstateMapError) -> Self { | |||
|
163 | CommandError::abort(format!("{}", error)) | |||
|
164 | } | |||
|
165 | } | |||
|
166 | ||||
|
167 | impl From<DirstateError> for CommandError { | |||
|
168 | fn from(error: DirstateError) -> Self { | |||
|
169 | match error { | |||
|
170 | DirstateError::Common(error) => error.into(), | |||
|
171 | DirstateError::Map(error) => error.into(), | |||
|
172 | } | |||
|
173 | } | |||
|
174 | } |
General Comments 0
You need to be logged in to leave comments.
Login now