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