Show More
@@ -17,6 +17,7 b' import socket' | |||||
17 | from mercurial.i18n import _ |
|
17 | from mercurial.i18n import _ | |
18 |
|
18 | |||
19 | from mercurial import ( |
|
19 | from mercurial import ( | |
|
20 | encoding, | |||
20 | error, |
|
21 | error, | |
21 | pathutil, |
|
22 | pathutil, | |
22 | pycompat, |
|
23 | pycompat, | |
@@ -26,6 +27,10 b' from mercurial import (' | |||||
26 | worker, |
|
27 | worker, | |
27 | ) |
|
28 | ) | |
28 |
|
29 | |||
|
30 | from mercurial.utils import ( | |||
|
31 | stringutil, | |||
|
32 | ) | |||
|
33 | ||||
29 | from ..largefiles import lfutil |
|
34 | from ..largefiles import lfutil | |
30 |
|
35 | |||
31 | # 64 bytes for SHA256 |
|
36 | # 64 bytes for SHA256 | |
@@ -231,6 +236,30 b' class local(object):' | |||||
231 | False otherwise.""" |
|
236 | False otherwise.""" | |
232 | return self.cachevfs.exists(oid) or self.vfs.exists(oid) |
|
237 | return self.cachevfs.exists(oid) or self.vfs.exists(oid) | |
233 |
|
238 | |||
|
239 | def _urlerrorreason(urlerror): | |||
|
240 | '''Create a friendly message for the given URLError to be used in an | |||
|
241 | LfsRemoteError message. | |||
|
242 | ''' | |||
|
243 | inst = urlerror | |||
|
244 | ||||
|
245 | if isinstance(urlerror.reason, Exception): | |||
|
246 | inst = urlerror.reason | |||
|
247 | ||||
|
248 | if util.safehasattr(inst, 'reason'): | |||
|
249 | try: # usually it is in the form (errno, strerror) | |||
|
250 | reason = inst.reason.args[1] | |||
|
251 | except (AttributeError, IndexError): | |||
|
252 | # it might be anything, for example a string | |||
|
253 | reason = inst.reason | |||
|
254 | if isinstance(reason, pycompat.unicode): | |||
|
255 | # SSLError of Python 2.7.9 contains a unicode | |||
|
256 | reason = encoding.unitolocal(reason) | |||
|
257 | return reason | |||
|
258 | elif getattr(inst, "strerror", None): | |||
|
259 | return encoding.strtolocal(inst.strerror) | |||
|
260 | else: | |||
|
261 | return stringutil.forcebytestr(urlerror) | |||
|
262 | ||||
234 | class _gitlfsremote(object): |
|
263 | class _gitlfsremote(object): | |
235 |
|
264 | |||
236 | def __init__(self, repo, url): |
|
265 | def __init__(self, repo, url): | |
@@ -279,6 +308,11 b' class _gitlfsremote(object):' | |||||
279 | } |
|
308 | } | |
280 | hint = hints.get(ex.code, _('api=%s, action=%s') % (url, action)) |
|
309 | hint = hints.get(ex.code, _('api=%s, action=%s') % (url, action)) | |
281 | raise LfsRemoteError(_('LFS HTTP error: %s') % ex, hint=hint) |
|
310 | raise LfsRemoteError(_('LFS HTTP error: %s') % ex, hint=hint) | |
|
311 | except util.urlerr.urlerror as ex: | |||
|
312 | hint = (_('the "lfs.url" config may be used to override %s') | |||
|
313 | % self.baseurl) | |||
|
314 | raise LfsRemoteError(_('LFS error: %s') % _urlerrorreason(ex), | |||
|
315 | hint=hint) | |||
282 | try: |
|
316 | try: | |
283 | response = json.loads(rawjson) |
|
317 | response = json.loads(rawjson) | |
284 | except ValueError: |
|
318 | except ValueError: | |
@@ -409,6 +443,11 b' class _gitlfsremote(object):' | |||||
409 | self.ui.debug('%s: %s\n' % (oid, ex.read())) |
|
443 | self.ui.debug('%s: %s\n' % (oid, ex.read())) | |
410 | raise LfsRemoteError(_('HTTP error: %s (oid=%s, action=%s)') |
|
444 | raise LfsRemoteError(_('HTTP error: %s (oid=%s, action=%s)') | |
411 | % (ex, oid, action)) |
|
445 | % (ex, oid, action)) | |
|
446 | except util.urlerr.urlerror as ex: | |||
|
447 | hint = (_('attempted connection to %s') | |||
|
448 | % util.urllibcompat.getfullurl(request)) | |||
|
449 | raise LfsRemoteError(_('LFS error: %s') % _urlerrorreason(ex), | |||
|
450 | hint=hint) | |||
412 |
|
451 | |||
413 | def _batch(self, pointers, localstore, action): |
|
452 | def _batch(self, pointers, localstore, action): | |
414 | if action not in ['upload', 'download']: |
|
453 | if action not in ['upload', 'download']: |
@@ -81,6 +81,11 b' Reasonable hint for a misconfigured blob' | |||||
81 | (the "lfs.url" config may be used to override http://localhost:$HGPORT/missing) |
|
81 | (the "lfs.url" config may be used to override http://localhost:$HGPORT/missing) | |
82 | [255] |
|
82 | [255] | |
83 |
|
83 | |||
|
84 | $ hg -R httpclone update default --config lfs.url=http://localhost:$HGPORT2/missing | |||
|
85 | abort: LFS error: *onnection *refused*! (glob) | |||
|
86 | (the "lfs.url" config may be used to override http://localhost:$HGPORT2/missing) | |||
|
87 | [255] | |||
|
88 | ||||
84 | Blob URIs are correct when --prefix is used |
|
89 | Blob URIs are correct when --prefix is used | |
85 |
|
90 | |||
86 | $ hg clone --debug http://localhost:$HGPORT/subdir/mount/point cloned2 |
|
91 | $ hg clone --debug http://localhost:$HGPORT/subdir/mount/point cloned2 |
General Comments 0
You need to be logged in to leave comments.
Login now