##// 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,6 +117,25 b' class mergestate(object):'
117 117 returns list of record [(TYPE, data), ...]"""
118 118 v1records = self._readrecordsv1()
119 119 v2records = self._readrecordsv2()
120 if self._v1v2match(v1records, v2records):
121 return v2records
122 else:
123 # v1 file is newer than v2 file, use it
124 # we have to infer the "other" changeset of the merge
125 # we cannot do better than that with v1 of the format
126 mctx = self._repo[None].parents()[-1]
127 v1records.append(('O', mctx.hex()))
128 # add place holder "other" file node information
129 # nobody is using it yet so we do no need to fetch the data
130 # if mctx was wrong `mctx[bits[-2]]` may fails.
131 for idx, r in enumerate(v1records):
132 if r[0] == 'F':
133 bits = r[1].split('\0')
134 bits.insert(-2, '')
135 v1records[idx] = (r[0], '\0'.join(bits))
136 return v1records
137
138 def _v1v2match(self, v1records, v2records):
120 139 oldv2 = set() # old format version of v2 record
121 140 for rec in v2records:
122 141 if rec[0] == 'L':
@@ -126,22 +145,9 b' class mergestate(object):'
126 145 oldv2.add(('F', _droponode(rec[1])))
127 146 for rec in v1records:
128 147 if rec not in oldv2:
129 # v1 file is newer than v2 file, use it
130 # we have to infer the "other" changeset of the merge
131 # we cannot do better than that with v1 of the format
132 mctx = self._repo[None].parents()[-1]
133 v1records.append(('O', mctx.hex()))
134 # add place holder "other" file node information
135 # nobody is using it yet so we do no need to fetch the data
136 # if mctx was wrong `mctx[bits[-2]]` may fails.
137 for idx, r in enumerate(v1records):
138 if r[0] == 'F':
139 bits = r[1].split('\0')
140 bits.insert(-2, '')
141 v1records[idx] = (r[0], '\0'.join(bits))
142 return v1records
148 return False
143 149 else:
144 return v2records
150 return True
145 151
146 152 def _readrecordsv1(self):
147 153 """read on disk merge state for version 1 file
General Comments 0
You need to be logged in to leave comments. Login now