# HG changeset patch # User Johannes Bornhold # Date 2016-09-01 11:03:28 # Node ID da50e6f0b152fc0c1661395fb24fa75da3252dc0 # Parent 265fb3a021fb28b31977f12423bcf7c19f0e5d86 hg: Add logging around check_url Add useful logging around check_url. This is especially useful when things go wrong. diff --git a/vcsserver/hg.py b/vcsserver/hg.py --- a/vcsserver/hg.py +++ b/vcsserver/hg.py @@ -316,6 +316,7 @@ class HgRemote(object): @reraise_safe_exceptions def check_url(self, url, config): + log.info("Checking URL for remote cloning/import: %s", url) _proto = None if '+' in url[:url.find('://')]: _proto = url[0:url.find('+')] @@ -345,10 +346,12 @@ class HgRemote(object): req = urllib2.Request(cu, None, {}) try: + log.debug("Trying to open URL %s", url) resp = o.open(req) if resp.code != 200: raise exceptions.URLError('Return Code is not 200') except Exception as e: + log.warning("URL cannot be opened: %s", url, exc_info=True) # means it cannot be cloned raise exceptions.URLError("[%s] org_exc: %s" % (cleaned_uri, e)) @@ -358,12 +361,16 @@ class HgRemote(object): pass else: # check for pure hg repos + log.debug( + "Verifying if URL is a Mercurial repository: %s", url) httppeer(make_ui_from_config(config), url).lookup('tip') except Exception as e: + log.warning("URL is not a valid Mercurial repository: %s", url) raise exceptions.URLError( "url [%s] does not look like an hg repo org_exc: %s" % (cleaned_uri, e)) + log.info("URL is a valid Mercurial repository: %s", url) return True @reraise_safe_exceptions