changeset 21149:c0d96bceadc2

bundle2: allow extensions to plug into the push process Extensions are offered functions to add parts and process their results.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 17 Apr 2014 16:54:15 -0400
parents 468cd774aa22
children 0d05915b688d
files mercurial/exchange.py
diffstat 1 files changed, 16 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Thu Apr 17 16:04:58 2014 -0400
+++ b/mercurial/exchange.py	Thu Apr 17 16:54:15 2014 -0400
@@ -219,6 +219,7 @@
         part = bundle2.bundlepart('B2X:CHECK:HEADS',
                                   data=iter(pushop.remoteheads))
         bundler.addpart(part)
+    extrainfo = _pushbundle2extraparts(pushop, bundler)
     # add the changegroup bundle
     cg = changegroup.getlocalbundle(pushop.repo, 'push', pushop.outgoing)
     cgpart = bundle2.bundlepart('B2X:CHANGEGROUP', data=cg.getchunks())
@@ -232,6 +233,21 @@
     cgreplies = op.records.getreplies(cgpart.id)
     assert len(cgreplies['changegroup']) == 1
     pushop.ret = cgreplies['changegroup'][0]['return']
+    _pushbundle2extrareply(pushop, op, extrainfo)
+
+def _pushbundle2extraparts(pushop, bundler):
+    """hook function to let extensions add parts
+
+    Return a dict to let extensions pass data to the reply processing.
+    """
+    return {}
+
+def _pushbundle2extrareply(pushop, op, extrainfo):
+    """hook function to let extensions react to part replies
+
+    The dict from _pushbundle2extrareply is fed to this function.
+    """
+    pass
 
 def _pushchangeset(pushop):
     """Make the actual push of changeset bundle to remote repo"""