##// END OF EJS Templates
models: Use the new get_vcs_instance method to retrieve vcs instances.
Martin Bornhold -
r485:34bd8df9 default
parent child Browse files
Show More
@@ -49,7 +49,7 b' from zope.cachedescriptors.property impo'
49 49 from pylons import url
50 50 from pylons.i18n.translation import lazy_ugettext as _
51 51
52 from rhodecode.lib.vcs import get_backend
52 from rhodecode.lib.vcs import get_backend, get_vcs_instance
53 53 from rhodecode.lib.vcs.utils.helpers import get_scm
54 54 from rhodecode.lib.vcs.exceptions import VCSError
55 55 from rhodecode.lib.vcs.backends.base import (
@@ -1986,27 +1986,16 b' class Repository(Base, BaseModel):'
1986 1986 return repo
1987 1987
1988 1988 def _get_instance(self, cache=True, config=None):
1989 repo_full_path = self.repo_full_path
1990 try:
1991 vcs_alias = get_scm(repo_full_path)[0]
1992 log.debug(
1993 'Creating instance of %s repository from %s',
1994 vcs_alias, repo_full_path)
1995 backend = get_backend(vcs_alias)
1996 except VCSError:
1997 log.exception(
1998 'Perhaps this repository is in db and not in '
1999 'filesystem run rescan repositories with '
2000 '"destroy old data" option from admin panel')
2001 return
2002
2003 1989 config = config or self._config
2004 1990 custom_wire = {
2005 1991 'cache': cache # controls the vcs.remote cache
2006 1992 }
2007 repo = backend(
2008 safe_str(repo_full_path), config=config, create=False,
2009 with_wire=custom_wire)
1993
1994 repo = get_vcs_instance(
1995 repo_path=safe_str(self.repo_full_path),
1996 config=config,
1997 with_wire=custom_wire,
1998 create=False)
2010 1999
2011 2000 return repo
2012 2001
@@ -3399,10 +3388,9 b' class Gist(Base, BaseModel):'
3399 3388 # SCM functions
3400 3389
3401 3390 def scm_instance(self, **kwargs):
3402 from rhodecode.lib.vcs import get_repo
3403 base_path = self.base_path()
3404 return get_repo(os.path.join(*map(safe_str,
3405 [base_path, self.gist_access_id])))
3391 full_repo_path = os.path.join(self.base_path(), self.gist_access_id)
3392 return get_vcs_instance(
3393 repo_path=safe_str(full_repo_path), create=False)
3406 3394
3407 3395
3408 3396 class DbMigrateVersion(Base, BaseModel):
General Comments 0
You need to be logged in to leave comments. Login now