From 465e9ede180aca2c22a60e69ca238fc91168cc30 Mon Sep 17 00:00:00 2001 From: RhodeCode Admin Date: Thu, 24 Oct 2024 13:25:37 +0200 Subject: [PATCH] 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 --- rhodecode/lib/vcs/backends/hg/repository.py | 30 ++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/rhodecode/lib/vcs/backends/hg/repository.py b/rhodecode/lib/vcs/backends/hg/repository.py index 8b2330e1..7cc7ac38 100644 --- a/rhodecode/lib/vcs/backends/hg/repository.py +++ b/rhodecode/lib/vcs/backends/hg/repository.py @@ -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):