# HG changeset patch # User Martin von Zweigbergk # Date 2020-12-15 02:09:37 # Node ID 3ca5ca380a3477a81402947e23fc50d13a4bd9d9 # Parent 34f2c634c8f6a24cde86a0c9bf9c9fa3d78bea61 filemerge: add support for the new "mergediff" marker style to premerge This adds support for the new "mergediff" conflict marker style to "merge-tools..premerge" (the new value is called "keep-mergediff"). Differential Revision: https://phab.mercurial-scm.org/D9606 diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -408,7 +408,7 @@ def _premerge(repo, fcd, fco, fca, toolc ui = repo.ui - validkeep = [b'keep', b'keep-merge3'] + validkeep = [b'keep', b'keep-merge3', b'keep-mergediff'] # do we attempt to simplemerge first? try: @@ -423,12 +423,17 @@ def _premerge(repo, fcd, fco, fca, toolc ) if premerge: - if premerge == b'keep-merge3': + mode = b'merge' + if premerge in {b'keep-merge3', b'keep-mergediff'}: if not labels: labels = _defaultconflictlabels if len(labels) < 3: labels.append(b'base') - r = simplemerge.simplemerge(ui, fcd, fca, fco, quiet=True, label=labels) + if premerge == b'keep-mergediff': + mode = b'mergediff' + r = simplemerge.simplemerge( + ui, fcd, fca, fco, quiet=True, label=labels, mode=mode + ) if not r: ui.debug(b" premerge successful\n") return 0 diff --git a/mercurial/helptext/config.txt b/mercurial/helptext/config.txt --- a/mercurial/helptext/config.txt +++ b/mercurial/helptext/config.txt @@ -1521,12 +1521,13 @@ Supported arguments: ``premerge`` Attempt to run internal non-interactive 3-way merge tool before - launching external tool. Options are ``true``, ``false``, ``keep`` or - ``keep-merge3``. The ``keep`` option will leave markers in the file if the - premerge fails. The ``keep-merge3`` will do the same but include information - about the base of the merge in the marker (see internal :merge3 in - :hg:`help merge-tools`). - (default: True) + launching external tool. Options are ``true``, ``false``, ``keep``, + ``keep-merge3``, or ``keep-mergediff`` (experimental). The ``keep`` option + will leave markers in the file if the premerge fails. The ``keep-merge3`` + will do the same but include information about the base of the merge in the + marker (see internal :merge3 in :hg:`help merge-tools`). The + ``keep-mergediff`` option is similar but uses a different marker style + (see internal :merge3 in :hg:`help merge-tools`). (default: True) ``binary`` This tool can merge binary files. (default: False, unless tool diff --git a/relnotes/next b/relnotes/next --- a/relnotes/next +++ b/relnotes/next @@ -33,7 +33,9 @@ `internal:merge3`, but it shows conflicts differently. Instead of showing 2 or 3 snapshots of the conflicting pieces of code, it shows one snapshot and a diff. This may be useful when at least one - side of the conflict is similar to the base. + side of the conflict is similar to the base. The new marker style + is also supported by "premerge" as + `merge-tools..premerge=keep-mergediff`. == New Experimental Features == diff --git a/tests/test-merge-tools.t b/tests/test-merge-tools.t --- a/tests/test-merge-tools.t +++ b/tests/test-merge-tools.t @@ -1255,6 +1255,46 @@ premerge=keep-merge3 keeps conflict mark # hg resolve --list R f +premerge=keep-mergediff keeps conflict markers with base content: + + $ beforemerge + [merge-tools] + false.whatever= + true.priority=1 + true.executable=cat + # hg update -C 1 + $ hg merge -r 4 --config merge-tools.true.premerge=keep-mergediff + merging f + <<<<<<< + ------- base + +++++++ working copy: ef83787e2614 - test: revision 1 + -revision 0 + +revision 1 + space + ======= merge rev: 81448d39c9a0 - test: revision 4 + revision 4 + >>>>>>> + revision 0 + space + revision 4 + 0 files updated, 1 files merged, 0 files removed, 0 files unresolved + (branch merge, don't forget to commit) + $ aftermerge + # cat f + <<<<<<< + ------- base + +++++++ working copy: ef83787e2614 - test: revision 1 + -revision 0 + +revision 1 + space + ======= merge rev: 81448d39c9a0 - test: revision 4 + revision 4 + >>>>>>> + # hg stat + M f + # hg resolve --list + R f + premerge=keep respects ui.mergemarkers=basic: $ beforemerge