comparison mercurial/bundle2.py @ 26829:58f1645f72c3 stable

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 24 Oct 2015 00:39:22 +0100
parents 42f705f2c02d
children 5c0fd878779c
comparison
equal deleted inserted replaced
26828:00e75baa810f 26829:58f1645f72c3
1406 The payload contains the capabilities information for the reply""" 1406 The payload contains the capabilities information for the reply"""
1407 caps = decodecaps(inpart.read()) 1407 caps = decodecaps(inpart.read())
1408 if op.reply is None: 1408 if op.reply is None:
1409 op.reply = bundle20(op.ui, caps) 1409 op.reply = bundle20(op.ui, caps)
1410 1410
1411 class AbortFromPart(error.Abort):
1412 """Sub-class of Abort that denotes an error from a bundle2 part."""
1413
1411 @parthandler('error:abort', ('message', 'hint')) 1414 @parthandler('error:abort', ('message', 'hint'))
1412 def handleerrorabort(op, inpart): 1415 def handleerrorabort(op, inpart):
1413 """Used to transmit abort error over the wire""" 1416 """Used to transmit abort error over the wire"""
1414 raise error.Abort(inpart.params['message'], hint=inpart.params.get('hint')) 1417 raise AbortFromPart(inpart.params['message'],
1418 hint=inpart.params.get('hint'))
1415 1419
1416 @parthandler('error:pushkey', ('namespace', 'key', 'new', 'old', 'ret', 1420 @parthandler('error:pushkey', ('namespace', 'key', 'new', 'old', 'ret',
1417 'in-reply-to')) 1421 'in-reply-to'))
1418 def handleerrorpushkey(op, inpart): 1422 def handleerrorpushkey(op, inpart):
1419 """Used to transmit failure of a mandatory pushkey over the wire""" 1423 """Used to transmit failure of a mandatory pushkey over the wire"""