##// 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 from pylons import url
49 from pylons import url
50 from pylons.i18n.translation import lazy_ugettext as _
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 from rhodecode.lib.vcs.utils.helpers import get_scm
53 from rhodecode.lib.vcs.utils.helpers import get_scm
54 from rhodecode.lib.vcs.exceptions import VCSError
54 from rhodecode.lib.vcs.exceptions import VCSError
55 from rhodecode.lib.vcs.backends.base import (
55 from rhodecode.lib.vcs.backends.base import (
@@ -1986,27 +1986,16 b' class Repository(Base, BaseModel):'
1986 return repo
1986 return repo
1987
1987
1988 def _get_instance(self, cache=True, config=None):
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 config = config or self._config
1989 config = config or self._config
2004 custom_wire = {
1990 custom_wire = {
2005 'cache': cache # controls the vcs.remote cache
1991 'cache': cache # controls the vcs.remote cache
2006 }
1992 }
2007 repo = backend(
1993
2008 safe_str(repo_full_path), config=config, create=False,
1994 repo = get_vcs_instance(
2009 with_wire=custom_wire)
1995 repo_path=safe_str(self.repo_full_path),
1996 config=config,
1997 with_wire=custom_wire,
1998 create=False)
2010
1999
2011 return repo
2000 return repo
2012
2001
@@ -3399,10 +3388,9 b' class Gist(Base, BaseModel):'
3399 # SCM functions
3388 # SCM functions
3400
3389
3401 def scm_instance(self, **kwargs):
3390 def scm_instance(self, **kwargs):
3402 from rhodecode.lib.vcs import get_repo
3391 full_repo_path = os.path.join(self.base_path(), self.gist_access_id)
3403 base_path = self.base_path()
3392 return get_vcs_instance(
3404 return get_repo(os.path.join(*map(safe_str,
3393 repo_path=safe_str(full_repo_path), create=False)
3405 [base_path, self.gist_access_id])))
3406
3394
3407
3395
3408 class DbMigrateVersion(Base, BaseModel):
3396 class DbMigrateVersion(Base, BaseModel):
General Comments 0
You need to be logged in to leave comments. Login now