mercurial/error.py
changeset 25945 147bd9e238a1
parent 25484 a5192774e925
child 26355 f51713b8c6fa
equal deleted inserted replaced
25944:337d010f31e6 25945:147bd9e238a1
     8 """Mercurial exceptions.
     8 """Mercurial exceptions.
     9 
     9 
    10 This allows us to catch exceptions at higher levels without forcing
    10 This allows us to catch exceptions at higher levels without forcing
    11 imports.
    11 imports.
    12 """
    12 """
       
    13 
       
    14 from __future__ import absolute_import
    13 
    15 
    14 # Do not import anything here, please
    16 # Do not import anything here, please
    15 
    17 
    16 class HintException(Exception):
    18 class HintException(Exception):
    17     def __init__(self, *args, **kw):
    19     def __init__(self, *args, **kw):
    30         self.index = index
    32         self.index = index
    31         # this can't be called 'message' because at least some installs of
    33         # this can't be called 'message' because at least some installs of
    32         # Python 2.6+ complain about the 'message' property being deprecated
    34         # Python 2.6+ complain about the 'message' property being deprecated
    33         self.lookupmessage = message
    35         self.lookupmessage = message
    34         if isinstance(name, str) and len(name) == 20:
    36         if isinstance(name, str) and len(name) == 20:
    35             from node import short
    37             from .node import short
    36             name = short(name)
    38             name = short(name)
    37         RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
    39         RevlogError.__init__(self, '%s@%s: %s' % (index, name, message))
    38 
    40 
    39     def __str__(self):
    41     def __str__(self):
    40         return RevlogError.__str__(self)
    42         return RevlogError.__str__(self)
    76 
    78 
    77 class UnknownIdentifier(ParseError):
    79 class UnknownIdentifier(ParseError):
    78     """Exception raised when a {rev,file}set references an unknown identifier"""
    80     """Exception raised when a {rev,file}set references an unknown identifier"""
    79 
    81 
    80     def __init__(self, function, symbols):
    82     def __init__(self, function, symbols):
    81         from i18n import _
    83         from .i18n import _
    82         ParseError.__init__(self, _("unknown identifier: %s") % function)
    84         ParseError.__init__(self, _("unknown identifier: %s") % function)
    83         self.function = function
    85         self.function = function
    84         self.symbols = symbols
    86         self.symbols = symbols
    85 
    87 
    86 class RepoError(HintException):
    88 class RepoError(HintException):
   171 
   173 
   172     Also contains the tombstone data substituted for the uncensored data.
   174     Also contains the tombstone data substituted for the uncensored data.
   173     """
   175     """
   174 
   176 
   175     def __init__(self, filename, node, tombstone):
   177     def __init__(self, filename, node, tombstone):
   176         from node import short
   178         from .node import short
   177         RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
   179         RevlogError.__init__(self, '%s:%s' % (filename, short(node)))
   178         self.tombstone = tombstone
   180         self.tombstone = tombstone
   179 
   181 
   180 class CensoredBaseError(RevlogError):
   182 class CensoredBaseError(RevlogError):
   181     """error raised when a delta is rejected because its base is censored
   183     """error raised when a delta is rejected because its base is censored