changeset 24799:d99d7e3f5cda

bundle2-localpeer: properly propagate the server output on error (issue4594) In case of errors, output parts salvaged from the reply bundle need to be processed for outputting their content. This concludes our quest for fixing issue4594.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Thu, 16 Apr 2015 04:01:51 -0400
parents 9fbf0a2a72a1
children cde547252f2e
files mercurial/localrepo.py tests/test-bundle2-exchange.t
diffstat 2 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Thu Apr 16 05:09:37 2015 -0400
+++ b/mercurial/localrepo.py	Thu Apr 16 04:01:51 2015 -0400
@@ -136,6 +136,21 @@
                     ret = bundle2.getunbundler(self.ui, stream)
                 return ret
             except Exception, exc:
+                # If the exception contains output salvaged from a bundle2
+                # reply, we need to make sure it is printed before continuing
+                # to fail. So we build a bundle2 with such output and consume
+                # it directly.
+                #
+                # This is not very elegant but allows a "simple" solution for
+                # issue4594
+                output = getattr(exc, '_bundle2salvagedoutput', ())
+                if output:
+                    bundler = bundle2.bundle20(self._repo.ui)
+                    for out in output:
+                        bundler.addpart(out)
+                    stream = util.chunkbuffer(bundler.getchunks())
+                    b = bundle2.getunbundler(self.ui, stream)
+                    bundle2.processbundle(self._repo, b)
                 raise
         except error.PushRaced, exc:
             raise error.ResponseError(_('push failed:'), str(exc))
--- a/tests/test-bundle2-exchange.t	Thu Apr 16 05:09:37 2015 -0400
+++ b/tests/test-bundle2-exchange.t	Thu Apr 16 04:01:51 2015 -0400
@@ -561,6 +561,10 @@
   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
   abort: pretxnclose.failpush hook exited with status 1
   [255]