mercurial/exchange.py
changeset 22020 311979b773fb
parent 22019 9fcf772f15ff
child 22033 342e7c428e47
equal deleted inserted replaced
22019:9fcf772f15ff 22020:311979b773fb
   364         cgreplies = op.records.getreplies(cgpart.id)
   364         cgreplies = op.records.getreplies(cgpart.id)
   365         assert len(cgreplies['changegroup']) == 1
   365         assert len(cgreplies['changegroup']) == 1
   366         pushop.ret = cgreplies['changegroup'][0]['return']
   366         pushop.ret = cgreplies['changegroup'][0]['return']
   367     return handlereply
   367     return handlereply
   368 
   368 
       
   369 @b2partsgenerator('phase')
       
   370 def _pushb2phases(pushop, bundler):
       
   371     """handle phase push through bundle2"""
       
   372     if 'phases' in pushop.stepsdone:
       
   373         return
       
   374     b2caps = bundle2.bundle2caps(pushop.remote)
       
   375     if not 'b2x:pushkey' in b2caps:
       
   376         return
       
   377     pushop.stepsdone.add('phases')
       
   378     part2node = []
       
   379     enc = pushkey.encode
       
   380     for newremotehead in pushop.outdatedphases:
       
   381         part = bundler.newpart('b2x:pushkey')
       
   382         part.addparam('namespace', enc('phases'))
       
   383         part.addparam('key', enc(newremotehead.hex()))
       
   384         part.addparam('old', enc(str(phases.draft)))
       
   385         part.addparam('new', enc(str(phases.public)))
       
   386         part2node.append((part.id, newremotehead))
       
   387     def handlereply(op):
       
   388         for partid, node in part2node:
       
   389             partrep = op.records.getreplies(partid)
       
   390             results = partrep['pushkey']
       
   391             assert len(results) <= 1
       
   392             msg = None
       
   393             if not results:
       
   394                 msg = _('server ignored update of %s to public!\n') % node
       
   395             elif not int(results[0]['return']):
       
   396                 msg = _('updating %s to public failed!\n') % node
       
   397             if msg is not None:
       
   398                 pushop.ui.warn(msg)
       
   399     return handlereply
   369 
   400 
   370 def _pushbundle2(pushop):
   401 def _pushbundle2(pushop):
   371     """push data to the remote using bundle2
   402     """push data to the remote using bundle2
   372 
   403 
   373     The only currently supported type of data is changegroup but this will
   404     The only currently supported type of data is changegroup but this will
   478             _localphasemove(pushop, pheads)
   509             _localphasemove(pushop, pheads)
   479             _localphasemove(pushop, cheads, phases.draft)
   510             _localphasemove(pushop, cheads, phases.draft)
   480         ### Apply local phase on remote
   511         ### Apply local phase on remote
   481 
   512 
   482         if pushop.ret:
   513         if pushop.ret:
       
   514             if 'phases' in pushop.stepsdone:
       
   515                 # phases already pushed though bundle2
       
   516                 return
   483             outdated = pushop.outdatedphases
   517             outdated = pushop.outdatedphases
   484         else:
   518         else:
   485             outdated = pushop.fallbackoutdatedphases
   519             outdated = pushop.fallbackoutdatedphases
   486 
   520 
       
   521         pushop.stepsdone.add('phases')
       
   522 
   487         # filter heads already turned public by the push
   523         # filter heads already turned public by the push
   488         outdated = [c for c in outdated if c.node() not in pheads]
   524         outdated = [c for c in outdated if c.node() not in pheads]
   489 
       
   490         b2caps = bundle2.bundle2caps(pushop.remote)
   525         b2caps = bundle2.bundle2caps(pushop.remote)
   491         if 'b2x:pushkey' in b2caps:
   526         if 'b2x:pushkey' in b2caps:
   492             # server supports bundle2, let's do a batched push through it
   527             # server supports bundle2, let's do a batched push through it
   493             #
   528             #
   494             # This will eventually be unified with the changesets bundle2 push
   529             # This will eventually be unified with the changesets bundle2 push