Show More
@@ -0,0 +1,35 | |||
|
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 | ||
|
10 | import os, urllib | |
|
11 | import localrepo, httprangereader, filelog, manifest, changelog | |
|
12 | ||
|
13 | def opener(base): | |
|
14 | """return a function that opens files over http""" | |
|
15 | p = base | |
|
16 | def o(path, mode="r"): | |
|
17 | f = os.path.join(p, urllib.quote(path)) | |
|
18 | return httprangereader.httprangereader(f) | |
|
19 | return o | |
|
20 | ||
|
21 | class statichttprepository(localrepo.localrepository): | |
|
22 | def __init__(self, ui, path): | |
|
23 | self.path = (path + "/.hg") | |
|
24 | self.ui = ui | |
|
25 | self.opener = opener(self.path) | |
|
26 | self.manifest = manifest.manifest(self.opener) | |
|
27 | self.changelog = changelog.changelog(self.opener) | |
|
28 | self.tagscache = None | |
|
29 | self.nodetagscache = None | |
|
30 | ||
|
31 | def dev(self): | |
|
32 | return -1 | |
|
33 | ||
|
34 | def local(self): | |
|
35 | return False |
@@ -9,7 +9,7 import util | |||
|
9 | 9 | from node import * |
|
10 | 10 | from repo import * |
|
11 | 11 | from demandload import * |
|
12 | demandload(globals(), "localrepo httprepo sshrepo") | |
|
12 | demandload(globals(), "localrepo httprepo sshrepo statichttprepo") | |
|
13 | 13 | |
|
14 | 14 | def repository(ui, path=None, create=0): |
|
15 | 15 | if path: |
@@ -21,8 +21,8 def repository(ui, path=None, create=0): | |||
|
21 | 21 | return httprepo.httprepository( |
|
22 | 22 | ui, path.replace("hg://", "http://")) |
|
23 | 23 | if path.startswith("old-http://"): |
|
24 |
return |
|
|
25 |
ui |
|
|
24 | return statichttprepo.statichttprepository( | |
|
25 | ui, path.replace("old-http://", "http://")) | |
|
26 | 26 | if path.startswith("ssh://"): |
|
27 | 27 | return sshrepo.sshrepository(ui, path) |
|
28 | 28 |
@@ -13,11 +13,6 demandload(globals(), "re lock transacti | |||
|
13 | 13 | |
|
14 | 14 | class localrepository: |
|
15 | 15 | def __init__(self, ui, opener, path=None, create=0): |
|
16 | self.remote = 0 | |
|
17 | if path and path.startswith("http://"): | |
|
18 | self.remote = 1 | |
|
19 | self.path = path | |
|
20 | else: | |
|
21 | 16 |
|
|
22 | 17 |
|
|
23 | 18 |
|
@@ -44,7 +39,6 class localrepository: | |||
|
44 | 39 | self.tagscache = None |
|
45 | 40 | self.nodetagscache = None |
|
46 | 41 | |
|
47 | if not self.remote: | |
|
48 | 42 |
|
|
49 | 43 |
|
|
50 | 44 |
|
@@ -142,11 +136,10 class localrepository: | |||
|
142 | 136 | raise repo.RepoError("unknown revision '%s'" % key) |
|
143 | 137 | |
|
144 | 138 | def dev(self): |
|
145 | if self.remote: return -1 | |
|
146 | 139 | return os.stat(self.path).st_dev |
|
147 | 140 | |
|
148 | 141 | def local(self): |
|
149 |
return |
|
|
142 | return True | |
|
150 | 143 | |
|
151 | 144 | def join(self, f): |
|
152 | 145 | return os.path.join(self.path, f) |
@@ -243,10 +243,6 def opener(base): | |||
|
243 | 243 | """ |
|
244 | 244 | p = base |
|
245 | 245 | def o(path, mode="r"): |
|
246 | if p.startswith("http://"): | |
|
247 | f = os.path.join(p, urllib.quote(path)) | |
|
248 | return httprangereader.httprangereader(f) | |
|
249 | ||
|
250 | 246 | f = os.path.join(p, path) |
|
251 | 247 | |
|
252 | 248 | mode += "b" # for that other OS |
General Comments 0
You need to be logged in to leave comments.
Login now