[PATCH] error: mark HintException as a private base class

Yuya Nishihara yuya at tcha.org
Fri Jul 8 11:50:39 EDT 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1451137556 -32400
#      Sat Dec 26 22:45:56 2015 +0900
# Node ID 1adb7c14f88c38e8570d5198141f493547f9acb6
# Parent  b4d117cee636be8a566f56e84d4b351a736a1299
error: mark HintException as a private base class

HintException is unrelated to the hierarchy of errors. It is an implementation
detail whether a class inherits from HintException or not, a sort of "private
inheritance" in C++.

This patch makes sure that client codes never abuse HintException as an
error category.

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -15,12 +15,12 @@ from __future__ import absolute_import
 
 # Do not import anything here, please
 
-class HintException(Exception):
+class _HintException(Exception):
     def __init__(self, *args, **kw):
         Exception.__init__(self, *args)
         self.hint = kw.get('hint')
 
-class RevlogError(HintException):
+class RevlogError(_HintException):
     pass
 
 class FilteredIndexError(IndexError):
@@ -50,10 +50,10 @@ class ManifestLookupError(LookupError):
 class CommandError(Exception):
     """Exception raised on errors in parsing the command line."""
 
-class InterventionRequired(HintException):
+class InterventionRequired(_HintException):
     """Exception raised when a command requires human intervention."""
 
-class Abort(HintException):
+class Abort(_HintException):
     """Raised if a command needs to print an error and exit."""
 
 class HookLoadError(Abort):
@@ -87,10 +87,10 @@ class ResponseExpected(Abort):
         from .i18n import _
         Abort.__init__(self, _('response expected'))
 
-class OutOfBandError(HintException):
+class OutOfBandError(_HintException):
     """Exception raised when a remote repo reports failure"""
 
-class ParseError(HintException):
+class ParseError(_HintException):
     """Raised when parsing config files and {rev,file}sets (msg[, pos])"""
 
 class UnknownIdentifier(ParseError):
@@ -102,7 +102,7 @@ class UnknownIdentifier(ParseError):
         self.function = function
         self.symbols = symbols
 
-class RepoError(HintException):
+class RepoError(_HintException):
     pass
 
 class RepoLookupError(RepoError):


More information about the Mercurial-devel mailing list