diff options
Diffstat (limited to 'mercurial/statichttprepo.py')
-rw-r--r-- | mercurial/statichttprepo.py | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py index c9274cd..769e4e2 100644 --- a/mercurial/statichttprepo.py +++ b/mercurial/statichttprepo.py @@ -26,17 +26,20 @@ class httprangereader(object): end = '' if bytes: end = self.pos + bytes - 1 - if self.pos or end: - req.add_header('Range', 'bytes=%d-%s' % (self.pos, end)) + req.add_header('Range', 'bytes=%d-%s' % (self.pos, end)) try: f = self.opener.open(req) data = f.read() - # Python 2.6+ defines a getcode() function, and 2.4 and - # 2.5 appear to always have an undocumented code attribute - # set. If we can't read either of those, fall back to 206 - # and hope for the best. - code = getattr(f, 'getcode', lambda : getattr(f, 'code', 206))() + if hasattr(f, 'getcode'): + # python 2.6+ + code = f.getcode() + elif hasattr(f, 'code'): + # undocumented attribute, seems to be set in 2.4 and 2.5 + code = f.code + else: + # Don't know how to check, hope for the best. + code = 206 except urllib2.HTTPError, inst: num = inst.code == 404 and errno.ENOENT or None raise IOError(num, inst) @@ -76,12 +79,6 @@ def build_opener(ui, authinfo): return statichttpopener -class statichttppeer(localrepo.localpeer): - def local(self): - return None - def canpush(self): - return False - class statichttprepository(localrepo.localrepository): def __init__(self, ui, path): self._url = path @@ -93,8 +90,6 @@ class statichttprepository(localrepo.localrepository): opener = build_opener(ui, authinfo) self.opener = opener(self.path) - self.vfs = self.opener - self._phasedefaults = [] try: requirements = scmutil.readrequires(self.opener, self.supported) @@ -119,10 +114,7 @@ class statichttprepository(localrepo.localrepository): self.store = store.store(requirements, self.path, opener) self.spath = self.store.path self.sopener = self.store.opener - self.svfs = self.sopener self.sjoin = self.store.join - self._filecache = {} - self.requirements = requirements self.manifest = manifest.manifest(self.sopener) self.changelog = changelog.changelog(self.sopener) @@ -132,9 +124,7 @@ class statichttprepository(localrepo.localrepository): self._branchcachetip = None self.encodepats = None self.decodepats = None - - def _restrictcapabilities(self, caps): - return caps.difference(["pushkey"]) + self.capabilities.difference_update(["pushkey"]) def url(self): return self._url @@ -142,9 +132,6 @@ class statichttprepository(localrepo.localrepository): def local(self): return False - def peer(self): - return statichttppeer(self) - def lock(self, wait=True): raise util.Abort(_('cannot lock static-http repository')) |