avoid writing conflicted repo requirements

Summary:
See the previous diff for context. Basically, it's not a valid setup to be both
a shallow (remotefilelog) and an eager repo. Detect that and avoid it.

Reviewed By: muirdm

Differential Revision: D43516086

fbshipit-source-id: 13b6eb41097478f1e5fa16c9282709c17f5d4ade
This commit is contained in:
Jun Wu 2023-02-22 20:59:29 -08:00 committed by Facebook GitHub Bot
parent 3a01cba6ff
commit 508bb1082e

View File

@ -229,9 +229,15 @@ class HgRepository(repobase.Repository):
hgrc["remotefilelog"]["cachepath"] = cachepath
self.write_hgrc(hgrc)
requirespath = os.path.join(self.path, ".hg", "requires")
with open(requirespath, "a") as f:
f.write("remotefilelog\n")
storerequirespath = os.path.join(self.path, ".hg", "store", "requires")
with open(storerequirespath, "r") as f:
storerequires = set(f.read().split())
# eagerepo conflicts with remotefilelog repo
if "eagerepo" not in storerequires:
requirespath = os.path.join(self.path, ".hg", "requires")
with open(requirespath, "a") as f:
f.write("remotefilelog\n")
def write_hgrc(self, hgrc: configparser.ConfigParser) -> None:
hgrc_path = os.path.join(self.path, ".hg", "hgrc")