# HG changeset patch # User Raphaël Gomès # Date 2022-07-11 15:27:39 # Node ID f3cd2d6eeef917ebd57f0b59f3c7089d3b9071e4 # Parent 5846bc8a285540e74dfe3cad5aecf0adfd04b086 rhg: support "!" syntax for disabling extensions This makes it so that calls in test-log.t do not fall back immediately because of the disabled extension, instead going through the CLI parsing code, which breaks because of invalid UTF-8 in a flag. I *think* clap 3.x+ supports this? I'm not sure, and we have to upgrade the minimum Rust version to use clap 3.x anyway which is out of scope for this series, so let's just kick that can down the road a little bit. 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 @@ -687,13 +687,18 @@ fn check_extensions(config: &Config) -> } let enabled: HashSet<&[u8]> = config - .get_section_keys(b"extensions") - .into_iter() - .map(|extension| { + .iter_section(b"extensions") + .filter_map(|(extension, value)| { + if value == b"!" { + // Filter out disabled extensions + return None; + } // 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 + let actual_extension = + extension.split_2(b':').unwrap_or((extension, b"")).0; + Some(actual_extension) }) .collect(); diff --git a/tests/test-log.t b/tests/test-log.t --- a/tests/test-log.t +++ b/tests/test-log.t @@ -2157,6 +2157,8 @@ test -u/-k for problematic encoding ... '''.encode('utf-8')) and None $ sh < setup.sh +#if no-rhg + test in problematic encoding >>> with open('test.sh', 'wb') as f: ... f.write(u''' @@ -2179,6 +2181,8 @@ test in problematic encoding 3 1 +#endif + $ cd .. test hg log on non-existent files and on directories