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