martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This adds support for the new "mergediff" conflict marker style to
  "merge-tools.<tool>.premerge" (the new value is called
  "keep-mergediff").

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9606

AFFECTED FILES
  mercurial/filemerge.py
  mercurial/helptext/config.txt
  relnotes/next
  tests/test-merge-tools.t

CHANGE DETAILS

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 @@
   # 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
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.<tool>.premerge=keep-mergediff`.
 
 == New Experimental Features ==
 
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 @@
 
 ``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/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -408,7 +408,7 @@
 
     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,16 @@
             )
 
     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



To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to