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):