mercurial/exchange.py
branchstable
changeset 23376 2e65da5f80df
parent 23082 0fc4686de1d7
child 23382 a81c76106d90
equal deleted inserted replaced
23346:5ccced6eab0b 23376:2e65da5f80df
   664 
   664 
   665         pushop.stepsdone.add('phases')
   665         pushop.stepsdone.add('phases')
   666 
   666 
   667         # filter heads already turned public by the push
   667         # filter heads already turned public by the push
   668         outdated = [c for c in outdated if c.node() not in pheads]
   668         outdated = [c for c in outdated if c.node() not in pheads]
   669         b2caps = bundle2.bundle2caps(pushop.remote)
   669         # fallback to independent pushkey command
   670         if 'b2x:pushkey' in b2caps:
   670         for newremotehead in outdated:
   671             # server supports bundle2, let's do a batched push through it
   671             r = pushop.remote.pushkey('phases',
   672             #
   672                                       newremotehead.hex(),
   673             # This will eventually be unified with the changesets bundle2 push
   673                                       str(phases.draft),
   674             bundler = bundle2.bundle20(pushop.ui, b2caps)
   674                                       str(phases.public))
   675             capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo))
   675             if not r:
   676             bundler.newpart('b2x:replycaps', data=capsblob)
   676                 pushop.ui.warn(_('updating %s to public failed!\n')
   677             part2node = []
   677                                % newremotehead)
   678             enc = pushkey.encode
       
   679             for newremotehead in outdated:
       
   680                 part = bundler.newpart('b2x:pushkey')
       
   681                 part.addparam('namespace', enc('phases'))
       
   682                 part.addparam('key', enc(newremotehead.hex()))
       
   683                 part.addparam('old', enc(str(phases.draft)))
       
   684                 part.addparam('new', enc(str(phases.public)))
       
   685                 part2node.append((part.id, newremotehead))
       
   686             stream = util.chunkbuffer(bundler.getchunks())
       
   687             try:
       
   688                 reply = pushop.remote.unbundle(stream, ['force'], 'push')
       
   689                 op = bundle2.processbundle(pushop.repo, reply)
       
   690             except error.BundleValueError, exc:
       
   691                 raise util.Abort('missing support for %s' % exc)
       
   692             for partid, node in part2node:
       
   693                 partrep = op.records.getreplies(partid)
       
   694                 results = partrep['pushkey']
       
   695                 assert len(results) <= 1
       
   696                 msg = None
       
   697                 if not results:
       
   698                     msg = _('server ignored update of %s to public!\n') % node
       
   699                 elif not int(results[0]['return']):
       
   700                     msg = _('updating %s to public failed!\n') % node
       
   701                 if msg is not None:
       
   702                     pushop.ui.warn(msg)
       
   703 
       
   704         else:
       
   705             # fallback to independant pushkey command
       
   706             for newremotehead in outdated:
       
   707                 r = pushop.remote.pushkey('phases',
       
   708                                           newremotehead.hex(),
       
   709                                           str(phases.draft),
       
   710                                           str(phases.public))
       
   711                 if not r:
       
   712                     pushop.ui.warn(_('updating %s to public failed!\n')
       
   713                                    % newremotehead)
       
   714 
   678 
   715 def _localphasemove(pushop, nodes, phase=phases.public):
   679 def _localphasemove(pushop, nodes, phase=phases.public):
   716     """move <nodes> to <phase> in the local source repo"""
   680     """move <nodes> to <phase> in the local source repo"""
   717     if pushop.locallocked:
   681     if pushop.locallocked:
   718         tr = pushop.repo.transaction('push-phase-sync')
   682         tr = pushop.repo.transaction('push-phase-sync')