diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1284,6 +1284,7 @@ def unbundle(repo, cg, heads, source, ur
     r = 0
     # need a transaction when processing a bundle2 stream
     wlock = lock = tr = None
+    recordout = None
     try:
         check_heads(repo, heads, 'uploading changes')
         # push can proceed
@@ -1301,11 +1302,18 @@ def unbundle(repo, cg, heads, source, ur
             except Exception, exc:
                 exc.duringunbundle2 = True
                 if r is not None:
-                    exc._bundle2salvagedoutput = r.salvageoutput()
+                    parts = exc._bundle2salvagedoutput = r.salvageoutput()
+                    repo.ui.pushbuffer(error=True)
+                    def recordout(output):
+                        part = bundle2.bundlepart('output', data=output,
+                                                  mandatory=False)
+                        parts.append(part)
                 raise
         else:
             lock = repo.lock()
             r = changegroup.addchangegroup(repo, cg, source, url)
     finally:
         lockmod.release(tr, lock, wlock)
+        if recordout is not None:
+            recordout(repo.ui.popbuffer())
     return r
diff --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t
--- a/tests/test-bundle2-exchange.t
+++ b/tests/test-bundle2-exchange.t
@@ -559,12 +559,12 @@ Doing the actual push: hook abort
   pushing to other
   searching for changes
   pre-close-tip:e7ec4e813ba6 draft 
-  transaction abort!
-  rollback completed
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
+  remote: transaction abort!
+  remote: rollback completed
   abort: pretxnclose.failpush hook exited with status 1
   [255]
 
@@ -575,10 +575,10 @@ Doing the actual push: hook abort
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
+  remote: transaction abort!
+  remote: rollback completed
   abort: pretxnclose.failpush hook exited with status 1
   remote: pre-close-tip:e7ec4e813ba6 draft 
-  remote: transaction abort!
-  remote: rollback completed
   [255]
 
   $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
@@ -588,6 +588,8 @@ Doing the actual push: hook abort
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
+  remote: transaction abort!
+  remote: rollback completed
   abort: pretxnclose.failpush hook exited with status 1
   [255]