Changeset - 7a939ea3510a
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2020-03-17 17:29:57
mads@kiilerich.com
hg: handle Mercurial RepoError correctly in is_valid_repo_uri

RepoError would be leaked by is_valid_repo_uri.

Now, when for example validating an ssh URL without having the ssh client
binary, it will be shown/logged as:
remote: /bin/sh: ssh: command not found
2020-03-17 17:28:53.907 WARNI [kallithea.model.validators] validation of clone URL 'ssh://no-ssh.com/' failed: Mercurial RepoError: no suitable response from remote hg
and shown in the UI as 'Invalid repository URL'.
1 file changed with 3 insertions and 0 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/utils.py
Show inline comments
 
@@ -33,12 +33,13 @@ import sys
 
import traceback
 
import urllib.error
 
from distutils.version import StrictVersion
 

	
 
import beaker.cache
 
import mercurial.config
 
import mercurial.error
 
import mercurial.ui
 

	
 
import kallithea.config.conf
 
from kallithea.lib.exceptions import InvalidCloneUriException
 
from kallithea.lib.utils2 import ascii_bytes, aslist, get_current_authuser, safe_bytes, safe_str
 
from kallithea.lib.vcs.backends.git.repository import GitRepository
 
@@ -232,12 +233,14 @@ def is_valid_repo_uri(repo_type, url, ui
 
            # initially check if it's at least the proper URL
 
            # or does it pass basic auth
 
            try:
 
                MercurialRepository._check_url(url, ui)
 
            except urllib.error.URLError as e:
 
                raise InvalidCloneUriException('URI %s URLError: %s' % (url, e))
 
            except mercurial.error.RepoError as e:
 
                raise InvalidCloneUriException('Mercurial %s: %s' % (type(e).__name__, safe_str(bytes(e))))
 
        elif url.startswith('svn+http'):
 
            try:
 
                from hgsubversion.svnrepo import svnremoterepo
 
            except ImportError:
 
                raise InvalidCloneUriException('URI type %s not supported - hgsubversion is not available' % (url,))
 
            svnremoterepo(ui, url).svn.uuid
0 comments (0 inline, 0 general)