Show More
@@ -150,7 +150,7 b' fn main() {' | |||
|
150 | 150 | .unwrap_or_else(|error| { |
|
151 | 151 | exit( |
|
152 | 152 | &None, |
|
153 | &Ui::new(&Config::empty()), | |
|
153 | &Ui::new_infallible(&Config::empty()), | |
|
154 | 154 | OnUnsupported::Abort, |
|
155 | 155 | Err(CommandError::abort(format!( |
|
156 | 156 | "abort: {}: '{}'", |
@@ -171,7 +171,7 b' fn main() {' | |||
|
171 | 171 | |
|
172 | 172 | exit( |
|
173 | 173 | &initial_current_dir, |
|
174 | &Ui::new(&Config::empty()), | |
|
174 | &Ui::new_infallible(&Config::empty()), | |
|
175 | 175 | on_unsupported, |
|
176 | 176 | Err(error.into()), |
|
177 | 177 | false, |
@@ -183,7 +183,7 b' fn main() {' | |||
|
183 | 183 | .unwrap_or_else(|error| { |
|
184 | 184 | exit( |
|
185 | 185 | &initial_current_dir, |
|
186 | &Ui::new(&non_repo_config), | |
|
186 | &Ui::new_infallible(&non_repo_config), | |
|
187 | 187 | OnUnsupported::from_config(&non_repo_config), |
|
188 | 188 | Err(error.into()), |
|
189 | 189 | non_repo_config |
@@ -201,7 +201,7 b' fn main() {' | |||
|
201 | 201 | if SCHEME_RE.is_match(&repo_path_bytes) { |
|
202 | 202 | exit( |
|
203 | 203 | &initial_current_dir, |
|
204 | &Ui::new(&non_repo_config), | |
|
204 | &Ui::new_infallible(&non_repo_config), | |
|
205 | 205 | OnUnsupported::from_config(&non_repo_config), |
|
206 | 206 | Err(CommandError::UnsupportedFeature { |
|
207 | 207 | message: format_bytes!( |
@@ -291,7 +291,7 b' fn main() {' | |||
|
291 | 291 | } |
|
292 | 292 | Err(error) => exit( |
|
293 | 293 | &initial_current_dir, |
|
294 | &Ui::new(&non_repo_config), | |
|
294 | &Ui::new_infallible(&non_repo_config), | |
|
295 | 295 | OnUnsupported::from_config(&non_repo_config), |
|
296 | 296 | Err(error.into()), |
|
297 | 297 | // TODO: show a warning or combine with original error if |
@@ -307,7 +307,17 b' fn main() {' | |||
|
307 | 307 | } else { |
|
308 | 308 | &non_repo_config |
|
309 | 309 | }; |
|
310 |
let ui = Ui::new(&config) |
|
|
310 | let ui = Ui::new(&config).unwrap_or_else(|error| { | |
|
311 | exit( | |
|
312 | &initial_current_dir, | |
|
313 | &Ui::new_infallible(&config), | |
|
314 | OnUnsupported::from_config(&config), | |
|
315 | Err(error.into()), | |
|
316 | config | |
|
317 | .get_bool(b"ui", b"detailed-exit-code") | |
|
318 | .unwrap_or(false), | |
|
319 | ) | |
|
320 | }); | |
|
311 | 321 | let on_unsupported = OnUnsupported::from_config(config); |
|
312 | 322 | |
|
313 | 323 | let result = main_with_result( |
@@ -1,5 +1,6 b'' | |||
|
1 | 1 | use format_bytes::format_bytes; |
|
2 | 2 | use hg::config::Config; |
|
3 | use hg::errors::HgError; | |
|
3 | 4 | use hg::utils::files::get_bytes_from_os_string; |
|
4 | 5 | use std::borrow::Cow; |
|
5 | 6 | use std::env; |
@@ -22,7 +23,17 b' pub enum UiError {' | |||
|
22 | 23 | |
|
23 | 24 | /// The commandline user interface |
|
24 | 25 | impl Ui { |
|
25 | pub fn new(_config: &Config) -> Self { | |
|
26 | pub fn new(_config: &Config) -> Result<Self, HgError> { | |
|
27 | Ok(Ui { | |
|
28 | stdout: std::io::stdout(), | |
|
29 | stderr: std::io::stderr(), | |
|
30 | }) | |
|
31 | } | |
|
32 | ||
|
33 | /// Default to no color if color configuration errors. | |
|
34 | /// | |
|
35 | /// Useful when we’re already handling another error. | |
|
36 | pub fn new_infallible(_config: &Config) -> Self { | |
|
26 | 37 | Ui { |
|
27 | 38 | stdout: std::io::stdout(), |
|
28 | 39 | stderr: std::io::stderr(), |
General Comments 0
You need to be logged in to leave comments.
Login now