protocol: unify client changegroup methods
authorMatt Mackall <mpm@selenic.com>
Wed, 14 Jul 2010 17:09:31 -0500
changeset 11591 0d9cb3f3b0a1
parent 11590 0b15aee0a306
child 11592 26e0782b8380
protocol: unify client changegroup methods
mercurial/httprepo.py
mercurial/sshrepo.py
mercurial/wireproto.py
--- a/mercurial/httprepo.py	Wed Jul 14 17:07:13 2010 -0500
+++ b/mercurial/httprepo.py	Wed Jul 14 17:09:31 2010 -0500
@@ -141,17 +141,8 @@
     def _abort(self, exception):
         raise exception
 
-    def changegroup(self, nodes, kind):
-        n = " ".join(map(hex, nodes))
-        f = self._callstream("changegroup", roots=n)
-        return util.chunkbuffer(zgenerator(f))
-
-    def changegroupsubset(self, bases, heads, source):
-        self.requirecap('changegroupsubset', _('look up remote changes'))
-        baselst = " ".join([hex(n) for n in bases])
-        headlst = " ".join([hex(n) for n in heads])
-        f = self._callstream("changegroupsubset", bases=baselst, heads=headlst)
-        return util.chunkbuffer(zgenerator(f))
+    def _decompress(self, stream):
+        return util.chunkbuffer(zgenerator(stream))
 
     def unbundle(self, cg, heads, source):
         '''Send cg (a readable file-like object representing the
--- a/mercurial/sshrepo.py	Wed Jul 14 17:07:13 2010 -0500
+++ b/mercurial/sshrepo.py	Wed Jul 14 17:09:31 2010 -0500
@@ -128,6 +128,9 @@
         self._callstream(cmd, **args)
         return self._recv()
 
+    def _decompress(self, stream):
+        return stream
+
     def _recv(self):
         l = self.pipei.readline()
         self.readerr()
@@ -152,16 +155,6 @@
     def unlock(self):
         self._call("unlock")
 
-    def changegroup(self, nodes, kind):
-        n = " ".join(map(hex, nodes))
-        return self._callstream("changegroup", roots=n)
-
-    def changegroupsubset(self, bases, heads, kind):
-        self.requirecap('changegroupsubset', _('look up remote changes'))
-        bases = " ".join(map(hex, bases))
-        heads = " ".join(map(hex, heads))
-        return self._callstream("changegroupsubset", bases=bases, heads=heads)
-
     def unbundle(self, cg, heads, source):
         '''Send cg (a readable file-like object representing the
         changegroup to push, typically a chunkbuffer object) to the
--- a/mercurial/wireproto.py	Wed Jul 14 17:07:13 2010 -0500
+++ b/mercurial/wireproto.py	Wed Jul 14 17:09:31 2010 -0500
@@ -91,6 +91,18 @@
     def stream_out(self):
         return self._callstream('stream_out')
 
+    def changegroup(self, nodes, kind):
+        n = " ".join(map(hex, nodes))
+        f = self._callstream("changegroup", roots=n)
+        return self._decompress(f)
+
+    def changegroupsubset(self, bases, heads, kind):
+        self.requirecap('changegroupsubset', _('look up remote changes'))
+        bases = " ".join(map(hex, bases))
+        heads = " ".join(map(hex, heads))
+        return self._decompress(self._callstream("changegroupsubset",
+                                                 bases=bases, heads=heads))
+
 # server side
 
 def dispatch(repo, proto, command):