def build_opener(ui, authinfo): # urllib cannot handle URLs with embedded user or passwd urlopener = url.opener(ui, authinfo) urlopener.add_handler(byterange.HTTPRangeHandler()) class statichttpopener(scmutil.abstractopener): def __init__(self, base): self.base = base def __call__(self, path, mode="r", atomictemp=None): if mode not in ('r', 'rb'): raise IOError('Permission denied') f = "/".join((self.base, urllib.quote(path))) return httprangereader(f, urlopener) return statichttpopener
def build_opener(ui, authinfo): # urllib cannot handle URLs with embedded user or passwd urlopener = url.opener(ui, authinfo) urlopener.add_handler(byterange.HTTPRangeHandler()) def opener(base): """return a function that opens files over http""" p = base def o(path, mode="r"): f = "/".join((p, urllib.quote(path))) return httprangereader(f, urlopener) return o return opener
def build_opener(ui, authinfo): # urllib cannot handle URLs with embedded user or passwd urlopener = url.opener(ui, authinfo) urlopener.add_handler(byterange.HTTPRangeHandler()) def opener(base): """return a function that opens files over http""" p = base def o(path, mode="r", atomictemp=None): if 'a' in mode or 'w' in mode: raise IOError('Permission denied') f = "/".join((p, urllib.quote(path))) return httprangereader(f, urlopener) return o return opener
def build_opener(ui, authinfo): # urllib cannot handle URLs with embedded user or passwd urlopener = url.opener(ui, authinfo) urlopener.add_handler(byterange.HTTPRangeHandler()) class statichttpvfs(scmutil.abstractvfs): def __init__(self, base): self.base = base def __call__(self, path, mode='r', *args, **kw): if mode not in ('r', 'rb'): raise IOError('Permission denied') f = "/".join((self.base, urllib.quote(path))) return httprangereader(f, urlopener) def join(self, path): if path: return os.path.join(self.base, path) else: return self.base return statichttpvfs