changeset 11591:0d9cb3f3b0a1

protocol: unify client changegroup methods
author Matt Mackall <mpm@selenic.com>
date Wed, 14 Jul 2010 17:09:31 -0500
parents 0b15aee0a306
children 26e0782b8380
files mercurial/httprepo.py mercurial/sshrepo.py mercurial/wireproto.py
diffstat 3 files changed, 17 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- 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):