##// 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 u.warn("abort: %s\n" % inst)
2160 u.warn("abort: %s\n" % inst)
2161 elif hasattr(inst, "reason"):
2161 elif hasattr(inst, "reason"):
2162 u.warn("abort: error: %s\n" % inst.reason[1])
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 elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
2165 elif hasattr(inst, "args") and inst[0] == errno.EPIPE:
2164 if u.debugflag:
2166 if u.debugflag:
2165 u.warn("broken pipe\n")
2167 u.warn("broken pipe\n")
@@ -12,7 +12,7 b' of the GNU General Public License, incor'
12
12
13 from node import *
13 from node import *
14 from demandload import demandload
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 def hash(text, p1, p2):
17 def hash(text, p1, p2):
18 """generate a hash from the given text and its parent hashes
18 """generate a hash from the given text and its parent hashes
@@ -179,8 +179,6 b' class revlog:'
179
179
180 try:
180 try:
181 i = self.opener(self.indexfile).read()
181 i = self.opener(self.indexfile).read()
182 except urllib2.URLError:
183 raise
184 except IOError, inst:
182 except IOError, inst:
185 if inst.errno != errno.ENOENT:
183 if inst.errno != errno.ENOENT:
186 raise
184 raise
@@ -7,15 +7,23 b''
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):
General Comments 0
You need to be logged in to leave comments. Login now