Comments
Patch
@@ -225,23 +225,28 @@ def _pushb2ctx(pushop, bundler):
cgreplies = op.records.getreplies(cgpart.id)
assert len(cgreplies['changegroup']) == 1
pushop.ret = cgreplies['changegroup'][0]['return']
return handlereply
+# list of function that may decide to add parts to an outgoing bundle2
+bundle2partsgenerators = [_pushb2ctx]
+
def _pushbundle2(pushop):
"""push data to the remote using bundle2
The only currently supported type of data is changegroup but this will
evolve in the future."""
bundler = bundle2.bundle20(pushop.ui, bundle2.bundle2caps(pushop.remote))
# create reply capability
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
+ replyhandlers = []
+ for partgen in bundle2partsgenerators:
+ ret = partgen(pushop, bundler)
+ replyhandlers.append(ret)
+ # do not push if nothing to push
if bundler.nbparts <= 1:
return
stream = util.chunkbuffer(bundler.getchunks())
try:
reply = pushop.remote.unbundle(stream, ['force'], 'push')
@@ -249,11 +254,12 @@ def _pushbundle2(pushop):
raise util.Abort('missing support for %s' % exc)
try:
op = bundle2.processbundle(pushop.repo, reply)
except error.BundleValueError, exc:
raise util.Abort('missing support for %s' % exc)
- cgreplyhandler(op)
+ for rephand in replyhandlers:
+ rephand(op)
_pushbundle2extrareply(pushop, op, extrainfo)
def _pushbundle2extraparts(pushop, bundler):
"""hook function to let extensions add parts