diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py --- a/mercurial/httppeer.py +++ b/mercurial/httppeer.py @@ -211,10 +211,8 @@ class httppeer(wireproto.wirepeer): fp.close() os.unlink(tempname) - def _abort(self, exception): - raise exception - - def _decompress(self, stream): + def _callcompressable(self, cmd, **args): + stream = self._callstream(cmd, **args) return util.chunkbuffer(zgenerator(stream)) class httpspeer(httppeer): diff --git a/mercurial/sshpeer.py b/mercurial/sshpeer.py --- a/mercurial/sshpeer.py +++ b/mercurial/sshpeer.py @@ -157,6 +157,9 @@ class sshpeer(wireproto.wirepeer): return self.pipei + def _callcompressable(self, cmd, **args): + return self._callstream(cmd, **args) + def _call(self, cmd, **args): self._callstream(cmd, **args) return self._recv() @@ -176,8 +179,6 @@ class sshpeer(wireproto.wirepeer): return '', r return self._recv(), '' - def _decompress(self, stream): - return stream def _recv(self): l = self.pipei.readline() diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -314,16 +314,16 @@ class wirepeer(peer.peerrepository): def changegroup(self, nodes, kind): n = encodelist(nodes) - f = self._callstream("changegroup", roots=n) - return changegroupmod.unbundle10(self._decompress(f), 'UN') + f = self._callcompressable("changegroup", roots=n) + return changegroupmod.unbundle10(f, 'UN') def changegroupsubset(self, bases, heads, kind): self.requirecap('changegroupsubset', _('look up remote changes')) bases = encodelist(bases) heads = encodelist(heads) - f = self._callstream("changegroupsubset", - bases=bases, heads=heads) - return changegroupmod.unbundle10(self._decompress(f), 'UN') + f = self._callcompressable("changegroupsubset", + bases=bases, heads=heads) + return changegroupmod.unbundle10(f, 'UN') def getbundle(self, source, heads=None, common=None, bundlecaps=None): self.requirecap('getbundle', _('look up remote changes')) @@ -334,8 +334,8 @@ class wirepeer(peer.peerrepository): opts['common'] = encodelist(common) if bundlecaps is not None: opts['bundlecaps'] = ','.join(bundlecaps) - f = self._callstream("getbundle", **opts) - return changegroupmod.unbundle10(self._decompress(f), 'UN') + f = self._callcompressable("getbundle", **opts) + return changegroupmod.unbundle10(f, 'UN') def unbundle(self, cg, heads, source): '''Send cg (a readable file-like object representing the @@ -388,6 +388,19 @@ class wirepeer(peer.peerrepository): returns the server reply as a file like object.""" raise NotImplementedError() + def _callcompressable(self, cmd, **args): + """execute on the server + + The command is expected to return a stream. + + The stream may have been compressed in some implementaitons. This + function takes care of the decompression. This is the only difference + with _callstream. + + returns the server reply as a file like object. + """ + raise NotImplementedError() + def _callpush(self, cmd, fp, **args): """execute a on server @@ -404,12 +417,6 @@ class wirepeer(peer.peerrepository): """ raise NotImplementedError() - - def _decompress(self, stream): - """decompress a received stream - """ - raise NotImplementedError() - # server side # wire protocol command can either return a string or one of these classes.