# HG changeset patch # User Pierre-Yves David # Date 2014-07-02 10:55:09 # Node ID 48f61cfb75764d6ec7b5caef5ccf4d85f2153910 # Parent 7a7def851ba0e1de62df72d9437fbc60a2fe1ffc bundle2-push: move changegroup push validation inside _pushb2ctx When bundle2 push includes more than just changesets, we may have no changegroup to push yet still have other data to push. So we now try to performs a bundle2 push in all cases. The check for changegroup inclusion is moved into the ``_pushb2ctx`` function in charge of creating the changegroup part. The bundle2 part is aborted if no actual payload part have been added to the bundle2. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -131,15 +131,11 @@ def push(repo, remote, force=False, revs lock = pushop.remote.lock() try: _pushdiscovery(pushop) - if _pushcheckoutgoing(pushop): - pushop.repo.prepushoutgoinghooks(pushop.repo, - pushop.remote, - pushop.outgoing) - if (pushop.repo.ui.configbool('experimental', 'bundle2-exp', - False) - and pushop.remote.capable('bundle2-exp')): - _pushbundle2(pushop) - _pushchangeset(pushop) + if (pushop.repo.ui.configbool('experimental', 'bundle2-exp', + False) + and pushop.remote.capable('bundle2-exp')): + _pushbundle2(pushop) + _pushchangeset(pushop) _pushcomputecommonheads(pushop) _pushsyncphase(pushop) _pushobsolete(pushop) @@ -214,6 +210,12 @@ def _pushb2ctx(pushop, bundler): return pushop.stepsdone.add('changesets') # Send known heads to the server for race detection. + pushop.stepsdone.add('changesets') + if not _pushcheckoutgoing(pushop): + return + pushop.repo.prepushoutgoinghooks(pushop.repo, + pushop.remote, + pushop.outgoing) if not pushop.force: bundler.newpart('B2X:CHECK:HEADS', data=iter(pushop.remoteheads)) cg = changegroup.getlocalbundle(pushop.repo, 'push', pushop.outgoing) @@ -237,6 +239,9 @@ def _pushbundle2(pushop): extrainfo = _pushbundle2extraparts(pushop, bundler) # add the changegroup bundle cgreplyhandler = _pushb2ctx(pushop, bundler) + # do not push if no other parts than the capability + if bundler.nbparts <= 1: + return stream = util.chunkbuffer(bundler.getchunks()) try: reply = pushop.remote.unbundle(stream, ['force'], 'push') @@ -268,6 +273,11 @@ def _pushchangeset(pushop): if 'changesets' in pushop.stepsdone: return pushop.stepsdone.add('changesets') + if not _pushcheckoutgoing(pushop): + return + pushop.repo.prepushoutgoinghooks(pushop.repo, + pushop.remote, + pushop.outgoing) outgoing = pushop.outgoing unbundle = pushop.remote.capable('unbundle') # TODO: get bundlecaps from remote