From patchwork Tue Apr 20 04:43:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D10483: errors: remove unnecessary varargs handling from OutOfBandError From: phabricator X-Patchwork-Id: 48800 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Tue, 20 Apr 2021 04:43:04 +0000 martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY In my recent D10465 , I moved some code over from scmutil into `OutOfBandError.__init__`. The code was written to deal with an arbitrary number of `message` arguments to the constructor. It turns out that we only ever pass 0 or 1. Given that, let's simplify it. REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D10483 AFFECTED FILES mercurial/error.py CHANGE DETAILS To: martinvonz, #hg-reviewers Cc: mercurial-patches, mercurial-devel diff --git a/mercurial/error.py b/mercurial/error.py --- a/mercurial/error.py +++ b/mercurial/error.py @@ -311,16 +311,15 @@ class OutOfBandError(RemoteError): """Exception raised when a remote repo reports failure""" - def __init__(self, *messages, **kwargs): + def __init__(self, message=None, hint=None): from .i18n import _ - if messages: - message = _(b"remote error:\n%s") % b''.join(messages) + if message: # Abort.format() adds a trailing newline - message = message.rstrip(b'\n') + message = _(b"remote error:\n%s") % message.rstrip(b'\n') else: message = _(b"remote error") - super(OutOfBandError, self).__init__(message, **kwargs) + super(OutOfBandError, self).__init__(message, hint=hint) class ParseError(Abort):