diff --git a/rhodecode/lib/vcs/backends/__init__.py b/rhodecode/lib/vcs/backends/__init__.py --- a/rhodecode/lib/vcs/backends/__init__.py +++ b/rhodecode/lib/vcs/backends/__init__.py @@ -22,6 +22,7 @@ VCS Backends module """ +import os import logging from pprint import pformat @@ -42,11 +43,18 @@ def get_vcs_instance(repo_path, *args, * for the path it returns None. Arguments and keyword arguments are passed to the vcs backend repository class. """ + explicit_vcs_alias = kwargs.pop('_vcs_alias', None) try: - vcs_alias = get_scm(repo_path)[0] + vcs_alias = explicit_vcs_alias or get_scm(repo_path)[0] log.debug( 'Creating instance of %s repository from %s', vcs_alias, repo_path) backend = get_backend(vcs_alias) + + if explicit_vcs_alias: + # do final verification of existance of the path, this does the + # same as get_scm() call which we skip in explicit_vcs_alias + if not os.path.isdir(repo_path): + raise VCSError("Given path %s is not a directory" % repo_path) except VCSError: log.exception( 'Perhaps this repository is in db and not in ' diff --git a/rhodecode/model/db.py b/rhodecode/model/db.py --- a/rhodecode/model/db.py +++ b/rhodecode/model/db.py @@ -1987,12 +1987,12 @@ class Repository(Base, BaseModel): custom_wire = { 'cache': cache # controls the vcs.remote cache } - repo = get_vcs_instance( repo_path=safe_str(self.repo_full_path), config=config, with_wire=custom_wire, - create=False) + create=False, + _vcs_alias=self.repo_type) return repo