mercurial/error.py
branchstable
changeset 46681 ae62ab82a345
parent 45942 89a2afe31e82
child 46794 e2f7b2695ba1
equal deleted inserted replaced
46680:6595e22048fe 46681:ae62ab82a345
    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:
   167 
   172 
   168 class Abort(Hint, Exception):
   173 class Abort(Hint, Exception):
   169     """Raised if a command needs to print an error and exit."""
   174     """Raised if a command needs to print an error and exit."""
   170 
   175 
   171     def __init__(self, message, hint=None):
   176     def __init__(self, message, hint=None):
       
   177         # type: (bytes, Optional[bytes]) -> None
   172         self.message = message
   178         self.message = message
   173         self.hint = hint
   179         self.hint = hint
   174         # Pass the message into the Exception constructor to help extensions
   180         # Pass the message into the Exception constructor to help extensions
   175         # that look for exc.args[0].
   181         # that look for exc.args[0].
   176         Exception.__init__(self, message)
   182         Exception.__init__(self, message)