Mercurial > hg
diff rust/hg-core/src/config/config.rs @ 47406:3237ed4dcda4
rhg: split non_repo_config and `--config` loading in different functions
This will help us in better handling of error caused when trying to
load `--config` values.
Differential Revision: https://phab.mercurial-scm.org/D10837
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 07 Jun 2021 17:19:46 +0530 |
parents | b0e92313107e |
children | 6961eca0b3ee |
line wrap: on
line diff
--- a/rust/hg-core/src/config/config.rs Mon May 24 16:27:54 2021 +0530 +++ b/rust/hg-core/src/config/config.rs Mon Jun 07 17:19:46 2021 +0530 @@ -88,9 +88,7 @@ /// Load system and user configuration from various files. /// /// This is also affected by some environment variables. - pub fn load( - cli_config_args: impl IntoIterator<Item = impl AsRef<[u8]>>, - ) -> Result<Self, ConfigError> { + pub fn load_non_repo() -> Result<Self, ConfigError> { let mut config = Self { layers: Vec::new() }; let opt_rc_path = env::var_os("HGRCPATH"); // HGRCPATH replaces system config @@ -133,10 +131,17 @@ } } } + Ok(config) + } + + pub fn load_cli_args_config( + &mut self, + cli_config_args: impl IntoIterator<Item = impl AsRef<[u8]>>, + ) -> Result<(), ConfigError> { if let Some(layer) = ConfigLayer::parse_cli_args(cli_config_args)? { - config.layers.push(layer) + self.layers.push(layer) } - Ok(config) + Ok(()) } fn add_trusted_dir(&mut self, path: &Path) -> Result<(), ConfigError> {