Mercurial > hg > mercurial-crew-with-dirclash
annotate mercurial/statichttprepo.py @ 1504:0fcdd126642d
fix file opening for some commands on Windows
Using file as opener in debug commands won't work on Windows, as the
index and data files needs to be opened in binary mode.
author | Christian Boos <cboos@neuf.fr> |
---|---|
date | Thu, 03 Nov 2005 14:24:07 -0800 |
parents | 57220daf40e9 |
children | 14d1f1868bf6 11d12bd6e1dc |
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) |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
18 except urllib2.URLError, inst: |
57220daf40e9
Move urllib error handling from revlog into statichttprepo, where it belongs.
Bryan O'Sullivan <bos@serpentine.com>
parents:
1101
diff
changeset
|
19 raise IOError(None, str(inst)) |
1101 | 20 |
21 def opener(base): | |
22 """return a function that opens files over http""" | |
23 p = base | |
24 def o(path, mode="r"): | |
25 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
|
26 return rangereader(f) |
1101 | 27 return o |
28 | |
29 class statichttprepository(localrepo.localrepository): | |
30 def __init__(self, ui, path): | |
31 self.path = (path + "/.hg") | |
32 self.ui = ui | |
33 self.opener = opener(self.path) | |
34 self.manifest = manifest.manifest(self.opener) | |
35 self.changelog = changelog.changelog(self.opener) | |
36 self.tagscache = None | |
37 self.nodetagscache = None | |
38 | |
39 def dev(self): | |
40 return -1 | |
41 | |
42 def local(self): | |
43 return False |