configfile: skip "local" config outside a repo

Summary: Now if you run "configfile" with no args outside a repo, it will show the system and user config paths, skipping the repo/local config.

Reviewed By: DurhamG

Differential Revision: D41310603

fbshipit-source-id: 540679ec9f446aa24d0a1f048ae8316cc5ff23fe
This commit is contained in:
Muir Manders 2022-11-15 12:53:57 -08:00 committed by Facebook GitHub Bot
parent 12bae04f31
commit c4a9cc2ccf
2 changed files with 13 additions and 7 deletions

View File

@ -57,15 +57,14 @@ pub fn run(ctx: ReqCtx<DebugConfigLocationOpts>, repo: &mut OptionalRepo) -> Res
}
if show_all || ctx.opts.local {
let repo = if let OptionalRepo::Some(repo) = repo {
repo
} else {
if let OptionalRepo::Some(repo) = repo {
if show_all {
write!(ctx.io().output(), "Repo config path: ")?;
}
write!(ctx.io().output(), "{}\n", repo.config_path().display())?;
} else if !show_all {
abort!("--local must be used inside a repo");
};
if show_all {
write!(ctx.io().output(), "Repo config path: ")?;
}
write!(ctx.io().output(), "{}\n", repo.config_path().display())?;
}
if show_all || ctx.opts.system {

View File

@ -37,3 +37,10 @@ Test locating other configs
$ hg configfile --system
/etc/mercurial/system.rc (no-windows !)
C:\ProgramData\Facebook\Mercurial\Facebook\Mercurial\system.rc (windows !)
Test outside a repo
$ cd
$ hg configfile
User config path: $TESTTMP/.hgrc
System config path: /etc/mercurial/system.rc (no-windows !)
System config path: C:\ProgramData\Facebook\Mercurial\Facebook\Mercurial\system.rc (windows !)