comparison mercurial/statichttprepo.py @ 1325:57220daf40e9

Move urllib error handling from revlog into statichttprepo, where it belongs.
author Bryan O'Sullivan <bos@serpentine.com>
date Fri, 23 Sep 2005 00:05:16 -0700
parents 2cf5c8a4eae5
children 14d1f1868bf6 11d12bd6e1dc
comparison
equal deleted inserted replaced
1323:60200b3fc839 1325:57220daf40e9
5 # Copyright 2005 Matt Mackall <mpm@selenic.com> 5 # Copyright 2005 Matt Mackall <mpm@selenic.com>
6 # 6 #
7 # This software may be used and distributed according to the terms 7 # This software may be used and distributed according to the terms
8 # of the GNU General Public License, incorporated herein by reference. 8 # of the GNU General Public License, incorporated herein by reference.
9 9
10 import os, urllib 10 from demandload import demandload
11 import localrepo, httprangereader, filelog, manifest, changelog 11 demandload(globals(), "changelog filelog httprangereader")
12 demandload(globals(), "localrepo manifest os urllib urllib2")
13
14 class rangereader(httprangereader.httprangereader):
15 def read(self, size=None):
16 try:
17 return httprangereader.httprangereader.read(self, size)
18 except urllib2.URLError, inst:
19 raise IOError(None, str(inst))
12 20
13 def opener(base): 21 def opener(base):
14 """return a function that opens files over http""" 22 """return a function that opens files over http"""
15 p = base 23 p = base
16 def o(path, mode="r"): 24 def o(path, mode="r"):
17 f = os.path.join(p, urllib.quote(path)) 25 f = os.path.join(p, urllib.quote(path))
18 return httprangereader.httprangereader(f) 26 return rangereader(f)
19 return o 27 return o
20 28
21 class statichttprepository(localrepo.localrepository): 29 class statichttprepository(localrepo.localrepository):
22 def __init__(self, ui, path): 30 def __init__(self, ui, path):
23 self.path = (path + "/.hg") 31 self.path = (path + "/.hg")