[PATCH 1 of 4] error: refactor common hint-pattern into a common base class
Jordi Gutiérrez Hermoso
jordigh at octave.org
Thu May 21 20:30:19 UTC 2015
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh at octave.org>
# Date 1432240086 14400
# Thu May 21 16:28:06 2015 -0400
# Node ID 1afb582cf7f85118a1c48c69aaa54625db5afab0
# Parent bb2f543b48b5290c634cc26c7e61d7c3e9dd8f6e
error: refactor common hint-pattern into a common base class
I'm about to make another exception class require hints, so third
strike and you refactor.
diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -13,6 +13,11 @@ imports.
# Do not import anything here, please
+class HintException(Exception):
+ def __init__(self, *args, **kw):
+ Exception.__init__(self, *args)
+ self.hint = kw.get('hint')
+
class RevlogError(Exception):
pass
@@ -46,11 +51,9 @@ class CommandError(Exception):
class InterventionRequired(Exception):
"""Exception raised when a command requires human intervention."""
-class Abort(Exception):
+class Abort(HintException):
"""Raised if a command needs to print an error and exit."""
- def __init__(self, *args, **kw):
- Exception.__init__(self, *args)
- self.hint = kw.get('hint')
+ pass
class HookAbort(Abort):
"""raised when a validation hook fails, aborting an operation
@@ -76,10 +79,8 @@ class UnknownIdentifier(ParseError):
self.function = function
self.symbols = symbols
-class RepoError(Exception):
- def __init__(self, *args, **kw):
- Exception.__init__(self, *args)
- self.hint = kw.get('hint')
+class RepoError(HintException):
+ pass
class RepoLookupError(RepoError):
pass
More information about the Mercurial-devel
mailing list