[PATCH 4 of 5] bundle2: capture output issue during transaction close

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


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1429797285 -3600
#      Thu Apr 23 14:54:45 2015 +0100
# Branch stable
# Node ID 09f08e0203066707963b3ed25c4b0da0c5a71622
# Parent  4fcd24c9b3297d3a3bd5cf3f39f1f9fda08156f2
bundle2: capture output issue during transaction close

We were capturing all output issue during bundle2 processing, and all output
issue during transaction rollback in case of failure. However, the output issue
during transaction commit was still roaming the land freely. It is now put back
in line.

This let the user see output from 'pretxnclose' and 'txnclose' (and related) in
the right order.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1296,16 +1296,19 @@ def unbundle(repo, cg, heads, source, ur
                 tr = repo.transaction(source)
                 tr.hookargs['source'] = source
                 tr.hookargs['url'] = url
                 tr.hookargs['bundle2'] = '1'
                 r = bundle2.processbundle(repo, cg, lambda: tr).reply
+                if r is not None:
+                    repo.ui.pushbuffer(error=True, subproc=True)
+                    def recordout(output):
+                        r.newpart('output', data=output, mandatory=False)
                 tr.close()
             except Exception, exc:
                 exc.duringunbundle2 = True
                 if r is not None:
                     parts = exc._bundle2salvagedoutput = r.salvageoutput()
-                    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
@@ -210,24 +210,24 @@ add extra data to test their exchange du
 
 push
   $ hg -R main push other --rev eea13746799a --bookmark book_eea1
   pushing to other
   searching for changes
-  pre-close-tip:eea13746799a public book_eea1
-  pushkey: lock state after "phases"
-  lock:  free
-  wlock: free
-  pushkey: lock state after "bookmarks"
-  lock:  free
-  wlock: free
-  postclose-tip:eea13746799a public book_eea1
-  txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob)
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 0 changes to 0 files (-1 heads)
   remote: 1 new obsolescence markers
+  remote: pre-close-tip:eea13746799a public book_eea1
+  remote: pushkey: lock state after "phases"
+  remote: lock:  free
+  remote: wlock: free
+  remote: pushkey: lock state after "bookmarks"
+  remote: lock:  free
+  remote: wlock: free
+  remote: postclose-tip:eea13746799a public book_eea1
+  remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_TXNID=TXN:* HG_TXNNAME=push HG_URL=push (glob)
   updating bookmark book_eea1
   pre-close-tip:02de42196ebe draft book_02de
   postclose-tip:02de42196ebe draft book_02de
   txnclose hook: HG_SOURCE=push-response HG_TXNID=TXN:* HG_TXNNAME=push-response (glob)
   file:/*/$TESTTMP/other HG_URL=file:$TESTTMP/other (glob)
@@ -302,17 +302,17 @@ push over ssh
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
   remote: 1 new obsolescence markers
-  updating bookmark book_5fdd
   remote: pre-close-tip:5fddd98957c8 draft book_5fdd
   remote: pushkey: lock state after "bookmarks"
   remote: lock:  free
   remote: wlock: free
   remote: postclose-tip:5fddd98957c8 draft book_5fdd
   remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_TXNID=TXN:* HG_TXNNAME=serve HG_URL=remote:ssh:127.0.0.1 (glob)
+  updating bookmark book_5fdd
   pre-close-tip:02de42196ebe draft book_02de
   postclose-tip:02de42196ebe draft book_02de
   txnclose hook: HG_SOURCE=push-response HG_TXNID=TXN:* HG_TXNNAME=push-response (glob)
   ssh://user@dummy/other HG_URL=ssh://user@dummy/other
   $ hg -R other log -G
@@ -353,10 +353,19 @@ push over http
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
   remote: 1 new obsolescence markers
+  remote: pre-close-tip:32af7686d403 public book_32af
+  remote: pushkey: lock state after "phases"
+  remote: lock:  free
+  remote: wlock: free
+  remote: pushkey: lock state after "bookmarks"
+  remote: lock:  free
+  remote: wlock: free
+  remote: postclose-tip:32af7686d403 public book_32af
+  remote: txnclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2=1 HG_NEW_OBSMARKERS=1 HG_NODE=32af7686d403cf45b5d95f2d70cebea587ac806a HG_PHASES_MOVED=1 HG_SOURCE=serve HG_TXNID=TXN:* HG_TXNNAME=serve HG_URL=remote:http:127.0.0.1: (glob)
   updating bookmark book_32af
   pre-close-tip:02de42196ebe draft book_02de
   postclose-tip:02de42196ebe draft book_02de
   txnclose hook: HG_SOURCE=push-response HG_TXNID=TXN:* HG_TXNNAME=push-response (glob)
   http://localhost:$HGPORT2/ HG_URL=http://localhost:$HGPORT2/
@@ -546,26 +555,27 @@ Doing the actual push: hook abort
 
   $ cat << EOF >> $HGRCPATH
   > [failpush]
   > reason =
   > [hooks]
-  > pretxnclose.failpush = false
+  > pretxnclose.failpush = echo "You shall not pass!"; 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
 
   $ hg -R main push other -r e7ec4e813ba6
   pushing to other
   searching for changes
-  pre-close-tip:e7ec4e813ba6 draft 
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
+  remote: pre-close-tip:e7ec4e813ba6 draft 
+  remote: You shall not pass!
   remote: transaction abort!
   remote: Cleaning up the mess...
   remote: rollback completed
   abort: pretxnclose.failpush hook exited with status 1
   [255]
@@ -575,24 +585,27 @@ Doing the actual push: hook abort
   searching for changes
   remote: adding changesets
   remote: adding manifests
   remote: adding file changes
   remote: added 1 changesets with 1 changes to 1 files
+  remote: pre-close-tip:e7ec4e813ba6 draft 
+  remote: You shall not pass!
   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]
 
   $ 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: pre-close-tip:e7ec4e813ba6 draft 
+  remote: You shall not pass!
   remote: transaction abort!
   remote: Cleaning up the mess...
   remote: rollback completed
   abort: pretxnclose.failpush hook exited with status 1
   [255]


More information about the Mercurial-devel mailing list