mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
clone: move repo creation earlier in the localrepo constructor
Summary: We've had a few issues recently where clones failed because of unexpected config load ordering. The main problem is that we can't load repo configs until the repo is created and the .hg/hgrc created. This happened rather late in the process, for instance it happened after the source connection was created, so no repo-specific dynamicconfigs could affect the source connection. This diff moves basic repo creation (the directory, the .hg, and the .hg/hgrc) earlier in the repo creation process and loads dynamicconfigs before proceeding. This eliminates the use of applydynamicconfig in the localrepo constructor. The next diff moves repo creation earlier in the clone process to then benefit from this, and removes the final use of applydynamicconfig, thus preventing config load ordering issues. Reviewed By: quark-zju Differential Revision: D26676520 fbshipit-source-id: 8784f2483909a50e8be9eb1a7adf03e8807ef076
This commit is contained in:
parent
b38cc98e54
commit
0026cbfa23
@ -432,15 +432,22 @@ class localrepository(object):
|
||||
# This list it to be filled by extension during repo setup
|
||||
self._phasedefaults = []
|
||||
|
||||
reponame = self.ui.config("remotefilelog", "reponame", "")
|
||||
# If the repo already exists, load the existing configs
|
||||
if self.localvfs.isdir():
|
||||
self.ui.reloadconfigs(self.root)
|
||||
# Create the initial directory if it doesn't already exist.
|
||||
created = False
|
||||
if not self.localvfs.isdir():
|
||||
if create:
|
||||
created = True
|
||||
# Create initial directory. Just enough to allow basic config
|
||||
# loading.
|
||||
if not self.wvfs.exists():
|
||||
self.wvfs.makedirs()
|
||||
self.localvfs.makedir(notindexed=True)
|
||||
else:
|
||||
raise errormod.RepoError(_("repository %s not found") % path)
|
||||
elif create:
|
||||
# If we're in the process of creating the repo, load the dynamic configs in
|
||||
# memory only. They will be written to disk later once the localvfs
|
||||
# is created.
|
||||
uiconfig.applydynamicconfig(self.ui, reponame, self.path)
|
||||
raise errormod.RepoError(_("repository %s already exists") % path)
|
||||
|
||||
self.ui.reloadconfigs(self.root)
|
||||
|
||||
self._loadextensions()
|
||||
|
||||
@ -459,31 +466,19 @@ class localrepository(object):
|
||||
if engine.revlogheader():
|
||||
self.supported.add("exp-compression-%s" % name)
|
||||
|
||||
created = False
|
||||
if not self.localvfs.isdir():
|
||||
if create:
|
||||
created = True
|
||||
self.requirements = newreporequirements(self)
|
||||
if "store" in self.requirements:
|
||||
self.storerequirements = newrepostorerequirements(self)
|
||||
if created:
|
||||
self.requirements = newreporequirements(self)
|
||||
if "store" in self.requirements:
|
||||
self.storerequirements = newrepostorerequirements(self)
|
||||
|
||||
if not self.wvfs.exists():
|
||||
self.wvfs.makedirs()
|
||||
self.localvfs.makedir(notindexed=True)
|
||||
self.localvfs.mkdir("store")
|
||||
|
||||
if "store" in self.requirements:
|
||||
self.localvfs.mkdir("store")
|
||||
|
||||
# create an invalid changelog
|
||||
self.localvfs.append(
|
||||
"00changelog.i",
|
||||
b"\0\0\0\1"
|
||||
b" dummy changelog to prevent using the old repo layout",
|
||||
)
|
||||
else:
|
||||
raise errormod.RepoError(_("repository %s not found") % path)
|
||||
elif create:
|
||||
raise errormod.RepoError(_("repository %s already exists") % path)
|
||||
# create an invalid changelog
|
||||
self.localvfs.append(
|
||||
"00changelog.i",
|
||||
b"\0\0\0\1"
|
||||
b" dummy changelog to prevent using the old repo layout",
|
||||
)
|
||||
else:
|
||||
try:
|
||||
self.requirements = scmutil.readrequires(self.localvfs, self.supported)
|
||||
|
Loading…
Reference in New Issue
Block a user