Patchwork [1,of,6,mergedriver] error: add a structured exception for unsupported merge records

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 17, 2015, 11:58 p.m.
Message ID <a27ce132c9b2bdbc3888.1447804719@dev666.prn1.facebook.com>
Download mbox | patch
Permalink /patch/11450/
State Accepted
Headers show

Comments

Siddharth Agarwal - Nov. 17, 2015, 11:58 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1447798212 28800
#      Tue Nov 17 14:10:12 2015 -0800
# Node ID a27ce132c9b2bdbc38884f64c1cc76fdd92e50aa
# Parent  082977eac3e6e5cdb2c9263b51b8ab401f256236
error: add a structured exception for unsupported merge records

We're going to use this in summary to print a better error message.

Patch

diff --git a/mercurial/error.py b/mercurial/error.py
--- a/mercurial/error.py
+++ b/mercurial/error.py
@@ -112,6 +112,16 @@  class CapabilityError(RepoError):
 class RequirementError(RepoError):
     """Exception raised if .hg/requires has an unknown entry."""
 
+class UnsupportedMergeRecords(Abort):
+    def __init__(self, recordtypes):
+        from .i18n import _
+        self.recordtypes = sorted(recordtypes)
+        s = ' '.join(self.recordtypes)
+        Abort.__init__(
+            self, _('unsupported merge state records: %s') % s,
+            hint=_('see https://mercurial-scm.org/wiki/MergeStateRecords for '
+                   'more information'))
+
 class LockError(IOError):
     def __init__(self, errno, strerror, filename, desc):
         IOError.__init__(self, errno, strerror, filename)