Changeset - f4b20558ae16
[Not reviewed]
beta
0 2 0
domruf - 13 years ago 2012-08-01 14:10:26
dominikruf@gmail.com
allow cloning with hgsubversion (reimplementing pull request 46)

sadly I get a exception from hg-git when doing the same for git+http URLs
so I did not implement it for hg-git
2 files changed with 21 insertions and 3 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -267,12 +267,15 @@ class MercurialRepository(BaseRepository
 
        from mercurial.url import httpbasicauthhandler, httpdigestauthhandler
 

	
 
        # check first if it's not an local url
 
        if os.path.isdir(url) or url.startswith('file:'):
 
            return True
 

	
 
        if('+' in url[:url.find('://')]):
 
            url = url[url.find('+')+1:]
 

	
 
        handlers = []
 
        test_uri, authinfo = Url(url).authinfo()
 

	
 
        if authinfo:
 
            #create a password manager
 
            passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
rhodecode/model/validators.py
Show inline comments
 
@@ -374,31 +374,46 @@ def ValidCloneUri():
 
        if repo_type == 'hg':
 
            from mercurial.httprepo import httprepository, httpsrepository
 
            if proto == 'https':
 
                httpsrepository(make_ui('db'), url).capabilities
 
            elif proto == 'http':
 
                httprepository(make_ui('db'), url).capabilities
 
            elif proto == 'svn+http':
 
                svnremoterepo(make_ui('db'), url).capabilities
 
        elif repo_type == 'git':
 
            #TODO: write a git url validator
 
            pass
 

	
 
    class _validator(formencode.validators.FancyValidator):
 
        messages = {
 
            'clone_uri': _(u'invalid clone url'),
 
            'invalid_clone_uri': _(u'Invalid clone url, provide a '
 
                                    'valid clone http\s url')
 
                                    'valid clone http(s)/svn+http(s) url')
 
        }
 

	
 
        def validate_python(self, value, state):
 
            repo_type = value.get('repo_type')
 
            url = value.get('clone_uri')
 

	
 
            if not url:
 
                pass
 
            elif url.startswith('https') or url.startswith('http'):
 
                _type = 'https' if url.startswith('https') else 'http'
 
            elif url.startswith('https') or \
 
                url.startswith('http') or \
 
                url.startswith('svn+http'):
 
                if url.startswith('https'):
 
                    _type = 'https'
 
                elif url.startswith('http'):
 
                    _type = 'http'
 
                elif url.startswith('svn+http'):
 
                    try:
 
                        from hgsubversion.svnrepo import svnremoterepo
 
                        global svnremoterepo
 
                    except ImportError:
 
                        raise formencode.Invalid(_('invalid clone url: hgsubversion '
 
                                                   'is not installed'), value, state)
 
                    _type = 'svn+http'
 
                try:
 
                    url_handler(repo_type, url, _type, make_ui('db'))
 
                except Exception:
 
                    log.exception('Url validation failed')
 
                    msg = M(self, 'clone_uri')
 
                    raise formencode.Invalid(msg, value, state,
0 comments (0 inline, 0 general)