simplemerge: burn "minimal" feature to the ground
Matt Mackall said:
The goal of simplemerge should have always been to be a drop-in
replacement for RCS merge. Please nuke this minimization thing entirely.
This whole things is now dead.
--- a/contrib/simplemerge Tue Jul 29 11:55:01 2014 -0700
+++ b/contrib/simplemerge Tue Aug 05 14:56:25 2014 -0700
@@ -11,8 +11,7 @@
('a', 'text', None, _('treat all files as text')),
('p', 'print', None,
_('print results instead of overwriting LOCAL')),
- ('', 'no-minimal', None,
- _('do not try to minimize conflict regions')),
+ ('', 'no-minimal', None, _('no effect (DEPRECATED)')),
('h', 'help', None, _('display help and exit')),
('q', 'quiet', None, _('suppress output'))]
--- a/mercurial/filemerge.py Tue Jul 29 11:55:01 2014 -0700
+++ b/mercurial/filemerge.py Tue Aug 05 14:56:25 2014 -0700
@@ -191,8 +191,7 @@
(tool, premerge, _valid))
if premerge:
- r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels,
- no_minimal=True)
+ r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels)
if not r:
ui.debug(" premerge successful\n")
return 0
@@ -219,7 +218,7 @@
ui = repo.ui
- r = simplemerge.simplemerge(ui, a, b, c, label=labels, no_minimal=True)
+ r = simplemerge.simplemerge(ui, a, b, c, label=labels)
return True, r
return False, 0
--- a/mercurial/simplemerge.py Tue Jul 29 11:55:01 2014 -0700
+++ b/mercurial/simplemerge.py Tue Aug 05 14:56:25 2014 -0700
@@ -82,8 +82,7 @@
start_marker='<<<<<<<',
mid_marker='=======',
end_marker='>>>>>>>',
- base_marker=None,
- reprocess=False):
+ base_marker=None):
"""Return merge in cvs-like form.
"""
self.conflicts = False
@@ -93,8 +92,6 @@
newline = '\r\n'
elif self.a[0].endswith('\r'):
newline = '\r'
- if base_marker and reprocess:
- raise CantReprocessAndShowBase
if name_a:
start_marker = start_marker + ' ' + name_a
if name_b:
@@ -102,8 +99,6 @@
if name_base and base_marker:
base_marker = base_marker + ' ' + name_base
merge_regions = self.merge_regions()
- if reprocess is True:
- merge_regions = self.reprocess_merge_regions(merge_regions)
for t in merge_regions:
what = t[0]
if what == 'unchanged':
@@ -278,37 +273,6 @@
ia = aend
ib = bend
- def reprocess_merge_regions(self, merge_regions):
- """Where there are conflict regions, remove the agreed lines.
-
- Lines where both A and B have made the same changes are
- eliminated.
- """
- for region in merge_regions:
- if region[0] != "conflict":
- yield region
- continue
- type, iz, zmatch, ia, amatch, ib, bmatch = region
- a_region = self.a[ia:amatch]
- b_region = self.b[ib:bmatch]
- matches = mdiff.get_matching_blocks(''.join(a_region),
- ''.join(b_region))
- next_a = ia
- next_b = ib
- for region_ia, region_ib, region_len in matches[:-1]:
- region_ia += ia
- region_ib += ib
- reg = self.mismatch_region(next_a, region_ia, next_b,
- region_ib)
- if reg is not None:
- yield reg
- yield 'same', region_ia, region_len + region_ia
- next_a = region_ia + region_len
- next_b = region_ib + region_len
- reg = self.mismatch_region(next_a, amatch, next_b, bmatch)
- if reg is not None:
- yield reg
-
def mismatch_region(next_a, region_ia, next_b, region_ib):
if next_a < region_ia or next_b < region_ib:
return 'conflict', None, None, next_a, region_ia, next_b, region_ib
@@ -437,11 +401,8 @@
else:
out = sys.stdout
- reprocess = not opts.get('no_minimal')
-
m3 = Merge3Text(basetext, localtext, othertext)
- for line in m3.merge_lines(name_a=name_a, name_b=name_b,
- reprocess=reprocess):
+ for line in m3.merge_lines(name_a=name_a, name_b=name_b):
out.write(line)
if not opts.get('print'):
--- a/tests/test-contrib.t Tue Jul 29 11:55:01 2014 -0700
+++ b/tests/test-contrib.t Tue Aug 05 14:56:25 2014 -0700
@@ -143,23 +143,11 @@
$ echo not other >> conflict-local
$ echo end >> conflict-local
$ echo end >> conflict-other
+
$ python simplemerge -p conflict-local base conflict-other
base
<<<<<<< conflict-local
not other
- =======
- other
- >>>>>>> conflict-other
- end
- warning: conflicts during merge.
- [1]
-
---no-minimal
-
- $ python simplemerge -p --no-minimal conflict-local base conflict-other
- base
- <<<<<<< conflict-local
- not other
end
=======
other
@@ -174,10 +162,11 @@
base
<<<<<<< foo
not other
+ end
=======
other
+ end
>>>>>>> conflict-other
- end
warning: conflicts during merge.
[1]
@@ -187,10 +176,11 @@
base
<<<<<<< foo
not other
+ end
=======
other
+ end
>>>>>>> bar
- end
warning: conflicts during merge.
[1]
@@ -231,7 +221,7 @@
-L --label labels to use on conflict markers
-a --text treat all files as text
-p --print print results instead of overwriting LOCAL
- --no-minimal do not try to minimize conflict regions
+ --no-minimal no effect (DEPRECATED)
-h --help display help and exit
-q --quiet suppress output
@@ -251,7 +241,7 @@
-L --label labels to use on conflict markers
-a --text treat all files as text
-p --print print results instead of overwriting LOCAL
- --no-minimal do not try to minimize conflict regions
+ --no-minimal no effect (DEPRECATED)
-h --help display help and exit
-q --quiet suppress output
[1]
@@ -272,7 +262,7 @@
-L --label labels to use on conflict markers
-a --text treat all files as text
-p --print print results instead of overwriting LOCAL
- --no-minimal do not try to minimize conflict regions
+ --no-minimal no effect (DEPRECATED)
-h --help display help and exit
-q --quiet suppress output
[1]
--- a/tests/test-simplemerge.py Tue Jul 29 11:55:01 2014 -0700
+++ b/tests/test-simplemerge.py Tue Aug 05 14:56:25 2014 -0700
@@ -320,66 +320,6 @@
self.log(''.join(ml))
self.assertEquals(ml, MERGED_RESULT)
- def test_minimal_conflicts_common(self):
- """Reprocessing"""
- base_text = ("a\n" * 20).splitlines(True)
- this_text = ("a\n"*10+"b\n" * 10).splitlines(True)
- other_text = ("a\n"*10+"c\n"+"b\n" * 8 + "c\n").splitlines(True)
- m3 = Merge3(base_text, other_text, this_text)
- m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True)
- merged_text = "".join(list(m_lines))
- optimal_text = ("a\n" * 10 + "<<<<<<< OTHER\nc\n=======\n"
- + ">>>>>>> THIS\n"
- + 8* "b\n" + "<<<<<<< OTHER\nc\n=======\n"
- + 2* "b\n" + ">>>>>>> THIS\n")
- self.assertEquals(optimal_text, merged_text)
-
- def test_minimal_conflicts_unique(self):
- def add_newline(s):
- """Add a newline to each entry in the string"""
- return [(x+'\n') for x in s]
-
- base_text = add_newline("abcdefghijklm")
- this_text = add_newline("abcdefghijklmNOPQRSTUVWXYZ")
- other_text = add_newline("abcdefghijklm1OPQRSTUVWXY2")
- m3 = Merge3(base_text, other_text, this_text)
- m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True)
- merged_text = "".join(list(m_lines))
- optimal_text = ''.join(add_newline("abcdefghijklm")
- + ["<<<<<<< OTHER\n1\n=======\nN\n>>>>>>> THIS\n"]
- + add_newline('OPQRSTUVWXY')
- + ["<<<<<<< OTHER\n2\n=======\nZ\n>>>>>>> THIS\n"]
- )
- self.assertEquals(optimal_text, merged_text)
-
- def test_minimal_conflicts_nonunique(self):
- def add_newline(s):
- """Add a newline to each entry in the string"""
- return [(x+'\n') for x in s]
-
- base_text = add_newline("abacddefgghij")
- this_text = add_newline("abacddefgghijkalmontfprz")
- other_text = add_newline("abacddefgghijknlmontfprd")
- m3 = Merge3(base_text, other_text, this_text)
- m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True)
- merged_text = "".join(list(m_lines))
- optimal_text = ''.join(add_newline("abacddefgghijk")
- + ["<<<<<<< OTHER\nn\n=======\na\n>>>>>>> THIS\n"]
- + add_newline('lmontfpr')
- + ["<<<<<<< OTHER\nd\n=======\nz\n>>>>>>> THIS\n"]
- )
- self.assertEquals(optimal_text, merged_text)
-
- def test_reprocess_and_base(self):
- """Reprocessing and showing base breaks correctly"""
- base_text = ("a\n" * 20).splitlines(True)
- this_text = ("a\n"*10+"b\n" * 10).splitlines(True)
- other_text = ("a\n"*10+"c\n"+"b\n" * 8 + "c\n").splitlines(True)
- m3 = Merge3(base_text, other_text, this_text)
- m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True,
- base_marker='|||||||')
- self.assertRaises(CantReprocessAndShowBase, list, m_lines)
-
def test_binary(self):
self.assertRaises(util.Abort, Merge3, ['\x00'], ['a'], ['b'])
--- a/tests/test-simplemerge.py.out Tue Jul 29 11:55:01 2014 -0700
+++ b/tests/test-simplemerge.py.out Tue Aug 05 14:56:25 2014 -0700
@@ -1,5 +1,5 @@
-....................
+................
----------------------------------------------------------------------
-Ran 20 tests in 0.000s
+Ran 16 tests in 0.000s
OK