[PATCH 2 of 6 mergedriver] mergestate: raise structured exception for unsupported merge records

Siddharth Agarwal sid0 at fb.com
Tue Nov 17 17:58:40 CST 2015


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1447798312 28800
#      Tue Nov 17 14:11:52 2015 -0800
# Node ID a879917dec18a4621476c8af18724f5d5696c663
# Parent  a27ce132c9b2bdbc38884f64c1cc76fdd92e50aa
mergestate: raise structured exception for unsupported merge records

We're going to catch this exception in 'hg summary' to print a better error
message.

This code is pretty untested, so there are no changes to test output. In
upcoming patches we're going to test the output more thoroughly.

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -110,6 +110,7 @@ class mergestate(object):
             del self.otherctx
         self._readmergedriver = None
         self._mdstate = 's'
+        unsupported = set()
         records = self._readrecords()
         for rtype, record in records:
             if rtype == 'L':
@@ -129,10 +130,12 @@ class mergestate(object):
                 bits = record.split('\0')
                 self._state[bits[0]] = bits[1:]
             elif not rtype.islower():
-                raise error.Abort(_('unsupported merge state record: %s')
-                                   % rtype)
+                unsupported.add(rtype)
         self._dirty = False
 
+        if unsupported:
+            raise error.UnsupportedMergeRecords(unsupported)
+
     def _readrecords(self):
         """Read merge state from disk and return a list of record (TYPE, data)
 


More information about the Mercurial-devel mailing list