[PATCH 6 of 9] bundle2-push: move changegroup push validation inside _pushb2ctx
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Mon Jul 7 06:02:04 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1404298509 -7200
# Wed Jul 02 12:55:09 2014 +0200
# Node ID 344c10f0668ffb06c78ee8125c40cd5159a7a536
# Parent 92fa0cfd1a2d15f0e637ef33c4cf42e16f80c483
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
@@ -129,19 +129,15 @@ def push(repo, remote, force=False, revs
unbundle = pushop.remote.capable('unbundle')
if not unbundle:
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)
finally:
if lock is not None:
@@ -212,10 +208,16 @@ def _pushb2ctx(pushop, bundler):
"""
if 'changesets' in pushop.stepsdone:
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)
cgpart = bundler.newpart('B2X:CHANGEGROUP', data=cg.getchunks())
def handlereply(op):
@@ -235,10 +237,13 @@ def _pushbundle2(pushop):
capsblob = bundle2.encodecaps(pushop.repo.bundle2caps)
bundler.newpart('b2x:replycaps', data=capsblob)
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')
except error.BundleValueError, exc:
raise util.Abort('missing support for %s' % exc)
@@ -266,10 +271,15 @@ def _pushbundle2extrareply(pushop, op, e
def _pushchangeset(pushop):
"""Make the actual push of changeset bundle to remote repo"""
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
bundlecaps = None
# create a changegroup from local
More information about the Mercurial-devel
mailing list