diff mercurial/httprepo.py @ 3444:3505fcd5a231

Adding changegroupsubset and lookup to web protocol so pull -r and clone -r can be supported.
author Eric Hopper <hopper@omnifarious.org>
date Sat, 09 Sep 2006 18:25:06 -0700
parents 5dbb3a991bbf
children 233c733e4af5
line wrap: on
line diff
--- a/mercurial/httprepo.py
+++ b/mercurial/httprepo.py
@@ -261,6 +261,14 @@ class httprepository(remoterepository):
             # if using keepalive, allow connection to be reused
             fp.close()
 
+    def lookup(self, key):
+        try:
+            d = self.do_cmd("lookup", key = key).read()
+            return bin(d[:-1])
+        except:
+            self.ui.warn('Not able to look up revision named "%s"\n' % (key,))
+            raise
+
     def heads(self):
         d = self.do_read("heads")
         try:
@@ -298,6 +306,22 @@ class httprepository(remoterepository):
             try:
                 for chnk in f:
                     yield zd.decompress(chnk)
+            except httplib.HTTPException, inst:
+                raise IOError(None, _('connection ended unexpectedly'))
+            yield zd.flush()
+
+        return util.chunkbuffer(zgenerator(util.filechunkiter(f)))
+
+    def changegroupsubset(self, bases, heads, source):
+        baselst = " ".join([hex(n) for n in bases])
+        headlst = " ".join([hex(n) for n in heads])
+        f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst)
+
+        def zgenerator(f):
+            zd = zlib.decompressobj()
+            try:
+                for chnk in f:
+                    yield zd.decompress(chnk)
             except httplib.HTTPException:
                 raise IOError(None, _('connection ended unexpectedly'))
             yield zd.flush()