changeset 47951:cff41e168c25

rhg: Switch rhg.ignored-extensions config to Python-compatible list syntax This includes the ability to have an extension name/path that contains a comma, by double-quoting it. Differential Revision: https://phab.mercurial-scm.org/D11390
author Simon Sapin <simon.sapin@octobus.net>
date Fri, 03 Sep 2021 16:32:35 +0200
parents 6961eca0b3ee
children 9cd35c8c6044
files rust/hg-core/src/config/config.rs rust/rhg/src/main.rs
diffstat 2 files changed, 2 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/rust/hg-core/src/config/config.rs	Wed Feb 17 20:49:53 2021 +0100
+++ b/rust/hg-core/src/config/config.rs	Fri Sep 03 16:32:35 2021 +0200
@@ -13,7 +13,6 @@
     ConfigError, ConfigLayer, ConfigOrigin, ConfigValue,
 };
 use crate::utils::files::get_bytes_from_os_str;
-use crate::utils::SliceExt;
 use format_bytes::{write_bytes, DisplayBytes};
 use std::collections::HashSet;
 use std::env;
@@ -362,32 +361,6 @@
         Ok(self.get_option(section, item)?.unwrap_or(false))
     }
 
-    /// Returns the corresponding list-value in the config if found, or `None`.
-    ///
-    /// This is appropriate for new configuration keys. The value syntax is
-    /// **not** the same as most existing list-valued config, which has Python
-    /// parsing implemented in `parselist()` in
-    /// `mercurial/utils/stringutil.py`. Faithfully porting that parsing
-    /// algorithm to Rust (including behavior that are arguably bugs)
-    /// turned out to be non-trivial and hasn’t been completed as of this
-    /// writing.
-    ///
-    /// Instead, the "simple" syntax is: split on comma, then trim leading and
-    /// trailing whitespace of each component. Quotes or backslashes are not
-    /// interpreted in any way. Commas are mandatory between values. Values
-    /// that contain a comma are not supported.
-    pub fn get_simple_list(
-        &self,
-        section: &[u8],
-        item: &[u8],
-    ) -> Option<impl Iterator<Item = &[u8]>> {
-        self.get(section, item).map(|value| {
-            value
-                .split(|&byte| byte == b',')
-                .map(|component| component.trim())
-        })
-    }
-
     /// If there is an `item` value in `section`, parse and return a list of
     /// byte strings.
     pub fn get_list(
--- a/rust/rhg/src/main.rs	Wed Feb 17 20:49:53 2021 +0100
+++ b/rust/rhg/src/main.rs	Fri Sep 03 16:32:35 2021 +0200
@@ -567,11 +567,10 @@
         unsupported.remove(supported);
     }
 
-    if let Some(ignored_list) =
-        config.get_simple_list(b"rhg", b"ignored-extensions")
+    if let Some(ignored_list) = config.get_list(b"rhg", b"ignored-extensions")
     {
         for ignored in ignored_list {
-            unsupported.remove(ignored);
+            unsupported.remove(ignored.as_slice());
         }
     }