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 |
|
|
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
|