# HG changeset patch # User Gregory Szorc # Date 1445643562 -3600 # Node ID 58f1645f72c3cd48191e1b8da412a5ddf31541c1 # Parent 00e75baa810f5e42080d7c2dd826dadc1a22d4c4 bundle2: attribute remote failures to remote (issue4788) Before bundle2, hook output from hook failures was prefixed with "remote: ". Up to this point with bundle2, the output was converted to the message to print in an Abort exception. This had 2 implications: 1) It was unclear whether an error message came from the local repo or the remote 2) The exit code changed from 1 to 255 This patch changes the handling of error:abort bundle2 parts during push to prefix the error message with "remote: ". This restores the old behavior. We still preserve the behavior of raising an Abort during bundle2 application failure. This is a regression from pre-bundle2 because the exit code changed. Because we no longer raise an Abort with the remote's message, we needed to insert a message for the new Abort. So, I invented a new error message for that. This is another change from pre-bundle2. However, I like the new error message because it states unambiguously who aborted the push failed, which I think is important for users so they can decide what's next. diff -r 00e75baa810f -r 58f1645f72c3 mercurial/bundle2.py --- a/mercurial/bundle2.py Sat Oct 24 00:39:26 2015 +0100 +++ b/mercurial/bundle2.py Sat Oct 24 00:39:22 2015 +0100 @@ -1408,10 +1408,14 @@ if op.reply is None: op.reply = bundle20(op.ui, caps) +class AbortFromPart(error.Abort): + """Sub-class of Abort that denotes an error from a bundle2 part.""" + @parthandler('error:abort', ('message', 'hint')) def handleerrorabort(op, inpart): """Used to transmit abort error over the wire""" - raise error.Abort(inpart.params['message'], hint=inpart.params.get('hint')) + raise AbortFromPart(inpart.params['message'], + hint=inpart.params.get('hint')) @parthandler('error:pushkey', ('namespace', 'key', 'new', 'old', 'ret', 'in-reply-to')) diff -r 00e75baa810f -r 58f1645f72c3 mercurial/exchange.py --- a/mercurial/exchange.py Sat Oct 24 00:39:26 2015 +0100 +++ b/mercurial/exchange.py Sat Oct 24 00:39:22 2015 +0100 @@ -798,6 +798,9 @@ op = bundle2.processbundle(pushop.repo, reply, trgetter) except error.BundleValueError as exc: raise error.Abort('missing support for %s' % exc) + except bundle2.AbortFromPart as exc: + pushop.ui.status(_('remote: %s\n') % exc) + raise error.Abort(_('push failed on remote'), hint=exc.hint) except error.PushkeyFailed as exc: partid = int(exc.partid) if partid not in pushop.pkfailcb: diff -r 00e75baa810f -r 58f1645f72c3 tests/test-bundle2-exchange.t --- a/tests/test-bundle2-exchange.t Sat Oct 24 00:39:26 2015 +0100 +++ b/tests/test-bundle2-exchange.t Sat Oct 24 00:39:22 2015 +0100 @@ -518,14 +518,16 @@ $ hg -R main push ssh://user@dummy/other -r e7ec4e813ba6 pushing to ssh://user@dummy/other searching for changes - abort: Abandon ship! + remote: Abandon ship! + abort: push failed on remote (don't panic) [255] $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6 pushing to http://localhost:$HGPORT2/ searching for changes - abort: Abandon ship! + remote: Abandon ship! + abort: push failed on remote (don't panic) [255] @@ -624,7 +626,8 @@ remote: transaction abort! remote: Cleaning up the mess... remote: rollback completed - abort: pretxnclose.failpush hook exited with status 1 + remote: pretxnclose.failpush hook exited with status 1 + abort: push failed on remote [255] $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6 @@ -639,7 +642,8 @@ remote: transaction abort! remote: Cleaning up the mess... remote: rollback completed - abort: pretxnclose.failpush hook exited with status 1 + remote: pretxnclose.failpush hook exited with status 1 + abort: push failed on remote [255] (check that no 'pending' files remain) @@ -684,7 +688,8 @@ remote: transaction abort! remote: Cleaning up the mess... remote: rollback completed - abort: pretxnchangegroup hook exited with status 1 + remote: pretxnchangegroup hook exited with status 1 + abort: push failed on remote [255] $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6 pushing to http://localhost:$HGPORT2/ @@ -697,7 +702,8 @@ remote: transaction abort! remote: Cleaning up the mess... remote: rollback completed - abort: pretxnchangegroup hook exited with status 1 + remote: pretxnchangegroup hook exited with status 1 + abort: push failed on remote [255] Check output capture control. @@ -733,7 +739,8 @@ remote: transaction abort! remote: Cleaning up the mess... remote: rollback completed - abort: pretxnchangegroup hook exited with status 1 + remote: pretxnchangegroup hook exited with status 1 + abort: push failed on remote [255] $ hg -R main push http://localhost:$HGPORT2/ -r e7ec4e813ba6 pushing to http://localhost:$HGPORT2/ @@ -746,7 +753,8 @@ remote: transaction abort! remote: Cleaning up the mess... remote: rollback completed - abort: pretxnchangegroup hook exited with status 1 + remote: pretxnchangegroup hook exited with status 1 + abort: push failed on remote [255] Check abort from mandatory pushkey @@ -928,7 +936,8 @@ $ hg push pushing to ssh://user@dummy/lazylock searching for changes - abort: Lock should not be taken + remote: Lock should not be taken + abort: push failed on remote [255] $ cat >> ../lazylock/.hg/hgrc <