Show More
@@ -33,3 +33,8 b' def get_version():' | |||
|
33 | 33 | Returns shorter version (digit parts only) as string. |
|
34 | 34 | """ |
|
35 | 35 | return '.'.join((str(each) for each in VERSION[:3])) |
|
36 | ||
|
37 | BACKENDS = { | |
|
38 | 'hg': 'Mercurial repository', | |
|
39 | #'git': 'Git repository', | |
|
40 | } |
@@ -10,7 +10,7 b' from rhodecode.lib import auth' | |||
|
10 | 10 | from rhodecode.lib.utils import get_repo_slug |
|
11 | 11 | from rhodecode.model import meta |
|
12 | 12 | from rhodecode.model.scm import ScmModel |
|
13 |
from |
|
|
13 | from rhodecode import BACKENDS | |
|
14 | 14 | |
|
15 | 15 | class BaseController(WSGIController): |
|
16 | 16 |
@@ -31,7 +31,7 b' from rhodecode.model.user import UserMod' | |||
|
31 | 31 | from rhodecode.model.repo import RepoModel |
|
32 | 32 | from rhodecode.model.db import User |
|
33 | 33 | from webhelpers.pylonslib.secure_form import authentication_token |
|
34 |
from |
|
|
34 | from rhodecode import BACKENDS | |
|
35 | 35 | import formencode |
|
36 | 36 | import logging |
|
37 | 37 | import os |
@@ -301,28 +301,28 b' def PasswordResetForm():' | |||
|
301 | 301 | email = All(ValidSystemEmail(), Email(not_empty=True)) |
|
302 | 302 | return _PasswordResetForm |
|
303 | 303 | |
|
304 | def RepoForm(edit=False, old_data={}): | |
|
304 | def RepoForm(edit=False, old_data={}, supported_backends=BACKENDS.keys()): | |
|
305 | 305 | class _RepoForm(formencode.Schema): |
|
306 | 306 | allow_extra_fields = True |
|
307 | 307 | filter_extra_fields = False |
|
308 | 308 | repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) |
|
309 | 309 | description = UnicodeString(strip=True, min=1, not_empty=True) |
|
310 | 310 | private = StringBoolean(if_missing=False) |
|
311 |
repo_type = OneOf( |
|
|
311 | repo_type = OneOf(supported_backends) | |
|
312 | 312 | if edit: |
|
313 | 313 | user = All(Int(not_empty=True), ValidRepoUser) |
|
314 | 314 | |
|
315 | 315 | chained_validators = [ValidPerms] |
|
316 | 316 | return _RepoForm |
|
317 | 317 | |
|
318 | def RepoForkForm(edit=False, old_data={}): | |
|
318 | def RepoForkForm(edit=False, old_data={}, supported_backends=BACKENDS.keys()): | |
|
319 | 319 | class _RepoForkForm(formencode.Schema): |
|
320 | 320 | allow_extra_fields = True |
|
321 | 321 | filter_extra_fields = False |
|
322 | 322 | fork_name = All(UnicodeString(strip=True, min=1, not_empty=True), ValidRepoName(edit, old_data)) |
|
323 | 323 | description = UnicodeString(strip=True, min=1, not_empty=True) |
|
324 | 324 | private = StringBoolean(if_missing=False) |
|
325 |
repo_type = All(ValidForkType(old_data), OneOf( |
|
|
325 | repo_type = All(ValidForkType(old_data), OneOf(supported_backends)) | |
|
326 | 326 | return _RepoForkForm |
|
327 | 327 | |
|
328 | 328 | def RepoSettingsForm(edit=False, old_data={}): |
@@ -24,6 +24,7 b' Model for RhodeCode' | |||
|
24 | 24 | """ |
|
25 | 25 | from beaker.cache import cache_region, region_invalidate |
|
26 | 26 | from mercurial import ui |
|
27 | from rhodecode import BACKENDS | |
|
27 | 28 | from rhodecode.lib import helpers as h |
|
28 | 29 | from rhodecode.lib.auth import HasRepoPermissionAny |
|
29 | 30 | from rhodecode.lib.utils import get_repos |
@@ -84,10 +85,10 b' class ScmModel(object):' | |||
|
84 | 85 | |
|
85 | 86 | klass = get_backend(path[0]) |
|
86 | 87 | |
|
87 | if path[0] == 'hg': | |
|
88 | if path[0] == 'hg' and path[0] in BACKENDS.keys(): | |
|
88 | 89 | repos_list[name] = klass(path[1], baseui=baseui) |
|
89 | 90 | |
|
90 | if path[0] == 'git': | |
|
91 | if path[0] == 'git' and path[0] in BACKENDS.keys(): | |
|
91 | 92 | repos_list[name] = klass(path[1]) |
|
92 | 93 | except OSError: |
|
93 | 94 | continue |
@@ -152,6 +153,7 b' class ScmModel(object):' | |||
|
152 | 153 | log.debug('Creating instance of %s repository', alias) |
|
153 | 154 | backend = get_backend(alias) |
|
154 | 155 | |
|
156 | #TODO: get the baseui from somewhere for this | |
|
155 | 157 | if alias == 'hg': |
|
156 | 158 | repo = backend(repo_path, create=False, baseui=None) |
|
157 | 159 | #skip hidden web repository |
General Comments 0
You need to be logged in to leave comments.
Login now