# HG changeset patch # User Raphaël Gomès # Date 1657553259 -7200 # 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 -r 5846bc8a2855 -r f3cd2d6eeef9 rust/rhg/src/main.rs --- a/rust/rhg/src/main.rs Fri May 20 11:02:52 2022 +0100 +++ b/rust/rhg/src/main.rs Mon Jul 11 17:27:39 2022 +0200 @@ -687,13 +687,18 @@ } 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 -r 5846bc8a2855 -r f3cd2d6eeef9 tests/test-log.t --- a/tests/test-log.t Fri May 20 11:02:52 2022 +0100 +++ b/tests/test-log.t Mon Jul 11 17:27:39 2022 +0200 @@ -2157,6 +2157,8 @@ ... '''.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 @@ 3 1 +#endif + $ cd .. test hg log on non-existent files and on directories