mercurial/statichttprepo.py
author mpm@selenic.com
Tue, 20 Sep 2005 10:45:26 -0700
changeset 1280 50553b99a5c9
parent 1101 2cf5c8a4eae5
child 1325 57220daf40e9
permissions -rw-r--r--
pull/unbundle: raise an exception on premature EOF
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1101
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     1
# statichttprepo.py - simple http repository class for mercurial
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     2
#
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     3
# This provides read-only repo access to repositories exported via static http
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     4
#
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     5
# Copyright 2005 Matt Mackall <mpm@selenic.com>
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     6
#
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     7
# This software may be used and distributed according to the terms
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     8
# of the GNU General Public License, incorporated herein by reference.
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
     9
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    10
import os, urllib
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    11
import localrepo, httprangereader, filelog, manifest, changelog
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    12
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    13
def opener(base):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    14
    """return a function that opens files over http"""
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    15
    p = base
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    16
    def o(path, mode="r"):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    17
        f = os.path.join(p, urllib.quote(path))
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    18
        return httprangereader.httprangereader(f)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    19
    return o
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    20
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    21
class statichttprepository(localrepo.localrepository):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    22
    def __init__(self, ui, path):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    23
        self.path = (path + "/.hg")
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    24
        self.ui = ui
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    25
        self.opener = opener(self.path)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    26
        self.manifest = manifest.manifest(self.opener)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    27
        self.changelog = changelog.changelog(self.opener)
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    28
        self.tagscache = None
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    29
        self.nodetagscache = None
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    30
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    31
    def dev(self):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    32
        return -1
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    33
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    34
    def local(self):
2cf5c8a4eae5 Separate out old-http support
mpm@selenic.com
parents:
diff changeset
    35
        return False