config: avoid unnecessary reponame rewrites

Summary: D35147190 (45d88665a8) put the inner repo loading behind the `init.use-rust` config, preventing excessive rewrites for the `reponame` file for users not in the alpha build. This diff makes those excessive rewrites disappear altogether for everyone.

Reviewed By: xavierd

Differential Revision: D35176025

fbshipit-source-id: 7b26c0bde4a74c9891df6e2f8a472d1a94f80273
This commit is contained in:
Saul Gutierrez 2022-03-29 10:48:40 -07:00 committed by Facebook GitHub Bot
parent c6d27c97d7
commit 0d96992a96
2 changed files with 17 additions and 1 deletions

View File

@ -509,7 +509,7 @@ fn read_set_repo_name(config: &mut ConfigSet, repo_path: &Path) -> crate::Result
tracing::debug!("repo name: {:?} (from {})", &repo_name, source);
if source != ".hg/reponame" {
let need_rewrite = match read_repo_name_from_disk(repo_path) {
Ok(s) => s == repo_name,
Ok(s) => s != repo_name,
Err(_) => true,
};
if need_rewrite {

View File

@ -0,0 +1,16 @@
#chg-compatible
$ configure modern
$ newrepo
Make sure we do not rewrite by default:
$ cat .hg/reponame
reponame-default (no-eol)
$ LOG=configparser::hg=debug hg log 2>&1 | grep written
[1]
Rewrite on wrong reponame:
$ echo foobar > .hg/reponame
$ LOG=configparser::hg=debug hg log 2>&1 | grep written
DEBUG configparser::hg: repo name: written to .hg/reponame
$ cat .hg/reponame
reponame-default (no-eol)