##// END OF EJS Templates
rhg: Sort config files when adding a directory...
rhg: Sort config files when adding a directory For example in `/etc/mercurial/hgrc.d/` or with `HGRCPATH=some-directory`. Previously files where parsed in the order returned by the filesystem, which is undefined. But order is significant when multiple files define the same configuration key: the "last" one wins. Differential Revision: https://phab.mercurial-scm.org/D10111

File last commit:

r47460:92e3cfd6 default
r47466:60fe9eba default
Show More
config.rs
36 lines | 1.0 KiB | application/rls-services+xml | RustLexer
use crate::error::CommandError;
use clap::Arg;
use format_bytes::format_bytes;
use hg::errors::HgError;
use hg::utils::SliceExt;
pub const HELP_TEXT: &str = "
With one argument of the form section.name, print just the value of that config item.
";
pub fn args() -> clap::App<'static, 'static> {
clap::SubCommand::with_name("config")
.arg(
Arg::with_name("name")
.help("the section.name to print")
.value_name("NAME")
.required(true)
.takes_value(true),
)
.about(HELP_TEXT)
}
pub fn run(invocation: &crate::CliInvocation) -> Result<(), CommandError> {
let (section, name) = invocation
.subcommand_args
.value_of("name")
.expect("missing required CLI argument")
.as_bytes()
.split_2(b'.')
.ok_or_else(|| HgError::unsupported("hg config <section>"))?;
let value = invocation.config.get(section, name).unwrap_or(b"");
invocation.ui.write_stdout(&format_bytes!(b"{}\n", value))?;
Ok(())
}