mercurial/wireproto.py
changeset 35705 8cdb671dbd0b
parent 35491 ded3a63f305b
child 35750 a39a9df7ecca
equal deleted inserted replaced
35704:41ef02ba329b 35705:8cdb671dbd0b
   518 class streamres(object):
   518 class streamres(object):
   519     """wireproto reply: binary stream
   519     """wireproto reply: binary stream
   520 
   520 
   521     The call was successful and the result is a stream.
   521     The call was successful and the result is a stream.
   522 
   522 
   523     Accepts either a generator or an object with a ``read(size)`` method.
   523     Accepts a generator containing chunks of data to be sent to the client.
   524 
   524 
   525     ``v1compressible`` indicates whether this data can be compressed to
   525     ``v1compressible`` indicates whether this data can be compressed to
   526     "version 1" clients (technically: HTTP peers using
   526     "version 1" clients (technically: HTTP peers using
   527     application/mercurial-0.1 media type). This flag should NOT be used on
   527     application/mercurial-0.1 media type). This flag should NOT be used on
   528     new commands because new clients should support a more modern compression
   528     new commands because new clients should support a more modern compression
   529     mechanism.
   529     mechanism.
   530     """
   530     """
   531     def __init__(self, gen=None, reader=None, v1compressible=False):
   531     def __init__(self, gen=None, v1compressible=False):
   532         self.gen = gen
   532         self.gen = gen
   533         self.reader = reader
       
   534         self.v1compressible = v1compressible
   533         self.v1compressible = v1compressible
   535 
   534 
   536 class pushres(object):
   535 class pushres(object):
   537     """wireproto reply: success with simple integer return
   536     """wireproto reply: success with simple integer return
   538 
   537 
   800 def changegroup(repo, proto, roots):
   799 def changegroup(repo, proto, roots):
   801     nodes = decodelist(roots)
   800     nodes = decodelist(roots)
   802     outgoing = discovery.outgoing(repo, missingroots=nodes,
   801     outgoing = discovery.outgoing(repo, missingroots=nodes,
   803                                   missingheads=repo.heads())
   802                                   missingheads=repo.heads())
   804     cg = changegroupmod.makechangegroup(repo, outgoing, '01', 'serve')
   803     cg = changegroupmod.makechangegroup(repo, outgoing, '01', 'serve')
   805     return streamres(reader=cg, v1compressible=True)
   804     gen = iter(lambda: cg.read(32768), '')
       
   805     return streamres(gen=gen, v1compressible=True)
   806 
   806 
   807 @wireprotocommand('changegroupsubset', 'bases heads')
   807 @wireprotocommand('changegroupsubset', 'bases heads')
   808 def changegroupsubset(repo, proto, bases, heads):
   808 def changegroupsubset(repo, proto, bases, heads):
   809     bases = decodelist(bases)
   809     bases = decodelist(bases)
   810     heads = decodelist(heads)
   810     heads = decodelist(heads)
   811     outgoing = discovery.outgoing(repo, missingroots=bases,
   811     outgoing = discovery.outgoing(repo, missingroots=bases,
   812                                   missingheads=heads)
   812                                   missingheads=heads)
   813     cg = changegroupmod.makechangegroup(repo, outgoing, '01', 'serve')
   813     cg = changegroupmod.makechangegroup(repo, outgoing, '01', 'serve')
   814     return streamres(reader=cg, v1compressible=True)
   814     gen = iter(lambda: cg.read(32768), '')
       
   815     return streamres(gen=gen, v1compressible=True)
   815 
   816 
   816 @wireprotocommand('debugwireargs', 'one two *')
   817 @wireprotocommand('debugwireargs', 'one two *')
   817 def debugwireargs(repo, proto, one, two, others):
   818 def debugwireargs(repo, proto, one, two, others):
   818     # only accept optional args from the known set
   819     # only accept optional args from the known set
   819     opts = options('debugwireargs', ['three', 'four'], others)
   820     opts = options('debugwireargs', ['three', 'four'], others)