158 Lines taken from a (and equal to b) |
158 Lines taken from a (and equal to b) |
159 |
159 |
160 'b', lines |
160 'b', lines |
161 Lines taken from b |
161 Lines taken from b |
162 |
162 |
163 'conflict', base_lines, a_lines, b_lines |
163 'conflict', (base_lines, a_lines, b_lines) |
164 Lines from base were changed to either a or b and conflict. |
164 Lines from base were changed to either a or b and conflict. |
165 """ |
165 """ |
166 for t in self.merge_regions(): |
166 for t in self.merge_regions(): |
167 what = t[0] |
167 what = t[0] |
168 if what == b'unchanged': |
168 if what == b'unchanged': |
172 elif what == b'b': |
172 elif what == b'b': |
173 yield what, self.b[t[1] : t[2]] |
173 yield what, self.b[t[1] : t[2]] |
174 elif what == b'conflict': |
174 elif what == b'conflict': |
175 yield ( |
175 yield ( |
176 what, |
176 what, |
177 self.base[t[1] : t[2]], |
177 ( |
178 self.a[t[3] : t[4]], |
178 self.base[t[1] : t[2]], |
179 self.b[t[5] : t[6]], |
179 self.a[t[3] : t[4]], |
|
180 self.b[t[5] : t[6]], |
|
181 ), |
180 ) |
182 ) |
181 else: |
183 else: |
182 raise ValueError(what) |
184 raise ValueError(what) |
183 |
185 |
184 def merge_regions(self): |
186 def merge_regions(self): |
415 |
417 |
416 |
418 |
417 def _mergediff(m3, name_a, name_b, name_base): |
419 def _mergediff(m3, name_a, name_b, name_base): |
418 lines = [] |
420 lines = [] |
419 conflicts = False |
421 conflicts = False |
420 for group in m3.merge_groups(): |
422 for what, group_lines in m3.merge_groups(): |
421 if group[0] == b'conflict': |
423 if what == b'conflict': |
422 base_lines, a_lines, b_lines = group[1:] |
424 base_lines, a_lines, b_lines = group_lines |
423 base_text = b''.join(base_lines) |
425 base_text = b''.join(base_lines) |
424 b_blocks = list( |
426 b_blocks = list( |
425 mdiff.allblocks( |
427 mdiff.allblocks( |
426 base_text, |
428 base_text, |
427 b''.join(b_lines), |
429 b''.join(b_lines), |
470 lines.append(b"======= %s\n" % name_b) |
472 lines.append(b"======= %s\n" % name_b) |
471 lines.extend(b_lines) |
473 lines.extend(b_lines) |
472 lines.append(b">>>>>>>\n") |
474 lines.append(b">>>>>>>\n") |
473 conflicts = True |
475 conflicts = True |
474 else: |
476 else: |
475 lines.extend(group[1]) |
477 lines.extend(group_lines) |
476 return lines, conflicts |
478 return lines, conflicts |
477 |
479 |
478 |
480 |
479 def _resolve(m3, sides): |
481 def _resolve(m3, sides): |
480 lines = [] |
482 lines = [] |
481 for group in m3.merge_groups(): |
483 for what, group_lines in m3.merge_groups(): |
482 if group[0] == b'conflict': |
484 if what == b'conflict': |
483 for side in sides: |
485 for side in sides: |
484 lines.extend(group[side + 1]) |
486 lines.extend(group_lines[side]) |
485 else: |
487 else: |
486 lines.extend(group[1]) |
488 lines.extend(group_lines) |
487 return lines |
489 return lines |
488 |
490 |
489 |
491 |
490 def simplemerge(ui, localctx, basectx, otherctx, **opts): |
492 def simplemerge(ui, localctx, basectx, otherctx, **opts): |
491 """Performs the simplemerge algorithm. |
493 """Performs the simplemerge algorithm. |