mercurial/bundle2.py
changeset 21146 4676135ac555
parent 21144 7a20fe8dc080
child 21176 70fcb0a71445
equal deleted inserted replaced
21145:0c5088be66af 21146:4676135ac555
   315                 handler(op, part)
   315                 handler(op, part)
   316             finally:
   316             finally:
   317                 if output is not None:
   317                 if output is not None:
   318                     output = op.ui.popbuffer()
   318                     output = op.ui.popbuffer()
   319             if output:
   319             if output:
   320                 outpart = bundlepart('output',
   320                 outpart = bundlepart('b2x:output',
   321                                      advisoryparams=[('in-reply-to',
   321                                      advisoryparams=[('in-reply-to',
   322                                                       str(part.id))],
   322                                                       str(part.id))],
   323                                      data=output)
   323                                      data=output)
   324                 op.reply.addpart(outpart)
   324                 op.reply.addpart(outpart)
   325             part.read()
   325             part.read()
   674         if size is None or len(data) < size:
   674         if size is None or len(data) < size:
   675             self.consumed = True
   675             self.consumed = True
   676         return data
   676         return data
   677 
   677 
   678 
   678 
   679 @parthandler('changegroup')
   679 @parthandler('b2x:changegroup')
   680 def handlechangegroup(op, inpart):
   680 def handlechangegroup(op, inpart):
   681     """apply a changegroup part on the repo
   681     """apply a changegroup part on the repo
   682 
   682 
   683     This is a very early implementation that will massive rework before being
   683     This is a very early implementation that will massive rework before being
   684     inflicted to any end-user.
   684     inflicted to any end-user.
   693     ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
   693     ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
   694     op.records.add('changegroup', {'return': ret})
   694     op.records.add('changegroup', {'return': ret})
   695     if op.reply is not None:
   695     if op.reply is not None:
   696         # This is definitly not the final form of this
   696         # This is definitly not the final form of this
   697         # return. But one need to start somewhere.
   697         # return. But one need to start somewhere.
   698         part = bundlepart('reply:changegroup', (),
   698         part = bundlepart('b2x:reply:changegroup', (),
   699                            [('in-reply-to', str(inpart.id)),
   699                            [('in-reply-to', str(inpart.id)),
   700                             ('return', '%i' % ret)])
   700                             ('return', '%i' % ret)])
   701         op.reply.addpart(part)
   701         op.reply.addpart(part)
   702     assert not inpart.read()
   702     assert not inpart.read()
   703 
   703 
   704 @parthandler('reply:changegroup')
   704 @parthandler('b2x:reply:changegroup')
   705 def handlechangegroup(op, inpart):
   705 def handlechangegroup(op, inpart):
   706     p = dict(inpart.advisoryparams)
   706     p = dict(inpart.advisoryparams)
   707     ret = int(p['return'])
   707     ret = int(p['return'])
   708     op.records.add('changegroup', {'return': ret}, int(p['in-reply-to']))
   708     op.records.add('changegroup', {'return': ret}, int(p['in-reply-to']))
   709 
   709 
   710 @parthandler('check:heads')
   710 @parthandler('b2x:check:heads')
   711 def handlechangegroup(op, inpart):
   711 def handlechangegroup(op, inpart):
   712     """check that head of the repo did not change
   712     """check that head of the repo did not change
   713 
   713 
   714     This is used to detect a push race when using unbundle.
   714     This is used to detect a push race when using unbundle.
   715     This replaces the "heads" argument of unbundle."""
   715     This replaces the "heads" argument of unbundle."""
   720         h = inpart.read(20)
   720         h = inpart.read(20)
   721     assert not h
   721     assert not h
   722     if heads != op.repo.heads():
   722     if heads != op.repo.heads():
   723         raise exchange.PushRaced()
   723         raise exchange.PushRaced()
   724 
   724 
   725 @parthandler('output')
   725 @parthandler('b2x:output')
   726 def handleoutput(op, inpart):
   726 def handleoutput(op, inpart):
   727     """forward output captured on the server to the client"""
   727     """forward output captured on the server to the client"""
   728     for line in inpart.read().splitlines():
   728     for line in inpart.read().splitlines():
   729         op.ui.write(('remote: %s\n' % line))
   729         op.ui.write(('remote: %s\n' % line))
   730 
   730 
   731 @parthandler('replycaps')
   731 @parthandler('b2x:replycaps')
   732 def handlereplycaps(op, inpart):
   732 def handlereplycaps(op, inpart):
   733     """Notify that a reply bundle should be created
   733     """Notify that a reply bundle should be created
   734 
   734 
   735     The payload contains the capabilities information for the reply"""
   735     The payload contains the capabilities information for the reply"""
   736     caps = decodecaps(inpart.read())
   736     caps = decodecaps(inpart.read())