Show More
@@ -0,0 +1,35 b'' | |||
|
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 b' 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 b' 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,22 +13,17 b' 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 |
|
|
|
20 | else: | |
|
21 | if not path: | |
|
22 |
|
|
|
23 |
|
|
|
24 | oldp = p | |
|
25 | p = os.path.dirname(p) | |
|
26 | if p == oldp: raise repo.RepoError("no repo found") | |
|
27 | path = p | |
|
28 | self.path = os.path.join(path, ".hg") | |
|
16 | if not path: | |
|
17 | p = os.getcwd() | |
|
18 | while not os.path.isdir(os.path.join(p, ".hg")): | |
|
19 | oldp = p | |
|
20 | p = os.path.dirname(p) | |
|
21 | if p == oldp: raise repo.RepoError("no repo found") | |
|
22 | path = p | |
|
23 | self.path = os.path.join(path, ".hg") | |
|
29 | 24 | |
|
30 |
|
|
|
31 |
|
|
|
25 | if not create and not os.path.isdir(self.path): | |
|
26 | raise repo.RepoError("repository %s not found" % self.path) | |
|
32 | 27 | |
|
33 | 28 | self.root = os.path.abspath(path) |
|
34 | 29 | self.ui = ui |
@@ -44,11 +39,10 b' class localrepository:' | |||
|
44 | 39 | self.tagscache = None |
|
45 | 40 | self.nodetagscache = None |
|
46 | 41 | |
|
47 | if not self.remote: | |
|
48 | self.dirstate = dirstate.dirstate(self.opener, ui, self.root) | |
|
49 | try: | |
|
50 | self.ui.readconfig(self.opener("hgrc")) | |
|
51 | except IOError: pass | |
|
42 | self.dirstate = dirstate.dirstate(self.opener, ui, self.root) | |
|
43 | try: | |
|
44 | self.ui.readconfig(self.opener("hgrc")) | |
|
45 | except IOError: pass | |
|
52 | 46 | |
|
53 | 47 | def hook(self, name, **args): |
|
54 | 48 | s = self.ui.config("hooks", name) |
@@ -142,11 +136,10 b' 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 b' 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