# HG changeset patch # User Pierre-Yves David # Date 2015-04-16 08:01:51 # Node ID d99d7e3f5cda79edcf56be374bb931061d0af055 # Parent 9fbf0a2a72a16f969942b875294f6b8aee3fcab1 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. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -136,6 +136,21 @@ class localpeer(peer.peerrepository): 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)) 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 @@ -561,6 +561,10 @@ Doing the actual push: hook abort 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]