[PATCH 1 of 5] bundle2: capture transaction rollback message output (issue4614)

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Apr 23 23:56:21 UTC 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1429795236 -3600
#      Thu Apr 23 14:20:36 2015 +0100
# Branch stable
# Node ID 61a2951a30f7c18501027501f7642dd632e72fcd
# Parent  1f9127c9239b9c39c676bb09752db1e2ca6c26f7
bundle2: capture transaction rollback message output (issue4614)

The output from the transaction rollback was not included into the reply bundle.
It was eventually caught by the usual 'unbundle' output capture and sent to the
client but the result was out of order on the client side. We now capture the
output for the transaction release and transmit it the same way as all other
output.

We should probably rethink the whole output capture things but this would not be
appropriate for stable.

The is still multiple cases were output failed to be properly capture, they will
be fixed in later changesets.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1282,10 +1282,11 @@ def unbundle(repo, cg, heads, source, ur
 
     If the push was raced as PushRaced exception is raised."""
     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
         if util.safehasattr(cg, 'params'):
             r = None
@@ -1299,13 +1300,20 @@ def unbundle(repo, cg, heads, source, ur
                 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()
+                    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
@@ -557,39 +557,41 @@ Doing the actual push: hook abort
 
   $ hg -R main push other -r e7ec4e813ba6
   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]
 
   $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
   pushing to ssh://user@dummy/other
   searching for changes
   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
   remote: pre-close-tip:e7ec4e813ba6 draft 
-  remote: transaction abort!
-  remote: rollback completed
   [255]
 
   $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6
   pushing to http://localhost:$HGPORT2/
   searching for changes
   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]
 
 (check that no 'pending' files remain)
 


More information about the Mercurial-devel mailing list