[Updated] D11978: simplemerge: split out function for rendering :merge3 conflict markers
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Mon Jan 17 13:15:19 UTC 2022
Closed by commit rHGe8f1414cfc43: simplemerge: split out function for rendering :merge3 conflict markers (authored by martinvonz).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11978?vs=31633&id=31672
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11978/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11978
AFFECTED FILES
mercurial/simplemerge.py
CHANGE DETAILS
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -354,11 +354,9 @@
m3,
name_a=None,
name_b=None,
- name_base=None,
start_marker=b'<<<<<<<',
mid_marker=b'=======',
end_marker=b'>>>>>>>',
- base_marker=None,
minimize=False,
):
"""Return merge in cvs-like form."""
@@ -368,8 +366,6 @@
start_marker = start_marker + b' ' + name_a
if name_b and end_marker:
end_marker = end_marker + b' ' + name_b
- if name_base and base_marker:
- base_marker = base_marker + b' ' + name_base
merge_groups = m3.merge_groups()
if minimize:
merge_groups = m3.minimize(merge_groups)
@@ -381,9 +377,6 @@
if start_marker is not None:
lines.append(start_marker + newline)
lines.extend(a_lines)
- if base_marker is not None:
- lines.append(base_marker + newline)
- lines.extend(base_lines)
if mid_marker is not None:
lines.append(mid_marker + newline)
lines.extend(b_lines)
@@ -394,7 +387,29 @@
return lines, conflicts
+def render_merge3(m3, name_a, name_b, name_base):
+ """Render conflicts as 3-way conflict markers."""
+ newline = _detect_newline(m3)
+ conflicts = False
+ lines = []
+ for what, group_lines in m3.merge_groups():
+ if what == b'conflict':
+ base_lines, a_lines, b_lines = group_lines
+ conflicts = True
+ lines.append(b'<<<<<<< ' + name_a + newline)
+ lines.extend(a_lines)
+ lines.append(b'||||||| ' + name_base + newline)
+ lines.extend(base_lines)
+ lines.append(b'=======' + newline)
+ lines.extend(b_lines)
+ lines.append(b'>>>>>>> ' + name_b + newline)
+ else:
+ lines.extend(group_lines)
+ return lines, conflicts
+
+
def render_mergediff(m3, name_a, name_b, name_base):
+ """Render conflicts as conflict markers with one snapshot and one diff."""
newline = _detect_newline(m3)
lines = []
conflicts = False
@@ -504,14 +519,12 @@
name_a, name_b, name_base = _picklabels(opts.get('label', []))
if mode == b'mergediff':
lines, conflicts = render_mergediff(m3, name_a, name_b, name_base)
+ elif mode == b'merge3':
+ lines, conflicts = render_merge3(m3, name_a, name_b, name_base)
else:
extrakwargs = {
'minimize': True,
}
- if mode == b'merge3':
- extrakwargs['base_marker'] = b'|||||||'
- extrakwargs['name_base'] = name_base
- extrakwargs['minimize'] = False
lines, conflicts = render_markers(
m3, name_a=name_a, name_b=name_b, **extrakwargs
)
To: martinvonz, #hg-reviewers, Alphare
Cc: mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20220117/e83557c4/attachment-0002.html>
More information about the Mercurial-patches
mailing list