diff --git a/rhodecode/__init__.py b/rhodecode/__init__.py --- a/rhodecode/__init__.py +++ b/rhodecode/__init__.py @@ -33,3 +33,8 @@ def get_version(): Returns shorter version (digit parts only) as string. """ return '.'.join((str(each) for each in VERSION[:3])) + +BACKENDS = { + 'hg': 'Mercurial repository', + #'git': 'Git repository', +} diff --git a/rhodecode/lib/base.py b/rhodecode/lib/base.py --- a/rhodecode/lib/base.py +++ b/rhodecode/lib/base.py @@ -10,7 +10,7 @@ from rhodecode.lib import auth from rhodecode.lib.utils import get_repo_slug from rhodecode.model import meta from rhodecode.model.scm import ScmModel -from vcs import BACKENDS +from rhodecode import BACKENDS class BaseController(WSGIController): diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -31,7 +31,7 @@ from rhodecode.model.user import UserMod from rhodecode.model.repo import RepoModel from rhodecode.model.db import User from webhelpers.pylonslib.secure_form import authentication_token -from vcs import BACKENDS +from rhodecode import BACKENDS import formencode import logging import os @@ -301,28 +301,28 @@ def PasswordResetForm(): email = All(ValidSystemEmail(), Email(not_empty=True)) return _PasswordResetForm -def RepoForm(edit=False, old_data={}): +def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys()): class _RepoForm(formencode.Schema): allow_extra_fields = True filter_extra_fields = False repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) description = UnicodeString(strip=True, min=1, not_empty=True) private = StringBoolean(if_missing=False) - repo_type = OneOf(BACKENDS.keys()) + repo_type = OneOf(supported_backends) if edit: user = All(Int(not_empty=True), ValidRepoUser) chained_validators = [ValidPerms] return _RepoForm -def RepoForkForm(edit=False, old_data={}): +def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys()): class _RepoForkForm(formencode.Schema): allow_extra_fields = True filter_extra_fields = False fork_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) description = UnicodeString(strip=True, min=1, not_empty=True) private = StringBoolean(if_missing=False) - repo_type = All(ValidForkType(old_data), OneOf(BACKENDS.keys())) + repo_type = All(ValidForkType(old_data), OneOf(supported_backends)) return _RepoForkForm def RepoSettingsForm(edit=False, old_data={}): diff --git a/rhodecode/model/scm.py b/rhodecode/model/scm.py --- a/rhodecode/model/scm.py +++ b/rhodecode/model/scm.py @@ -24,6 +24,7 @@ Model for RhodeCode """ from beaker.cache import cache_region, region_invalidate from mercurial import ui +from rhodecode import BACKENDS from rhodecode.lib import helpers as h from rhodecode.lib.auth import HasRepoPermissionAny from rhodecode.lib.utils import get_repos @@ -84,10 +85,10 @@ class ScmModel(object): klass = get_backend(path[0]) - if path[0] == 'hg': + if path[0] == 'hg' and path[0] in BACKENDS.keys(): repos_list[name] = klass(path[1], baseui=baseui) - if path[0] == 'git': + if path[0] == 'git' and path[0] in BACKENDS.keys(): repos_list[name] = klass(path[1]) except OSError: continue @@ -152,6 +153,7 @@ class ScmModel(object): log.debug('Creating instance of %s repository', alias) backend = get_backend(alias) + #TODO: get the baseui from somewhere for this if alias == 'hg': repo = backend(repo_path, create=False, baseui=None) #skip hidden web repository