mercurial/error.py
changeset 46796 e2f7b2695ba1
parent 46690 6fc57680cfd6
parent 46388 ae62ab82a345
child 46819 d4ba4d51f85f
equal deleted inserted replaced
46795:6b52cffd8d0a 46796:e2f7b2695ba1
    15 
    15 
    16 import difflib
    16 import difflib
    17 
    17 
    18 # Do not import anything but pycompat here, please
    18 # Do not import anything but pycompat here, please
    19 from . import pycompat
    19 from . import pycompat
       
    20 
       
    21 if pycompat.TYPE_CHECKING:
       
    22     from typing import (
       
    23         Optional,
       
    24     )
    20 
    25 
    21 
    26 
    22 def _tobytes(exc):
    27 def _tobytes(exc):
    23     """Byte-stringify exception in the same way as BaseException_str()"""
    28     """Byte-stringify exception in the same way as BaseException_str()"""
    24     if not exc.args:
    29     if not exc.args:
   168 
   173 
   169 class Abort(Hint, Exception):
   174 class Abort(Hint, Exception):
   170     """Raised if a command needs to print an error and exit."""
   175     """Raised if a command needs to print an error and exit."""
   171 
   176 
   172     def __init__(self, message, hint=None):
   177     def __init__(self, message, hint=None):
       
   178         # type: (bytes, Optional[bytes]) -> None
   173         self.message = message
   179         self.message = message
   174         self.hint = hint
   180         self.hint = hint
   175         # Pass the message into the Exception constructor to help extensions
   181         # Pass the message into the Exception constructor to help extensions
   176         # that look for exc.args[0].
   182         # that look for exc.args[0].
   177         Exception.__init__(self, message)
   183         Exception.__init__(self, message)