##// END OF EJS Templates
rhg: Pass a &Config to Ui::new...
Simon Sapin -
r49581:1aaf11e3 default
parent child Browse files
Show More
@@ -84,6 +84,11 b' impl fmt::Display for ConfigValueParseEr'
84 }
84 }
85
85
86 impl Config {
86 impl Config {
87 /// The configuration to use when printing configuration-loading errors
88 pub fn empty() -> Self {
89 Self { layers: Vec::new() }
90 }
91
87 /// Load system and user configuration from various files.
92 /// Load system and user configuration from various files.
88 ///
93 ///
89 /// This is also affected by some environment variables.
94 /// This is also affected by some environment variables.
@@ -137,7 +137,6 b' fn main() {'
137 let process_start_time = blackbox::ProcessStartTime::now();
137 let process_start_time = blackbox::ProcessStartTime::now();
138
138
139 env_logger::init();
139 env_logger::init();
140 let ui = ui::Ui::new();
141
140
142 let early_args = EarlyArgs::parse(std::env::args_os());
141 let early_args = EarlyArgs::parse(std::env::args_os());
143
142
@@ -151,7 +150,7 b' fn main() {'
151 .unwrap_or_else(|error| {
150 .unwrap_or_else(|error| {
152 exit(
151 exit(
153 &None,
152 &None,
154 &ui,
153 &Ui::new(&Config::empty()),
155 OnUnsupported::Abort,
154 OnUnsupported::Abort,
156 Err(CommandError::abort(format!(
155 Err(CommandError::abort(format!(
157 "abort: {}: '{}'",
156 "abort: {}: '{}'",
@@ -172,7 +171,7 b' fn main() {'
172
171
173 exit(
172 exit(
174 &initial_current_dir,
173 &initial_current_dir,
175 &ui,
174 &Ui::new(&Config::empty()),
176 on_unsupported,
175 on_unsupported,
177 Err(error.into()),
176 Err(error.into()),
178 false,
177 false,
@@ -184,7 +183,7 b' fn main() {'
184 .unwrap_or_else(|error| {
183 .unwrap_or_else(|error| {
185 exit(
184 exit(
186 &initial_current_dir,
185 &initial_current_dir,
187 &ui,
186 &Ui::new(&non_repo_config),
188 OnUnsupported::from_config(&non_repo_config),
187 OnUnsupported::from_config(&non_repo_config),
189 Err(error.into()),
188 Err(error.into()),
190 non_repo_config
189 non_repo_config
@@ -202,7 +201,7 b' fn main() {'
202 if SCHEME_RE.is_match(&repo_path_bytes) {
201 if SCHEME_RE.is_match(&repo_path_bytes) {
203 exit(
202 exit(
204 &initial_current_dir,
203 &initial_current_dir,
205 &ui,
204 &Ui::new(&non_repo_config),
206 OnUnsupported::from_config(&non_repo_config),
205 OnUnsupported::from_config(&non_repo_config),
207 Err(CommandError::UnsupportedFeature {
206 Err(CommandError::UnsupportedFeature {
208 message: format_bytes!(
207 message: format_bytes!(
@@ -292,7 +291,7 b' fn main() {'
292 }
291 }
293 Err(error) => exit(
292 Err(error) => exit(
294 &initial_current_dir,
293 &initial_current_dir,
295 &ui,
294 &Ui::new(&non_repo_config),
296 OnUnsupported::from_config(&non_repo_config),
295 OnUnsupported::from_config(&non_repo_config),
297 Err(error.into()),
296 Err(error.into()),
298 // TODO: show a warning or combine with original error if
297 // TODO: show a warning or combine with original error if
@@ -308,6 +307,7 b' fn main() {'
308 } else {
307 } else {
309 &non_repo_config
308 &non_repo_config
310 };
309 };
310 let ui = Ui::new(&config);
311 let on_unsupported = OnUnsupported::from_config(config);
311 let on_unsupported = OnUnsupported::from_config(config);
312
312
313 let result = main_with_result(
313 let result = main_with_result(
@@ -1,4 +1,5 b''
1 use format_bytes::format_bytes;
1 use format_bytes::format_bytes;
2 use hg::config::Config;
2 use hg::utils::files::get_bytes_from_os_string;
3 use hg::utils::files::get_bytes_from_os_string;
3 use std::borrow::Cow;
4 use std::borrow::Cow;
4 use std::env;
5 use std::env;
@@ -21,7 +22,7 b' pub enum UiError {'
21
22
22 /// The commandline user interface
23 /// The commandline user interface
23 impl Ui {
24 impl Ui {
24 pub fn new() -> Self {
25 pub fn new(_config: &Config) -> Self {
25 Ui {
26 Ui {
26 stdout: std::io::stdout(),
27 stdout: std::io::stdout(),
27 stderr: std::io::stderr(),
28 stderr: std::io::stderr(),
General Comments 0
You need to be logged in to leave comments. Login now