# HG changeset patch # User RhodeCode Admin # Date 2024-10-24 11:25:37 # Node ID 68a5b57b88f8917965fb1d0fb74fd55c44490615 # Parent 16defd511f02f95c2ff6902e8ece3068819d3d4d 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 diff --git a/rhodecode/lib/vcs/backends/hg/repository.py b/rhodecode/lib/vcs/backends/hg/repository.py --- 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) + if create: + 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) + self._remote.clone(url, self.path, do_workspace_checkout) - # Don't try to create if we've already cloned repo - create = False + # 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) - if create: - os.makedirs(self.path, mode=0o755) - - 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):