##// END OF EJS Templates
merge.mergestate: factor out code to validate v1/v2 records...
Siddharth Agarwal -
r26500:5bd7c4c0 default
parent child Browse files
Show More
@@ -117,15 +117,9 b' class mergestate(object):'
117 returns list of record [(TYPE, data), ...]"""
117 returns list of record [(TYPE, data), ...]"""
118 v1records = self._readrecordsv1()
118 v1records = self._readrecordsv1()
119 v2records = self._readrecordsv2()
119 v2records = self._readrecordsv2()
120 oldv2 = set() # old format version of v2 record
120 if self._v1v2match(v1records, v2records):
121 for rec in v2records:
121 return v2records
122 if rec[0] == 'L':
122 else:
123 oldv2.add(rec)
124 elif rec[0] == 'F':
125 # drop the onode data (not contained in v1)
126 oldv2.add(('F', _droponode(rec[1])))
127 for rec in v1records:
128 if rec not in oldv2:
129 # v1 file is newer than v2 file, use it
123 # v1 file is newer than v2 file, use it
130 # we have to infer the "other" changeset of the merge
124 # we have to infer the "other" changeset of the merge
131 # we cannot do better than that with v1 of the format
125 # we cannot do better than that with v1 of the format
@@ -140,8 +134,20 b' class mergestate(object):'
140 bits.insert(-2, '')
134 bits.insert(-2, '')
141 v1records[idx] = (r[0], '\0'.join(bits))
135 v1records[idx] = (r[0], '\0'.join(bits))
142 return v1records
136 return v1records
137
138 def _v1v2match(self, v1records, v2records):
139 oldv2 = set() # old format version of v2 record
140 for rec in v2records:
141 if rec[0] == 'L':
142 oldv2.add(rec)
143 elif rec[0] == 'F':
144 # drop the onode data (not contained in v1)
145 oldv2.add(('F', _droponode(rec[1])))
146 for rec in v1records:
147 if rec not in oldv2:
148 return False
143 else:
149 else:
144 return v2records
150 return True
145
151
146 def _readrecordsv1(self):
152 def _readrecordsv1(self):
147 """read on disk merge state for version 1 file
153 """read on disk merge state for version 1 file
General Comments 0
You need to be logged in to leave comments. Login now