Show More
@@ -226,13 +226,40 b' def ValidRepoName(edit, old_data):' | |||||
226 |
|
226 | |||
227 | return _ValidRepoName |
|
227 | return _ValidRepoName | |
228 |
|
228 | |||
|
229 | def ValidCloneUri(): | |||
|
230 | from mercurial.httprepo import httprepository, httpsrepository | |||
|
231 | from rhodecode.lib.utils import make_ui | |||
|
232 | ||||
|
233 | class _ValidCloneUri(formencode.validators.FancyValidator): | |||
|
234 | def to_python(self, value, state): | |||
|
235 | if not value: | |||
|
236 | pass | |||
|
237 | elif value.startswith('https'): | |||
|
238 | try: | |||
|
239 | httpsrepository(make_ui('db'), value).capabilities() | |||
|
240 | except: | |||
|
241 | raise formencode.Invalid(_('invalid clone url'), value, | |||
|
242 | state) | |||
|
243 | elif value.startswith('http'): | |||
|
244 | try: | |||
|
245 | httprepository(make_ui('db'), value).capabilities() | |||
|
246 | except: | |||
|
247 | raise formencode.Invalid(_('invalid clone url'), value, | |||
|
248 | state) | |||
|
249 | else: | |||
|
250 | raise formencode.Invalid(_('Invalid clone url, provide a ' | |||
|
251 | 'valid clone http\s url'), value, | |||
|
252 | state) | |||
|
253 | ||||
|
254 | return _ValidCloneUri | |||
|
255 | ||||
229 | def ValidForkType(old_data): |
|
256 | def ValidForkType(old_data): | |
230 | class _ValidForkType(formencode.validators.FancyValidator): |
|
257 | class _ValidForkType(formencode.validators.FancyValidator): | |
231 |
|
258 | |||
232 | def to_python(self, value, state): |
|
259 | def to_python(self, value, state): | |
233 | if old_data['repo_type'] != value: |
|
260 | if old_data['repo_type'] != value: | |
234 |
raise formencode.Invalid(_('Fork have to be the same |
|
261 | raise formencode.Invalid(_('Fork have to be the same ' | |
235 | value, state) |
|
262 | 'type as original'), value, state) | |
236 | return value |
|
263 | return value | |
237 | return _ValidForkType |
|
264 | return _ValidForkType | |
238 |
|
265 | |||
@@ -457,7 +484,8 b' def RepoForm(edit=False, old_data={}, su' | |||||
457 | filter_extra_fields = False |
|
484 | filter_extra_fields = False | |
458 | repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), |
|
485 | repo_name = All(UnicodeString(strip=True, min=1, not_empty=True), | |
459 | ValidRepoName(edit, old_data)) |
|
486 | ValidRepoName(edit, old_data)) | |
460 | clone_uri = UnicodeString(strip=True, min=1, not_empty=False) |
|
487 | clone_uri = All(UnicodeString(strip=True, min=1, not_empty=False), | |
|
488 | ValidCloneUri()()) | |||
461 | repo_group = OneOf(repo_groups, hideList=True) |
|
489 | repo_group = OneOf(repo_groups, hideList=True) | |
462 | repo_type = OneOf(supported_backends) |
|
490 | repo_type = OneOf(supported_backends) | |
463 | description = UnicodeString(strip=True, min=1, not_empty=True) |
|
491 | description = UnicodeString(strip=True, min=1, not_empty=True) |
General Comments 0
You need to be logged in to leave comments.
Login now