changeset 45151:e429e7c801b2

error: normalize "unresolved conflicts" error messages with a custom class Differential Revision: https://phab.mercurial-scm.org/D8713
author Daniel Ploch <dploch@google.com>
date Tue, 14 Jul 2020 13:35:54 -0700
parents dc5e5577af39
children b3b0cd8b9366
files hgext/rebase.py mercurial/error.py mercurial/shelve.py
diffstat 3 files changed, 18 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/rebase.py	Mon Jul 13 16:42:44 2020 -0700
+++ b/hgext/rebase.py	Tue Jul 14 13:35:54 2020 -0700
@@ -630,12 +630,7 @@
                         if self.inmemory:
                             raise error.InMemoryMergeConflictsError()
                         else:
-                            raise error.InterventionRequired(
-                                _(
-                                    b"unresolved conflicts (see 'hg "
-                                    b"resolve', then 'hg rebase --continue')"
-                                )
-                            )
+                            raise error.ConflictResolutionRequired(b'rebase')
             if not self.collapsef:
                 merging = p2 != nullrev
                 editform = cmdutil.mergeeditform(merging, b'rebase')
--- a/mercurial/error.py	Mon Jul 13 16:42:44 2020 -0700
+++ b/mercurial/error.py	Tue Jul 14 13:35:54 2020 -0700
@@ -106,6 +106,22 @@
     __bytes__ = _tobytes
 
 
+class ConflictResolutionRequired(InterventionRequired):
+    """Exception raised when a continuable command required merge conflict resolution."""
+
+    def __init__(self, opname):
+        from .i18n import _
+
+        self.opname = opname
+        InterventionRequired.__init__(
+            self,
+            _(
+                b"unresolved conflicts (see 'hg resolve', then 'hg %s --continue')"
+            )
+            % opname,
+        )
+
+
 class Abort(Hint, Exception):
     """Raised if a command needs to print an error and exit."""
 
--- a/mercurial/shelve.py	Mon Jul 13 16:42:44 2020 -0700
+++ b/mercurial/shelve.py	Tue Jul 14 13:35:54 2020 -0700
@@ -1014,12 +1014,7 @@
                 activebookmark,
                 interactive,
             )
-            raise error.InterventionRequired(
-                _(
-                    b"unresolved conflicts (see 'hg resolve', then "
-                    b"'hg unshelve --continue')"
-                )
-            )
+            raise error.ConflictResolutionRequired(b'unshelve')
 
         with repo.dirstate.parentchange():
             repo.setparents(tmpwctx.node(), nodemod.nullid)