diff rust/hg-core/src/config/mod.rs @ 50804:7f8f6fe13fa9

configitems: move blackbox's config items to the new configitems.toml In order for the Rust code to gain access to default values of in-core extensions that have a Rust implementation, we need to centralize them alongside the core items declarations. This is the first and so far only one of the extensions that have gained Rust support, I don't think it's worth the churn to move the rest of the extension's configitems yet.
author Rapha?l Gom?s <rgomes@octobus.net>
date Wed, 05 Jul 2023 23:59:22 +0200
parents 8ff187fbbfea
children 67faf1bd8acd
line wrap: on
line diff
--- a/rust/hg-core/src/config/mod.rs	Mon Feb 13 18:11:48 2023 +0100
+++ b/rust/hg-core/src/config/mod.rs	Wed Jul 05 23:59:22 2023 +0200
@@ -373,7 +373,17 @@
                 Some("`mercurial/configitems.toml` is not valid".into()),
             )
         })?;
-        Ok(default_config.get(section, item))
+        let default_opt = default_config.get(section, item);
+        Ok(default_opt.filter(|default| {
+            default
+                .in_core_extension()
+                .map(|extension| {
+                    // Only return the default for an in-core extension item
+                    // if said extension is enabled
+                    self.is_extension_enabled(extension.as_bytes())
+                })
+                .unwrap_or(true)
+        }))
     }
 
     fn get_parse<'config, T: 'config>(