comparison mercurial/merge.py @ 26986:1ee5e48f09d4

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.
author Siddharth Agarwal <sid0@fb.com>
date Tue, 17 Nov 2015 14:11:52 -0800
parents 6618dfd3ea1c
children 416b2b7d3068
comparison
equal deleted inserted replaced
26985:039a53c87370 26986:1ee5e48f09d4
108 self._other = None 108 self._other = None
109 if 'otherctx' in vars(self): 109 if 'otherctx' in vars(self):
110 del self.otherctx 110 del self.otherctx
111 self._readmergedriver = None 111 self._readmergedriver = None
112 self._mdstate = 's' 112 self._mdstate = 's'
113 unsupported = set()
113 records = self._readrecords() 114 records = self._readrecords()
114 for rtype, record in records: 115 for rtype, record in records:
115 if rtype == 'L': 116 if rtype == 'L':
116 self._local = bin(record) 117 self._local = bin(record)
117 elif rtype == 'O': 118 elif rtype == 'O':
127 self._mdstate = mdstate 128 self._mdstate = mdstate
128 elif rtype in 'FD': 129 elif rtype in 'FD':
129 bits = record.split('\0') 130 bits = record.split('\0')
130 self._state[bits[0]] = bits[1:] 131 self._state[bits[0]] = bits[1:]
131 elif not rtype.islower(): 132 elif not rtype.islower():
132 raise error.Abort(_('unsupported merge state record: %s') 133 unsupported.add(rtype)
133 % rtype)
134 self._dirty = False 134 self._dirty = False
135
136 if unsupported:
137 raise error.UnsupportedMergeRecords(unsupported)
135 138
136 def _readrecords(self): 139 def _readrecords(self):
137 """Read merge state from disk and return a list of record (TYPE, data) 140 """Read merge state from disk and return a list of record (TYPE, data)
138 141
139 We read data from both v1 and v2 files and decide which one to use. 142 We read data from both v1 and v2 files and decide which one to use.