mercurial/exchange.py
changeset 21904 5fbccbcc07ea
parent 21903 48f61cfb7576
child 21906 08dcb572a456
--- a/mercurial/exchange.py	Wed Jul 02 12:55:09 2014 +0200
+++ b/mercurial/exchange.py	Wed Jul 02 15:26:04 2014 +0200
@@ -227,6 +227,9 @@
         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
 
@@ -237,9 +240,11 @@
     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())
@@ -251,7 +256,8 @@
         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):