mercurial/bundle2.py
changeset 21131 b7435117d951
parent 21130 1ff06386217f
child 21133 bef4a2adc532
--- a/mercurial/bundle2.py	Wed Apr 16 14:09:35 2014 -0400
+++ b/mercurial/bundle2.py	Wed Apr 16 14:22:24 2014 -0400
@@ -307,7 +307,21 @@
             # risk catching KeyErrors from anything other than the
             # parthandlermapping lookup (any KeyError raised by handler()
             # itself represents a defect of a different variety).
-            handler(op, part)
+            output = None
+            if op.reply is not None:
+                op.ui.pushbuffer()
+                output = ''
+            try:
+                handler(op, part)
+            finally:
+                if output is not None:
+                    output = op.ui.popbuffer()
+            if output:
+                outpart = bundlepart('output',
+                                     advisoryparams=[('in-reply-to',
+                                                      str(part.id))],
+                                     data=output)
+                op.reply.addpart(outpart)
             part.read()
     except Exception:
         if part is not None:
@@ -672,6 +686,12 @@
     if heads != op.repo.heads():
         raise exchange.PushRaced()
 
+@parthandler('output')
+def handleoutput(op, inpart):
+    """forward output captured on the server to the client"""
+    for line in inpart.read().splitlines():
+        op.ui.write(('remote: %s\n' % line))
+
 @parthandler('replycaps')
 def handlereplycaps(op, inpart):
     """Notify that a reply bundle should be created
@@ -679,3 +699,4 @@
     Will convey bundle capability at some point too."""
     if op.reply is None:
         op.reply = bundle20(op.ui)
+