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