Patchwork [3,of,7] bundle2: store the salvaged output on the exception object

login
register
mail settings
Submitter Pierre-Yves David
Date April 16, 2015, 9:25 a.m.
Message ID <2354acab590e493da377.1429176345@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8705/
State Accepted
Headers show

Comments

Pierre-Yves David - April 16, 2015, 9:25 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1429168621 14400
#      Thu Apr 16 03:17:01 2015 -0400
# Node ID 2354acab590e493da3774b34169c6f897897c711
# Parent  3e1f69627291b38adf39a87a78cf48089f767a24
bundle2: store the salvaged output on the exception object

The re-handling of output is happening in some 'unbundle' callers. We have to
transmit the output information to this place so we stick it on the exception.

This is the third step in our quest for preserving the server output on error
(issue4594). We want to be able to copy the output part from the aborted reply
into the exception bundle.

Patch

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -316,10 +316,14 @@  def processbundle(repo, unbundler, trans
         # processing from processing the old format. This is mostly
         # needed to handle different return codes to unbundle according to the
         # type of bundle. We should probably clean up or drop this return code
         # craziness in a future version.
         exc.duringunbundle2 = True
+        salvaged = []
+        if op.reply is not None:
+            salvaged = op.reply.salvageoutput()
+        exc._bundle2salvagedoutput = salvaged
         raise
     return op
 
 def _processpart(op, part):
     """process a single part from a bundle
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1286,10 +1286,11 @@  def unbundle(repo, cg, heads, source, ur
     wlock = lock = tr = None
     try:
         check_heads(repo, heads, 'uploading changes')
         # push can proceed
         if util.safehasattr(cg, 'params'):
+            r = None
             try:
                 wlock = repo.wlock()
                 lock = repo.lock()
                 tr = repo.transaction(source)
                 tr.hookargs['source'] = source
@@ -1297,10 +1298,12 @@  def unbundle(repo, cg, heads, source, ur
                 tr.hookargs['bundle2'] = '1'
                 r = bundle2.processbundle(repo, cg, lambda: tr).reply
                 tr.close()
             except Exception, exc:
                 exc.duringunbundle2 = True
+                if r is not None:
+                    exc._bundle2salvagedoutput = r.salvageoutput()
                 raise
         else:
             lock = repo.lock()
             r = changegroup.addchangegroup(repo, cg, source, url)
     finally: