[Updated] [+- ] D11761: rhg: [encode] and [decode] config sections are not supported

SimonSapin phabricator at mercurial-scm.org
Fri Nov 26 15:00:20 UTC 2021


SimonSapin updated this revision to Diff 31139.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D11761?vs=31074&id=31139

BRANCH
  default

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

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

AFFECTED FILES
  rust/hg-core/src/config/config.rs
  rust/hg-core/src/config/layer.rs
  rust/rhg/src/main.rs
  tests/test-encode.t

CHANGE DETAILS

diff --git a/tests/test-encode.t b/tests/test-encode.t
--- a/tests/test-encode.t
+++ b/tests/test-encode.t
@@ -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
diff --git a/rust/rhg/src/main.rs b/rust/rhg/src/main.rs
--- a/rust/rhg/src/main.rs
+++ b/rust/rhg/src/main.rs
@@ -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(())
 }
diff --git a/rust/hg-core/src/config/layer.rs b/rust/hg-core/src/config/layer.rs
--- a/rust/hg-core/src/config/layer.rs
+++ b/rust/hg-core/src/config/layer.rs
@@ -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()
     }
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
@@ -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)]



To: SimonSapin, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211126/4d79da66/attachment-0002.html>


More information about the Mercurial-patches mailing list