##// END OF EJS Templates
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan -
r1325:57220daf default
parent child Browse files
Show More
@@ -2160,6 +2160,8 b' def dispatch(args):'
2160 2160 u.warn("abort: %s\n" % inst)
2161 2161 elif hasattr(inst, "reason"):
2162 2162 u.warn("abort: error: %s\n" % inst.reason[1])
2163 elif getattr(inst, "strerror", None):
2164 u.warn("abort: %s\n" % inst.strerror)
2163 2165 elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
2164 2166 if u.debugflag:
2165 2167 u.warn("broken pipe\n")
@@ -12,7 +12,7 b' of the GNU General Public License, incor'
12 12
13 13 from node import *
14 14 from demandload import demandload
15 demandload(globals(), "binascii errno heapq mdiff sha struct urllib2 zlib")
15 demandload(globals(), "binascii errno heapq mdiff sha struct zlib")
16 16
17 17 def hash(text, p1, p2):
18 18 """generate a hash from the given text and its parent hashes
@@ -179,8 +179,6 b' class revlog:'
179 179
180 180 try:
181 181 i = self.opener(self.indexfile).read()
182 except urllib2.URLError:
183 raise
184 182 except IOError, inst:
185 183 if inst.errno != errno.ENOENT:
186 184 raise
@@ -7,15 +7,23 b''
7 7 # This software may be used and distributed according to the terms
8 8 # of the GNU General Public License, incorporated herein by reference.
9 9
10 import os, urllib
11 import localrepo, httprangereader, filelog, manifest, changelog
10 from demandload import demandload
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 21 def opener(base):
14 22 """return a function that opens files over http"""
15 23 p = base
16 24 def o(path, mode="r"):
17 25 f = os.path.join(p, urllib.quote(path))
18 return httprangereader.httprangereader(f)
26 return rangereader(f)
19 27 return o
20 28
21 29 class statichttprepository(localrepo.localrepository):
General Comments 0
You need to be logged in to leave comments. Login now