mercurial/statichttprepo.py
changeset 52640 24ee91ba9aa8
parent 52163 7346f93be7a4
child 52643 5cc8deb96b48
equal deleted inserted replaced
52639:9db77d46de79 52640:24ee91ba9aa8
    70         except urlerr.httperror as inst:
    70         except urlerr.httperror as inst:
    71             num = inst.code == 404 and errno.ENOENT or None
    71             num = inst.code == 404 and errno.ENOENT or None
    72             # Explicitly convert the exception to str as Py3 will try
    72             # Explicitly convert the exception to str as Py3 will try
    73             # convert it to local encoding and with as the HTTPResponse
    73             # convert it to local encoding and with as the HTTPResponse
    74             # instance doesn't support encode.
    74             # instance doesn't support encode.
    75             raise IOError(num, str(inst))
    75             raise OSError(num, str(inst))
    76         except urlerr.urlerror as inst:
    76         except urlerr.urlerror as inst:
    77             raise IOError(None, inst.reason)
    77             raise OSError(None, inst.reason)
    78 
    78 
    79         if code == 200:
    79         if code == 200:
    80             # HTTPRangeHandler does nothing if remote does not support
    80             # HTTPRangeHandler does nothing if remote does not support
    81             # Range headers and returns the full entity. Let's slice it.
    81             # Range headers and returns the full entity. Let's slice it.
    82             if n > 0 and (self.pos + n) < len(data):
    82             if n > 0 and (self.pos + n) < len(data):
   138             self.base = base
   138             self.base = base
   139             self.options = {}
   139             self.options = {}
   140 
   140 
   141         def __call__(self, path, mode=b'r', *args, **kw):
   141         def __call__(self, path, mode=b'r', *args, **kw):
   142             if mode not in (b'r', b'rb'):
   142             if mode not in (b'r', b'rb'):
   143                 raise IOError('Permission denied')
   143                 raise OSError('Permission denied')
   144             f = b"/".join((self.base, urlreq.quote(path)))
   144             f = b"/".join((self.base, urlreq.quote(path)))
   145             return httprangereader(f, urlopener)
   145             return httprangereader(f, urlopener)
   146 
   146 
   147         def _auditpath(self, path: bytes, mode: bytes) -> None:
   147         def _auditpath(self, path: bytes, mode: bytes) -> None:
   148             raise NotImplementedError
   148             raise NotImplementedError