##// END OF EJS Templates
remote-clones: make sure we always use obfuscated url inside logs....
marcink -
r105:859d7a10 default
parent child Browse files
Show More
@@ -37,7 +37,7 b' from vcsserver import exceptions, settin'
37 from vcsserver.utils import safe_str
37 from vcsserver.utils import safe_str
38 from vcsserver.base import RepoFactory
38 from vcsserver.base import RepoFactory
39 from vcsserver.hgcompat import (
39 from vcsserver.hgcompat import (
40 hg_url, httpbasicauthhandler, httpdigestauthhandler)
40 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler)
41
41
42
42
43 DIR_STAT = stat.S_IFDIR
43 DIR_STAT = stat.S_IFDIR
@@ -152,7 +152,7 b' class GitRemote(object):'
152
152
153 def _build_opener(self, url):
153 def _build_opener(self, url):
154 handlers = []
154 handlers = []
155 url_obj = hg_url(url)
155 url_obj = url_parser(url)
156 _, authinfo = url_obj.authinfo()
156 _, authinfo = url_obj.authinfo()
157
157
158 if authinfo:
158 if authinfo:
@@ -167,10 +167,11 b' class GitRemote(object):'
167
167
168 @reraise_safe_exceptions
168 @reraise_safe_exceptions
169 def check_url(self, url, config):
169 def check_url(self, url, config):
170 url_obj = hg_url(url)
170 url_obj = url_parser(url)
171 test_uri, _ = url_obj.authinfo()
171 test_uri, _ = url_obj.authinfo()
172 url_obj.passwd = '*****'
172 url_obj.passwd = '*****'
173 cleaned_uri = str(url_obj)
173 cleaned_uri = str(url_obj)
174 log.info("Checking URL for remote cloning/import: %s", cleaned_uri)
174
175
175 if not test_uri.endswith('info/refs'):
176 if not test_uri.endswith('info/refs'):
176 test_uri = test_uri.rstrip('/') + '/info/refs'
177 test_uri = test_uri.rstrip('/') + '/info/refs'
@@ -184,12 +185,14 b' class GitRemote(object):'
184 req = urllib2.Request(cu, None, {})
185 req = urllib2.Request(cu, None, {})
185
186
186 try:
187 try:
188 log.debug("Trying to open URL %s", cleaned_uri)
187 resp = o.open(req)
189 resp = o.open(req)
188 if resp.code != 200:
190 if resp.code != 200:
189 raise Exception('Return Code is not 200')
191 raise exceptions.URLError('Return Code is not 200')
190 except Exception as e:
192 except Exception as e:
193 log.warning("URL cannot be opened: %s", cleaned_uri, exc_info=True)
191 # means it cannot be cloned
194 # means it cannot be cloned
192 raise urllib2.URLError("[%s] org_exc: %s" % (cleaned_uri, e))
195 raise exceptions.URLError("[%s] org_exc: %s" % (cleaned_uri, e))
193
196
194 # now detect if it's proper git repo
197 # now detect if it's proper git repo
195 gitdata = resp.read()
198 gitdata = resp.read()
@@ -199,7 +202,7 b' class GitRemote(object):'
199 # old style git can return some other format !
202 # old style git can return some other format !
200 pass
203 pass
201 else:
204 else:
202 raise urllib2.URLError(
205 raise exceptions.URLError(
203 "url [%s] does not look like an git" % (cleaned_uri,))
206 "url [%s] does not look like an git" % (cleaned_uri,))
204
207
205 return True
208 return True
@@ -327,7 +330,7 b' class GitRemote(object):'
327 if url != 'default' and '://' not in url:
330 if url != 'default' and '://' not in url:
328 client = LocalGitClient(url)
331 client = LocalGitClient(url)
329 else:
332 else:
330 url_obj = hg_url(url)
333 url_obj = url_parser(url)
331 o = self._build_opener(url)
334 o = self._build_opener(url)
332 url, _ = url_obj.authinfo()
335 url, _ = url_obj.authinfo()
333 client = HttpGitClient(base_url=url, opener=o)
336 client = HttpGitClient(base_url=url, opener=o)
@@ -30,11 +30,11 b' from mercurial import unionrepo'
30 from vcsserver import exceptions
30 from vcsserver import exceptions
31 from vcsserver.base import RepoFactory
31 from vcsserver.base import RepoFactory
32 from vcsserver.hgcompat import (
32 from vcsserver.hgcompat import (
33 archival, bin, clone, config as hgconfig, diffopts, hex, hg_url,
33 archival, bin, clone, config as hgconfig, diffopts, hex,
34 httpbasicauthhandler, httpdigestauthhandler, httppeer, localrepository,
34 hg_url as url_parser, httpbasicauthhandler, httpdigestauthhandler,
35 match, memctx, exchange, memfilectx, nullrev, patch, peer, revrange, ui,
35 httppeer, localrepository, match, memctx, exchange, memfilectx, nullrev,
36 Abort, LookupError, RepoError, RepoLookupError, InterventionRequired,
36 patch, peer, revrange, ui, Abort, LookupError, RepoError, RepoLookupError,
37 RequirementError)
37 InterventionRequired, RequirementError)
38
38
39 log = logging.getLogger(__name__)
39 log = logging.getLogger(__name__)
40
40
@@ -321,16 +321,16 b' class HgRemote(object):'
321
321
322 @reraise_safe_exceptions
322 @reraise_safe_exceptions
323 def check_url(self, url, config):
323 def check_url(self, url, config):
324 log.info("Checking URL for remote cloning/import: %s", url)
325 _proto = None
324 _proto = None
326 if '+' in url[:url.find('://')]:
325 if '+' in url[:url.find('://')]:
327 _proto = url[0:url.find('+')]
326 _proto = url[0:url.find('+')]
328 url = url[url.find('+') + 1:]
327 url = url[url.find('+') + 1:]
329 handlers = []
328 handlers = []
330 url_obj = hg_url(url)
329 url_obj = url_parser(url)
331 test_uri, authinfo = url_obj.authinfo()
330 test_uri, authinfo = url_obj.authinfo()
332 url_obj.passwd = '*****'
331 url_obj.passwd = '*****'
333 cleaned_uri = str(url_obj)
332 cleaned_uri = str(url_obj)
333 log.info("Checking URL for remote cloning/import: %s", cleaned_uri)
334
334
335 if authinfo:
335 if authinfo:
336 # create a password manager
336 # create a password manager
@@ -351,12 +351,12 b' class HgRemote(object):'
351 req = urllib2.Request(cu, None, {})
351 req = urllib2.Request(cu, None, {})
352
352
353 try:
353 try:
354 log.debug("Trying to open URL %s", url)
354 log.debug("Trying to open URL %s", cleaned_uri)
355 resp = o.open(req)
355 resp = o.open(req)
356 if resp.code != 200:
356 if resp.code != 200:
357 raise exceptions.URLError('Return Code is not 200')
357 raise exceptions.URLError('Return Code is not 200')
358 except Exception as e:
358 except Exception as e:
359 log.warning("URL cannot be opened: %s", url, exc_info=True)
359 log.warning("URL cannot be opened: %s", cleaned_uri, exc_info=True)
360 # means it cannot be cloned
360 # means it cannot be cloned
361 raise exceptions.URLError("[%s] org_exc: %s" % (cleaned_uri, e))
361 raise exceptions.URLError("[%s] org_exc: %s" % (cleaned_uri, e))
362
362
@@ -367,15 +367,17 b' class HgRemote(object):'
367 else:
367 else:
368 # check for pure hg repos
368 # check for pure hg repos
369 log.debug(
369 log.debug(
370 "Verifying if URL is a Mercurial repository: %s", url)
370 "Verifying if URL is a Mercurial repository: %s",
371 cleaned_uri)
371 httppeer(make_ui_from_config(config), url).lookup('tip')
372 httppeer(make_ui_from_config(config), url).lookup('tip')
372 except Exception as e:
373 except Exception as e:
373 log.warning("URL is not a valid Mercurial repository: %s", url)
374 log.warning("URL is not a valid Mercurial repository: %s",
375 cleaned_uri)
374 raise exceptions.URLError(
376 raise exceptions.URLError(
375 "url [%s] does not look like an hg repo org_exc: %s"
377 "url [%s] does not look like an hg repo org_exc: %s"
376 % (cleaned_uri, e))
378 % (cleaned_uri, e))
377
379
378 log.info("URL is a valid Mercurial repository: %s", url)
380 log.info("URL is a valid Mercurial repository: %s", cleaned_uri)
379 return True
381 return True
380
382
381 @reraise_safe_exceptions
383 @reraise_safe_exceptions
General Comments 0
You need to be logged in to leave comments. Login now