##// END OF EJS Templates
Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein -
r1821:0b3f4be5 default
parent child Browse files
Show More
@@ -1,45 +1,47 b''
1 1 # statichttprepo.py - simple http repository class for mercurial
2 2 #
3 3 # This provides read-only repo access to repositories exported via static http
4 4 #
5 5 # Copyright 2005 Matt Mackall <mpm@selenic.com>
6 6 #
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 10 from demandload import demandload
11 11 demandload(globals(), "changelog filelog httprangereader")
12 12 demandload(globals(), "localrepo manifest os urllib urllib2")
13 13
14 14 class rangereader(httprangereader.httprangereader):
15 15 def read(self, size=None):
16 16 try:
17 17 return httprangereader.httprangereader.read(self, size)
18 except urllib2.HTTPError, inst:
19 raise IOError(None, inst)
18 20 except urllib2.URLError, inst:
19 raise IOError(None, str(inst))
21 raise IOError(None, inst.reason[1])
20 22
21 23 def opener(base):
22 24 """return a function that opens files over http"""
23 25 p = base
24 26 def o(path, mode="r"):
25 27 f = os.path.join(p, urllib.quote(path))
26 28 return rangereader(f)
27 29 return o
28 30
29 31 class statichttprepository(localrepo.localrepository):
30 32 def __init__(self, ui, path):
31 33 self.path = (path + "/.hg")
32 34 self.ui = ui
33 35 self.opener = opener(self.path)
34 36 self.manifest = manifest.manifest(self.opener)
35 37 self.changelog = changelog.changelog(self.opener)
36 38 self.tagscache = None
37 39 self.nodetagscache = None
38 40 self.encodepats = None
39 41 self.decodepats = None
40 42
41 43 def dev(self):
42 44 return -1
43 45
44 46 def local(self):
45 47 return False
@@ -1,23 +1,23 b''
1 abort: <urlopen error (111, 'Connection refused')>
1 abort: Connection refused
2 2 255
3 3 ls: copy: No such file or directory
4 4 changeset: 0:61c9426e69fe
5 5 tag: tip
6 6 user: test
7 7 date: Thu Jan 1 00:00:00 1970 +0000
8 8 summary: test
9 9
10 10 requesting all changes
11 11 adding changesets
12 12 adding manifests
13 13 adding file changes
14 14 added 1 changesets with 1 changes to 1 files
15 15 checking changesets
16 16 checking manifests
17 17 crosschecking files in changesets and manifests
18 18 checking files
19 19 1 files, 1 changesets, 1 total revisions
20 20 foo
21 21 pulling from old-http://localhost:20059/remote
22 22 searching for changes
23 23 no changes found
General Comments 0
You need to be logged in to leave comments. Login now