Mercurial > hg
changeset 48439:9cf5ac8c7109
rhg: support the new extension suboptions syntax
See inline comments
Differential Revision: https://phab.mercurial-scm.org/D11874
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Tue, 07 Dec 2021 12:34:58 +0100 |
parents | 715e4e81e39a |
children | c8ca21962ff4 |
files | rust/rhg/src/main.rs tests/test-rhg.t |
diffstat | 2 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rust/rhg/src/main.rs Wed Dec 08 10:14:37 2021 +0100 +++ b/rust/rhg/src/main.rs Tue Dec 07 12:34:58 2021 +0100 @@ -11,6 +11,7 @@ use hg::repo::{Repo, RepoError}; use hg::utils::files::{get_bytes_from_os_str, get_path_from_bytes}; use hg::utils::SliceExt; +use std::collections::HashSet; use std::ffi::OsString; use std::path::PathBuf; use std::process::Command; @@ -598,11 +599,23 @@ } } +/// The `*` extension is an edge-case for config sub-options that apply to all +/// extensions. For now, only `:required` exists, but that may change in the +/// future. const SUPPORTED_EXTENSIONS: &[&[u8]] = - &[b"blackbox", b"share", b"sparse", b"narrow"]; + &[b"blackbox", b"share", b"sparse", b"narrow", b"*"]; fn check_extensions(config: &Config) -> Result<(), CommandError> { - let enabled = config.get_section_keys(b"extensions"); + let enabled: HashSet<&[u8]> = config + .get_section_keys(b"extensions") + .into_iter() + .map(|extension| { + // Ignore extension suboptions. Only `required` exists for now. + // `rhg` either supports an extension or doesn't, so it doesn't + // make sense to consider the loading of an extension. + extension.split_2(b':').unwrap_or((extension, b"")).0 + }) + .collect(); let mut unsupported = enabled; for supported in SUPPORTED_EXTENSIONS {
--- a/tests/test-rhg.t Wed Dec 08 10:14:37 2021 +0100 +++ b/tests/test-rhg.t Tue Dec 07 12:34:58 2021 +0100 @@ -380,3 +380,13 @@ $ rhg files a $ rm .hgsub + +The `:required` extension suboptions are correctly ignored + + $ echo "[extensions]" >> $HGRCPATH + $ echo "blackbox:required = yes" >> $HGRCPATH + $ rhg files + a + $ echo "*:required = yes" >> $HGRCPATH + $ rhg files + a