mercurial/wireproto.py
changeset 30206 d105195436c0
parent 30187 3e86261bf110
child 30466 2add671bf55b
equal deleted inserted replaced
30205:b4074417b661 30206:d105195436c0
    80 
    80 
    81     def groupchunks(self, fh):
    81     def groupchunks(self, fh):
    82         """Generator of chunks to send to the client.
    82         """Generator of chunks to send to the client.
    83 
    83 
    84         Some protocols may have compressed the contents.
    84         Some protocols may have compressed the contents.
       
    85         """
       
    86         raise NotImplementedError()
       
    87 
       
    88     def compresschunks(self, chunks):
       
    89         """Generator of possible compressed chunks to send to the client.
       
    90 
       
    91         This is like ``groupchunks()`` except it accepts a generator as
       
    92         its argument.
    85         """
    93         """
    86         raise NotImplementedError()
    94         raise NotImplementedError()
    87 
    95 
    88 class remotebatch(peer.batcher):
    96 class remotebatch(peer.batcher):
    89     '''batches the queued calls; uses as few roundtrips as possible'''
    97     '''batches the queued calls; uses as few roundtrips as possible'''
   771     if not bundle1allowed(repo, 'pull'):
   779     if not bundle1allowed(repo, 'pull'):
   772         if not exchange.bundle2requested(opts.get('bundlecaps')):
   780         if not exchange.bundle2requested(opts.get('bundlecaps')):
   773             return ooberror(bundle2required)
   781             return ooberror(bundle2required)
   774 
   782 
   775     chunks = exchange.getbundlechunks(repo, 'serve', **opts)
   783     chunks = exchange.getbundlechunks(repo, 'serve', **opts)
   776     # TODO avoid util.chunkbuffer() here since it is adding overhead to
   784     return streamres(proto.compresschunks(chunks))
   777     # what is fundamentally a generator proxying operation.
       
   778     return streamres(proto.groupchunks(util.chunkbuffer(chunks)))
       
   779 
   785 
   780 @wireprotocommand('heads')
   786 @wireprotocommand('heads')
   781 def heads(repo, proto):
   787 def heads(repo, proto):
   782     h = repo.heads()
   788     h = repo.heads()
   783     return encodelist(h) + "\n"
   789     return encodelist(h) + "\n"