mercurial/error.py
changeset 45884 98399dd1b96c
parent 45883 1817b66897ad
child 45885 600aec73f309
--- a/mercurial/error.py	Thu Nov 19 11:23:59 2020 -0800
+++ b/mercurial/error.py	Fri Nov 20 08:51:45 2020 -0800
@@ -267,6 +267,20 @@
 
     __bytes__ = _tobytes
 
+    def format(self):
+        from .i18n import _
+
+        if self.location is not None:
+            message = _(b"hg: parse error at %s: %s\n") % (
+                pycompat.bytestr(self.location),
+                self.message,
+            )
+        else:
+            message = _(b"hg: parse error: %s\n") % self.message
+        if self.hint:
+            message += _(b"(%s)\n") % self.hint
+        return message
+
 
 class PatchError(Exception):
     __bytes__ = _tobytes