# HG changeset patch # User mpm@selenic.com # Date 1125185333 25200 # Node ID 2cf5c8a4eae5dc70c375fe56cddf9d764934495a # Parent d6b6a15cc7c6860f4877ff222cbc76e68f9452a4 Separate out old-http support - create new statichttprepo class - pull remote bits out of localrepo - pull remote bits out of util.opener - switch hg.repository to use statichttprepo diff -r d6b6a15cc7c6 -r 2cf5c8a4eae5 mercurial/hg.py --- a/mercurial/hg.py Sat Aug 27 15:35:37 2005 -0700 +++ b/mercurial/hg.py Sat Aug 27 16:28:53 2005 -0700 @@ -9,7 +9,7 @@ from node import * from repo import * from demandload import * -demandload(globals(), "localrepo httprepo sshrepo") +demandload(globals(), "localrepo httprepo sshrepo statichttprepo") def repository(ui, path=None, create=0): if path: @@ -21,8 +21,8 @@ return httprepo.httprepository( ui, path.replace("hg://", "http://")) if path.startswith("old-http://"): - return localrepo.localrepository( - ui, util.opener, path.replace("old-http://", "http://")) + return statichttprepo.statichttprepository( + ui, path.replace("old-http://", "http://")) if path.startswith("ssh://"): return sshrepo.sshrepository(ui, path) diff -r d6b6a15cc7c6 -r 2cf5c8a4eae5 mercurial/localrepo.py --- a/mercurial/localrepo.py Sat Aug 27 15:35:37 2005 -0700 +++ b/mercurial/localrepo.py Sat Aug 27 16:28:53 2005 -0700 @@ -13,22 +13,17 @@ class localrepository: def __init__(self, ui, opener, path=None, create=0): - self.remote = 0 - if path and path.startswith("http://"): - self.remote = 1 - self.path = path - else: - if not path: - p = os.getcwd() - while not os.path.isdir(os.path.join(p, ".hg")): - oldp = p - p = os.path.dirname(p) - if p == oldp: raise repo.RepoError("no repo found") - path = p - self.path = os.path.join(path, ".hg") + if not path: + p = os.getcwd() + while not os.path.isdir(os.path.join(p, ".hg")): + oldp = p + p = os.path.dirname(p) + if p == oldp: raise repo.RepoError("no repo found") + path = p + self.path = os.path.join(path, ".hg") - if not create and not os.path.isdir(self.path): - raise repo.RepoError("repository %s not found" % self.path) + if not create and not os.path.isdir(self.path): + raise repo.RepoError("repository %s not found" % self.path) self.root = os.path.abspath(path) self.ui = ui @@ -44,11 +39,10 @@ self.tagscache = None self.nodetagscache = None - if not self.remote: - self.dirstate = dirstate.dirstate(self.opener, ui, self.root) - try: - self.ui.readconfig(self.opener("hgrc")) - except IOError: pass + self.dirstate = dirstate.dirstate(self.opener, ui, self.root) + try: + self.ui.readconfig(self.opener("hgrc")) + except IOError: pass def hook(self, name, **args): s = self.ui.config("hooks", name) @@ -142,11 +136,10 @@ raise repo.RepoError("unknown revision '%s'" % key) def dev(self): - if self.remote: return -1 return os.stat(self.path).st_dev def local(self): - return not self.remote + return True def join(self, f): return os.path.join(self.path, f) diff -r d6b6a15cc7c6 -r 2cf5c8a4eae5 mercurial/statichttprepo.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mercurial/statichttprepo.py Sat Aug 27 16:28:53 2005 -0700 @@ -0,0 +1,35 @@ +# statichttprepo.py - simple http repository class for mercurial +# +# This provides read-only repo access to repositories exported via static http +# +# Copyright 2005 Matt Mackall +# +# This software may be used and distributed according to the terms +# of the GNU General Public License, incorporated herein by reference. + +import os, urllib +import localrepo, httprangereader, filelog, manifest, changelog + +def opener(base): + """return a function that opens files over http""" + p = base + def o(path, mode="r"): + f = os.path.join(p, urllib.quote(path)) + return httprangereader.httprangereader(f) + return o + +class statichttprepository(localrepo.localrepository): + def __init__(self, ui, path): + self.path = (path + "/.hg") + self.ui = ui + self.opener = opener(self.path) + self.manifest = manifest.manifest(self.opener) + self.changelog = changelog.changelog(self.opener) + self.tagscache = None + self.nodetagscache = None + + def dev(self): + return -1 + + def local(self): + return False diff -r d6b6a15cc7c6 -r 2cf5c8a4eae5 mercurial/util.py --- a/mercurial/util.py Sat Aug 27 15:35:37 2005 -0700 +++ b/mercurial/util.py Sat Aug 27 16:28:53 2005 -0700 @@ -243,10 +243,6 @@ """ p = base def o(path, mode="r"): - if p.startswith("http://"): - f = os.path.join(p, urllib.quote(path)) - return httprangereader.httprangereader(f) - f = os.path.join(p, path) mode += "b" # for that other OS