fix(mercurial): actually use assert_path instead of always initializing repo object.

This makes it consistent with how things work on git and svn sides
This commit is contained in:
RhodeCode Admin 2024-10-24 13:25:37 +02:00
parent 67674fcb3d
commit 465e9ede18

View file

@ -368,26 +368,32 @@ class MercurialRepository(BaseRepository):
be created.
If `src_url` is given, would try to clone repository from the
location at given clone_point. Additionally it'll make update to
location at given clone_point. Additionally, it'll make update to
working copy accordingly to `do_workspace_checkout` flag.
"""
if create and os.path.exists(self.path):
raise RepositoryError(
f"Cannot create repository at {self.path}, location already exist")
if src_url:
url = str(self._get_url(src_url))
MercurialRepository.check_url(url, self.config)
self._remote.clone(url, self.path, do_workspace_checkout)
# Don't try to create if we've already cloned repo
create = False
if create:
os.makedirs(self.path, mode=0o755)
if src_url:
url = str(self._get_url(src_url))
MercurialRepository.check_url(url, self.config)
self._remote.localrepository(create)
self._remote.clone(url, self.path, do_workspace_checkout)
# Don't try to create if we've already cloned repo
create = False
self._remote.localrepository(create)
else:
os.makedirs(self.path, mode=0o755)
create = True
self._remote.localrepository(create)
else:
if not self._remote.assert_correct_path():
raise RepositoryError(
f'Path "{self.path}" does not contain a Mercurial repository')
@LazyProperty
def in_memory_commit(self):