##// END OF EJS Templates
wireproto: drop the _decompress method in favor a new call type...
Pierre-Yves David -
r20905:167047ba default
parent child Browse files
Show More
@@ -211,10 +211,8 b' class httppeer(wireproto.wirepeer):'
211 fp.close()
211 fp.close()
212 os.unlink(tempname)
212 os.unlink(tempname)
213
213
214 def _abort(self, exception):
214 def _callcompressable(self, cmd, **args):
215 raise exception
215 stream = self._callstream(cmd, **args)
216
217 def _decompress(self, stream):
218 return util.chunkbuffer(zgenerator(stream))
216 return util.chunkbuffer(zgenerator(stream))
219
217
220 class httpspeer(httppeer):
218 class httpspeer(httppeer):
@@ -157,6 +157,9 b' class sshpeer(wireproto.wirepeer):'
157
157
158 return self.pipei
158 return self.pipei
159
159
160 def _callcompressable(self, cmd, **args):
161 return self._callstream(cmd, **args)
162
160 def _call(self, cmd, **args):
163 def _call(self, cmd, **args):
161 self._callstream(cmd, **args)
164 self._callstream(cmd, **args)
162 return self._recv()
165 return self._recv()
@@ -176,8 +179,6 b' class sshpeer(wireproto.wirepeer):'
176 return '', r
179 return '', r
177 return self._recv(), ''
180 return self._recv(), ''
178
181
179 def _decompress(self, stream):
180 return stream
181
182
182 def _recv(self):
183 def _recv(self):
183 l = self.pipei.readline()
184 l = self.pipei.readline()
@@ -314,16 +314,16 b' class wirepeer(peer.peerrepository):'
314
314
315 def changegroup(self, nodes, kind):
315 def changegroup(self, nodes, kind):
316 n = encodelist(nodes)
316 n = encodelist(nodes)
317 f = self._callstream("changegroup", roots=n)
317 f = self._callcompressable("changegroup", roots=n)
318 return changegroupmod.unbundle10(self._decompress(f), 'UN')
318 return changegroupmod.unbundle10(f, 'UN')
319
319
320 def changegroupsubset(self, bases, heads, kind):
320 def changegroupsubset(self, bases, heads, kind):
321 self.requirecap('changegroupsubset', _('look up remote changes'))
321 self.requirecap('changegroupsubset', _('look up remote changes'))
322 bases = encodelist(bases)
322 bases = encodelist(bases)
323 heads = encodelist(heads)
323 heads = encodelist(heads)
324 f = self._callstream("changegroupsubset",
324 f = self._callcompressable("changegroupsubset",
325 bases=bases, heads=heads)
325 bases=bases, heads=heads)
326 return changegroupmod.unbundle10(self._decompress(f), 'UN')
326 return changegroupmod.unbundle10(f, 'UN')
327
327
328 def getbundle(self, source, heads=None, common=None, bundlecaps=None):
328 def getbundle(self, source, heads=None, common=None, bundlecaps=None):
329 self.requirecap('getbundle', _('look up remote changes'))
329 self.requirecap('getbundle', _('look up remote changes'))
@@ -334,8 +334,8 b' class wirepeer(peer.peerrepository):'
334 opts['common'] = encodelist(common)
334 opts['common'] = encodelist(common)
335 if bundlecaps is not None:
335 if bundlecaps is not None:
336 opts['bundlecaps'] = ','.join(bundlecaps)
336 opts['bundlecaps'] = ','.join(bundlecaps)
337 f = self._callstream("getbundle", **opts)
337 f = self._callcompressable("getbundle", **opts)
338 return changegroupmod.unbundle10(self._decompress(f), 'UN')
338 return changegroupmod.unbundle10(f, 'UN')
339
339
340 def unbundle(self, cg, heads, source):
340 def unbundle(self, cg, heads, source):
341 '''Send cg (a readable file-like object representing the
341 '''Send cg (a readable file-like object representing the
@@ -388,6 +388,19 b' class wirepeer(peer.peerrepository):'
388 returns the server reply as a file like object."""
388 returns the server reply as a file like object."""
389 raise NotImplementedError()
389 raise NotImplementedError()
390
390
391 def _callcompressable(self, cmd, **args):
392 """execute <cmd> on the server
393
394 The command is expected to return a stream.
395
396 The stream may have been compressed in some implementaitons. This
397 function takes care of the decompression. This is the only difference
398 with _callstream.
399
400 returns the server reply as a file like object.
401 """
402 raise NotImplementedError()
403
391 def _callpush(self, cmd, fp, **args):
404 def _callpush(self, cmd, fp, **args):
392 """execute a <cmd> on server
405 """execute a <cmd> on server
393
406
@@ -404,12 +417,6 b' class wirepeer(peer.peerrepository):'
404 """
417 """
405 raise NotImplementedError()
418 raise NotImplementedError()
406
419
407
408 def _decompress(self, stream):
409 """decompress a received stream
410 """
411 raise NotImplementedError()
412
413 # server side
420 # server side
414
421
415 # wire protocol command can either return a string or one of these classes.
422 # wire protocol command can either return a string or one of these classes.
General Comments 0
You need to be logged in to leave comments. Login now