[Updated] D11812: rust: add function to check if an extension is enabled

Alphare (Raphaël Gomès) phabricator at mercurial-scm.org
Tue Dec 7 14:44:29 UTC 2021


Closed by commit rHG1d940d76571b: rust: add function to check if an extension is enabled (authored by Alphare).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11812?vs=31136&id=31347

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D11812/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D11812

AFFECTED FILES
  rust/hg-core/src/config/config.rs

CHANGE DETAILS

diff --git a/rust/hg-core/src/config/config.rs b/rust/hg-core/src/config/config.rs
--- a/rust/hg-core/src/config/config.rs
+++ b/rust/hg-core/src/config/config.rs
@@ -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(



To: Alphare, #hg-reviewers, pulkit
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20211207/6aeabb11/attachment.html>


More information about the Mercurial-patches mailing list