diff mercurial/error.py @ 45885:600aec73f309

errors: format "abort: " text in a new Abort.format() method This remove some duplication we had. Differential Revision: https://phab.mercurial-scm.org/D9348
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 20 Nov 2020 09:17:38 -0800
parents 98399dd1b96c
children 7eb221b9af6c
line wrap: on
line diff
--- a/mercurial/error.py	Fri Nov 20 08:51:45 2020 -0800
+++ b/mercurial/error.py	Fri Nov 20 09:17:38 2020 -0800
@@ -182,6 +182,14 @@
             # may raise another exception.
             return pycompat.sysstr(self.__bytes__())
 
+    def format(self):
+        from .i18n import _
+
+        message = _(b"abort: %s\n") % self.message
+        if self.hint:
+            message += _(b"(%s)\n") % self.hint
+        return message
+
 
 class InputError(Abort):
     """Indicates that the user made an error in their input.