From patchwork Sat Nov 21 00:26:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D9350: errors: make ParseError a subtype of Abort From: phabricator X-Patchwork-Id: 47628 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Sat, 21 Nov 2020 00:26:43 +0000 martinvonz created this revision. Herald added a reviewer: hg-reviewers. Herald added a subscriber: mercurial-patches. REVISION SUMMARY I didn't plan this before, but the previous two changes made it really easy to make `ParseError` a subtype of `Abort`. It seems obvious with hindsight that I *should* have planned it :) REPOSITORY rHG Mercurial BRANCH default REVISION DETAIL https://phab.mercurial-scm.org/D9350 AFFECTED FILES mercurial/chgserver.py mercurial/dispatch.py 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 @@ -259,13 +259,12 @@ __bytes__ = _tobytes -class ParseError(Hint, Exception): +class ParseError(Abort): """Raised when parsing config files and {rev,file}sets (msg[, pos])""" def __init__(self, message, location=None, hint=None): - self.message = message + super(ParseError, self).__init__(message, hint=hint) self.location = location - self.hint = hint # Pass the message and possibly location into the Exception constructor # to help code that looks for exc.args. if location is not None: diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -258,9 +258,6 @@ except error.Abort as inst: ferr.write(inst.format()) return -1 - except error.ParseError as inst: - ferr.write(inst.format()) - return -1 msg = _formatargs(req.args) starttime = util.timer() @@ -466,9 +463,6 @@ else: ui.warn(_(b"hg: %s\n") % inst.message) ui.warn(_(b"(use 'hg help -v' for a list of global options)\n")) - except error.ParseError as inst: - ui.warn(inst.format()) - return -1 except error.UnknownCommand as inst: nocmdmsg = _(b"hg: unknown command '%s'\n") % inst.command try: diff --git a/mercurial/chgserver.py b/mercurial/chgserver.py --- a/mercurial/chgserver.py +++ b/mercurial/chgserver.py @@ -506,11 +506,6 @@ args = self._readlist() try: self.ui, lui = _loadnewui(self.ui, args, self.cdebug) - except error.ParseError as inst: - self.ui.warn(inst.format()) - self.ui.flush() - self.cresult.write(b'exit 255') - return except error.Abort as inst: self.ui.error(inst.format()) self.ui.flush()