Mercurial > hg
annotate mercurial/statichttprepo.py @ 2169:4564794b6f55
Combine catching exceptions added in dd4ec4576cc8 in one except statement.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Sun, 30 Apr 2006 22:46:54 +0200 |
parents | 74d3f5336b66 |
children | 109a22f5434a |
rev | line source |
---|---|
1101 | 1 # statichttprepo.py - simple http repository class for mercurial |
2 # | |
3 # This provides read-only repo access to repositories exported via static http | |
4 # | |
5 # Copyright 2005 Matt Mackall <mpm@selenic.com> | |
6 # | |
7 # This software may be used and distributed according to the terms | |
8 # of the GNU General Public License, incorporated herein by reference. | |
9 | |
1325
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
10 from demandload import demandload |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
11 demandload(globals(), "changelog filelog httprangereader") |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
12 demandload(globals(), "localrepo manifest os urllib urllib2") |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
13 |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
14 class rangereader(httprangereader.httprangereader): |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
15 def read(self, size=None): |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
16 try: |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
17 return httprangereader.httprangereader.read(self, size) |
1821
0b3f4be5c5bf
Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1598
diff
changeset
|
18 except urllib2.HTTPError, inst: |
0b3f4be5c5bf
Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1598
diff
changeset
|
19 raise IOError(None, inst) |
1325
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
20 except urllib2.URLError, inst: |
1821
0b3f4be5c5bf
Catch urllib errors for old-http in a nicer way.
Thomas Arendsen Hein <thomas@intevation.de>
parents:
1598
diff
changeset
|
21 raise IOError(None, inst.reason[1]) |
1101 | 22 |
23 def opener(base): | |
24 """return a function that opens files over http""" | |
25 p = base | |
26 def o(path, mode="r"): | |
27 f = os.path.join(p, urllib.quote(path)) | |
1325
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
28 return rangereader(f) |
1101 | 29 return o |
30 | |
31 class statichttprepository(localrepo.localrepository): | |
32 def __init__(self, ui, path): | |
33 self.path = (path + "/.hg") | |
34 self.ui = ui | |
2072 | 35 self.revlogversion = 0 |
1101 | 36 self.opener = opener(self.path) |
37 self.manifest = manifest.manifest(self.opener) | |
38 self.changelog = changelog.changelog(self.opener) | |
39 self.tagscache = None | |
40 self.nodetagscache = None | |
1598
14d1f1868bf6
cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1325
diff
changeset
|
41 self.encodepats = None |
14d1f1868bf6
cleanup of revlog.group when repository is local
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
1325
diff
changeset
|
42 self.decodepats = None |
1101 | 43 |
44 def dev(self): | |
45 return -1 | |
46 | |
47 def local(self): | |
48 return False |