[PATCH 3 of 5] bundle2: also capture hook output during processing

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


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1429805038 -3600
#      Thu Apr 23 17:03:58 2015 +0100
# Branch stable
# Node ID 4fcd24c9b3297d3a3bd5cf3f39f1f9fda08156f2
# Parent  8aea112e68b1f90f8b2917f06fd4081116502c64
bundle2: also capture hook output during processing

External hook used to directly write on stdout and stderr. As a result their
output was not captured by the bundle2 processing. This resulted in confusing
out of order output on the client side. We are now capturing hooks output in
this context.

diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py
--- a/mercurial/bundle2.py
+++ b/mercurial/bundle2.py
@@ -352,11 +352,11 @@ def _processpart(op, part):
         # risk catching KeyErrors from anything other than the
         # parthandlermapping lookup (any KeyError raised by handler()
         # itself represents a defect of a different variety).
         output = None
         if op.reply is not None:
-            op.ui.pushbuffer(error=True)
+            op.ui.pushbuffer(error=True, subproc=True)
             output = ''
         try:
             handler(op, part)
         finally:
             if output is not None:
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1301,11 +1301,11 @@ def unbundle(repo, cg, heads, source, ur
                 tr.close()
             except Exception, exc:
                 exc.duringunbundle2 = True
                 if r is not None:
                     parts = exc._bundle2salvagedoutput = r.salvageoutput()
-                    repo.ui.pushbuffer(error=True)
+                    repo.ui.pushbuffer(error=True, subproc=True)
                     def recordout(output):
                         part = bundle2.bundlepart('output', data=output,
                                                   mandatory=False)
                         parts.append(part)
                 raise
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
@@ -547,10 +547,11 @@ Doing the actual push: hook abort
   $ cat << EOF >> $HGRCPATH
   > [failpush]
   > reason =
   > [hooks]
   > pretxnclose.failpush = false
+  > txnabort.failpush = echo 'Cleaning up the mess...'
   > EOF
 
   $ "$TESTDIR/killdaemons.py" $DAEMON_PIDS
   $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
   $ cat other.pid >> $DAEMON_PIDS
@@ -562,10 +563,11 @@ Doing the actual push: hook abort
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
   remote: transaction abort!
+  remote: Cleaning up the mess...
   remote: rollback completed
   abort: pretxnclose.failpush hook exited with status 1
   [255]
 
   $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6
@@ -574,10 +576,11 @@ Doing the actual push: hook abort
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
   remote: transaction abort!
+  remote: Cleaning up the mess...
   remote: rollback completed
   abort: pretxnclose.failpush hook exited with status 1
   remote: pre-close-tip:e7ec4e813ba6 draft 
   [255]
 
@@ -587,10 +590,11 @@ Doing the actual push: hook abort
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
   remote: transaction abort!
+  remote: Cleaning up the mess...
   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