Show More
@@ -370,14 +370,15 b' def SlugifyName():' | |||
|
370 | 370 | def ValidCloneUri(): |
|
371 | 371 | from rhodecode.lib.utils import make_ui |
|
372 | 372 | |
|
373 |
def url_handler(repo_type, url, |
|
|
373 | def url_handler(repo_type, url, ui=None): | |
|
374 | 374 | if repo_type == 'hg': |
|
375 | 375 | from mercurial.httprepo import httprepository, httpsrepository |
|
376 |
if |
|
|
376 | if url.startswith('https'): | |
|
377 | 377 | httpsrepository(make_ui('db'), url).capabilities |
|
378 |
elif |
|
|
378 | elif url.startswith('http'): | |
|
379 | 379 | httprepository(make_ui('db'), url).capabilities |
|
380 |
elif |
|
|
380 | elif url.startswith('svn+http'): | |
|
381 | from hgsubversion.svnrepo import svnremoterepo | |
|
381 | 382 | svnremoterepo(make_ui('db'), url).capabilities |
|
382 | 383 | elif repo_type == 'git': |
|
383 | 384 | #TODO: write a git url validator |
@@ -396,34 +397,15 b' def ValidCloneUri():' | |||
|
396 | 397 | |
|
397 | 398 | if not url: |
|
398 | 399 | pass |
|
399 | elif url.startswith('https') or \ | |
|
400 | url.startswith('http') or \ | |
|
401 | url.startswith('svn+http'): | |
|
402 | if url.startswith('https'): | |
|
403 | _type = 'https' | |
|
404 | elif url.startswith('http'): | |
|
405 | _type = 'http' | |
|
406 | elif url.startswith('svn+http'): | |
|
400 | else: | |
|
407 | 401 |
|
|
408 | from hgsubversion.svnrepo import svnremoterepo | |
|
409 | global svnremoterepo | |
|
410 | except ImportError: | |
|
411 | raise formencode.Invalid(_('invalid clone url: hgsubversion ' | |
|
412 | 'is not installed'), value, state) | |
|
413 | _type = 'svn+http' | |
|
414 | try: | |
|
415 | url_handler(repo_type, url, _type, make_ui('db')) | |
|
402 | url_handler(repo_type, url, make_ui('db')) | |
|
416 | 403 | except Exception: |
|
417 | 404 | log.exception('Url validation failed') |
|
418 | 405 | msg = M(self, 'clone_uri') |
|
419 | 406 | raise formencode.Invalid(msg, value, state, |
|
420 | 407 | error_dict=dict(clone_uri=msg) |
|
421 | 408 | ) |
|
422 | else: | |
|
423 | msg = M(self, 'invalid_clone_uri', state) | |
|
424 | raise formencode.Invalid(msg, value, state, | |
|
425 | error_dict=dict(clone_uri=msg) | |
|
426 | ) | |
|
427 | 409 | return _validator |
|
428 | 410 | |
|
429 | 411 |
General Comments 0
You need to be logged in to leave comments.
Login now