Mercurial > hg
comparison rust/rhg/src/main.rs @ 49477:f3cd2d6eeef9
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.
author | Raphaël Gomès <rgomes@octobus.net> |
---|---|
date | Mon, 11 Jul 2022 17:27:39 +0200 |
parents | 411d591e0a27 |
children | a0d189b2e871 |
comparison
equal
deleted
inserted
replaced
49476:5846bc8a2855 | 49477:f3cd2d6eeef9 |
---|---|
685 // All extensions are to be ignored, nothing to do here | 685 // All extensions are to be ignored, nothing to do here |
686 return Ok(()); | 686 return Ok(()); |
687 } | 687 } |
688 | 688 |
689 let enabled: HashSet<&[u8]> = config | 689 let enabled: HashSet<&[u8]> = config |
690 .get_section_keys(b"extensions") | 690 .iter_section(b"extensions") |
691 .into_iter() | 691 .filter_map(|(extension, value)| { |
692 .map(|extension| { | 692 if value == b"!" { |
693 // Filter out disabled extensions | |
694 return None; | |
695 } | |
693 // Ignore extension suboptions. Only `required` exists for now. | 696 // Ignore extension suboptions. Only `required` exists for now. |
694 // `rhg` either supports an extension or doesn't, so it doesn't | 697 // `rhg` either supports an extension or doesn't, so it doesn't |
695 // make sense to consider the loading of an extension. | 698 // make sense to consider the loading of an extension. |
696 extension.split_2(b':').unwrap_or((extension, b"")).0 | 699 let actual_extension = |
700 extension.split_2(b':').unwrap_or((extension, b"")).0; | |
701 Some(actual_extension) | |
697 }) | 702 }) |
698 .collect(); | 703 .collect(); |
699 | 704 |
700 let mut unsupported = enabled; | 705 let mut unsupported = enabled; |
701 for supported in SUPPORTED_EXTENSIONS { | 706 for supported in SUPPORTED_EXTENSIONS { |