changeset 48460:1d940d76571b

rust: add function to check if an extension is enabled This will be used in the next patch Differential Revision: https://phab.mercurial-scm.org/D11812
author Raphaël Gomès <rgomes@octobus.net>
date Fri, 26 Nov 2021 15:05:58 +0100
parents c6d00759dc2b
children 9ff246cd6200
files rust/hg-core/src/config/config.rs
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/config/config.rs	Fri Dec 03 15:06:40 2021 +0100
+++ b/rust/hg-core/src/config/config.rs	Fri Nov 26 15:05:58 2021 +0100
@@ -362,6 +362,15 @@
         Ok(self.get_option(section, item)?.unwrap_or(false))
     }
 
+    /// Returns `true` if the extension is enabled, `false` otherwise
+    pub fn is_extension_enabled(&self, extension: &[u8]) -> bool {
+        let value = self.get(b"extensions", extension);
+        match value {
+            Some(c) => !c.starts_with(b"!"),
+            None => false,
+        }
+    }
+
     /// If there is an `item` value in `section`, parse and return a list of
     /// byte strings.
     pub fn get_list(