[PATCH STABLE] push: stop independant usage of bundle2 in syncphase (issue4454)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Nov 20 05:39:05 UTC 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1416360977 0
#      Wed Nov 19 01:36:17 2014 +0000
# Branch stable
# Node ID 2246d315882b8f937297a3bdb00968898271af82
# Parent  5ccced6eab0be9e3479e7981687c6a0ab937fa15
push: stop independant usage of bundle2 in syncphase (issue4454)

The phase syncing code was using bundle2 if the remote supported it. It was
doing so without regards of 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 crash when a 3.2 client was pushing
to a 3.1 server. The real bundle2 path detected that their version was
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.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -664,55 +664,19 @@ def _pushsyncphase(pushop):
 
         pushop.stepsdone.add('phases')
 
         # filter heads already turned public by the push
         outdated = [c for c in outdated if c.node() not in pheads]
-        b2caps = bundle2.bundle2caps(pushop.remote)
-        if 'b2x:pushkey' in b2caps:
-            # server supports bundle2, let's do a batched push through it
-            #
-            # This will eventually be unified with the changesets bundle2 push
-            bundler = bundle2.bundle20(pushop.ui, b2caps)
-            capsblob = bundle2.encodecaps(bundle2.getrepocaps(pushop.repo))
-            bundler.newpart('b2x:replycaps', data=capsblob)
-            part2node = []
-            enc = pushkey.encode
-            for newremotehead in outdated:
-                part = bundler.newpart('b2x:pushkey')
-                part.addparam('namespace', enc('phases'))
-                part.addparam('key', enc(newremotehead.hex()))
-                part.addparam('old', enc(str(phases.draft)))
-                part.addparam('new', enc(str(phases.public)))
-                part2node.append((part.id, newremotehead))
-            stream = util.chunkbuffer(bundler.getchunks())
-            try:
-                reply = pushop.remote.unbundle(stream, ['force'], 'push')
-                op = bundle2.processbundle(pushop.repo, reply)
-            except error.BundleValueError, exc:
-                raise util.Abort('missing support for %s' % exc)
-            for partid, node in part2node:
-                partrep = op.records.getreplies(partid)
-                results = partrep['pushkey']
-                assert len(results) <= 1
-                msg = None
-                if not results:
-                    msg = _('server ignored update of %s to public!\n') % node
-                elif not int(results[0]['return']):
-                    msg = _('updating %s to public failed!\n') % node
-                if msg is not None:
-                    pushop.ui.warn(msg)
-
-        else:
-            # fallback to independant pushkey command
-            for newremotehead in outdated:
-                r = pushop.remote.pushkey('phases',
-                                          newremotehead.hex(),
-                                          str(phases.draft),
-                                          str(phases.public))
-                if not r:
-                    pushop.ui.warn(_('updating %s to public failed!\n')
-                                   % newremotehead)
+        # fallback to independant pushkey command
+        for newremotehead in outdated:
+            r = pushop.remote.pushkey('phases',
+                                      newremotehead.hex(),
+                                      str(phases.draft),
+                                      str(phases.public))
+            if not r:
+                pushop.ui.warn(_('updating %s to public failed!\n')
+                               % newremotehead)
 
 def _localphasemove(pushop, nodes, phase=phases.public):
     """move <nodes> to <phase> in the local source repo"""
     if pushop.locallocked:
         tr = pushop.repo.transaction('push-phase-sync')


More information about the Mercurial-devel mailing list