changeset 48339:a2e278b5e265

rhg: [encode] and [decode] config sections are not supported Differential Revision: https://phab.mercurial-scm.org/D11761
author Simon Sapin <simon.sapin@octobus.net>
date Tue, 09 Nov 2021 19:09:57 +0100
parents f9db8eeb3aec
children d71b9902e2de
files rust/hg-core/src/config/config.rs rust/hg-core/src/config/layer.rs rust/rhg/src/main.rs tests/test-encode.t
diffstat 4 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/config/config.rs	Tue Nov 09 18:56:55 2021 +0100
+++ b/rust/hg-core/src/config/config.rs	Tue Nov 09 19:09:57 2021 +0100
@@ -403,6 +403,13 @@
             .collect()
     }
 
+    /// Returns whether any key is defined in the given section
+    pub fn has_non_empty_section(&self, section: &[u8]) -> bool {
+        self.layers
+            .iter()
+            .any(|layer| layer.has_non_empty_section(section))
+    }
+
     /// Get raw values bytes from all layers (even untrusted ones) in order
     /// of precedence.
     #[cfg(test)]
--- a/rust/hg-core/src/config/layer.rs	Tue Nov 09 18:56:55 2021 +0100
+++ b/rust/hg-core/src/config/layer.rs	Tue Nov 09 19:09:57 2021 +0100
@@ -127,6 +127,13 @@
             .flat_map(|section| section.keys().map(|vec| &**vec))
     }
 
+    /// Returns whether any key is defined in the given section
+    pub fn has_non_empty_section(&self, section: &[u8]) -> bool {
+        self.sections
+            .get(section)
+            .map_or(false, |section| !section.is_empty())
+    }
+
     pub fn is_empty(&self) -> bool {
         self.sections.is_empty()
     }
--- a/rust/rhg/src/main.rs	Tue Nov 09 18:56:55 2021 +0100
+++ b/rust/rhg/src/main.rs	Tue Nov 09 19:09:57 2021 +0100
@@ -626,5 +626,13 @@
         Err(CommandError::unsupported("$HG_PENDING"))?
     }
 
+    if config.has_non_empty_section(b"encode") {
+        Err(CommandError::unsupported("[encode] config"))?
+    }
+
+    if config.has_non_empty_section(b"decode") {
+        Err(CommandError::unsupported("[decode] config"))?
+    }
+
     Ok(())
 }
--- a/tests/test-encode.t	Tue Nov 09 18:56:55 2021 +0100
+++ b/tests/test-encode.t	Tue Nov 09 19:09:57 2021 +0100
@@ -1,7 +1,3 @@
-TODO: fix rhg bugs that make this test fail when status is enabled
-  $ unset RHG_STATUS
-
-
 Test encode/decode filters
 
   $ hg init