diff mercurial/statichttprepo.py @ 11066:26abd91d9e84 stable

static-http: mimic more closely localrepo (issue2164: allow clone -r ) * httprangereader: name, __iter__ and close are needed to mimic file object * static-http opener: - disallow write/append modes - add (unused) atomictemp parameter * static-http repo: - root attribute is needed for localrepo.dirstate() - _branch* attributes are required for commitctx and branchmap calls * tags: force repo.opener.__iter__ call earlier to force httprangereader to try to read the cache early, to avoid raising IOError later.
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Mon, 26 Apr 2010 20:13:14 +0900
parents 25e572394f5c
children 245a67fe2574
line wrap: on
line diff
--- a/mercurial/statichttprepo.py	Fri Apr 30 18:11:56 2010 +0200
+++ b/mercurial/statichttprepo.py	Mon Apr 26 20:13:14 2010 +0900
@@ -18,6 +18,7 @@
         self.url = url
         self.pos = 0
         self.opener = opener
+        self.name = url
     def seek(self, pos):
         self.pos = pos
     def read(self, bytes=None):
@@ -56,6 +57,10 @@
             data = data[:bytes]
         self.pos += len(data)
         return data
+    def __iter__(self):
+        return iter(self.read().splitlines(1))
+    def close(self):
+        pass
 
 def build_opener(ui, authinfo):
     # urllib cannot handle URLs with embedded user or passwd
@@ -65,7 +70,9 @@
     def opener(base):
         """return a function that opens files over http"""
         p = base
-        def o(path, mode="r"):
+        def o(path, mode="r", atomictemp=None):
+            if 'a' in mode or 'w' in mode:
+                raise IOError('Permission denied')
             f = "/".join((p, urllib.quote(path)))
             return httprangereader(f, urlopener)
         return o
@@ -77,6 +84,7 @@
         self._url = path
         self.ui = ui
 
+        self.root = path
         self.path, authinfo = url.getauthinfo(path.rstrip('/') + "/.hg")
 
         opener = build_opener(ui, authinfo)
@@ -116,6 +124,8 @@
         self.changelog = changelog.changelog(self.sopener)
         self._tags = None
         self.nodetagscache = None
+        self._branchcache = None
+        self._branchcachetip = None
         self.encodepats = None
         self.decodepats = None