Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/exchange.py @ 23376:2e65da5f80df stable
push: stop independent usage of bundle2 in syncphase (issue4454)
The phase-syncing code was using bundle2 if the remote supported it. It was
doing so without regard to bundle2 activation on the client. Moreover, the
phase push is now properly included in the unified bundle2 push, so having extra
code in syncphase should be useless. If the remote is bundle2-enabled, the
phases should already be synced.
The buggy verification code was leading to a crash when a 3.2 client was pushing
to a 3.1 server. The real bundle2 path detected that their versions were
incompatible, but the syncphase code failed to, sending an incompatible bundle2
to the server.
We drop the useless and buggy code as a result. The "else" clause is
de-indented in the process.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Wed, 19 Nov 2014 01:36:17 +0000 |
parents | 0fc4686de1d7 |
children | a81c76106d90 |
comparison
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') |