[PATCH 3 of 6] mergemarkers: make ``plain`` the default scope

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Tue Jun 10 15:50:27 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1402311527 25200
#      Mon Jun 09 03:58:47 2014 -0700
# Node ID a3ebce9245b8c722f6fd7a81048db2a0f5f3177d
# Parent  a0d2858a720b665e594372fc3953fcdb20d1ce52
mergemarkers: make ``plain`` the default scope

While the minimalist approach looks nice at first glance, the unrecoverable
confusion it can runs into, whenever two unrelated content (with some common lines)
are added at the same place, makes it a bad default choice.

See previous changeset for additional documentation of those behavior.

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -188,13 +188,13 @@ def _premerge(repo, toolconf, files, lab
             raise error.ConfigError(_("%s.premerge not valid "
                                       "('%s' is neither boolean nor %s)") %
                                     (tool, premerge, _valid))
 
     if premerge:
-        scope = ui.config('ui', 'mergemarkersscope', 'minimal')
+        scope = ui.config('ui', 'mergemarkersscope', 'plain')
         r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels,
-                                    no_minimal=(scope == 'plain'))
+                                    no_minimal=(scope != 'minimal'))
         if not r:
             ui.debug(" premerge successful\n")
             return 0
         if premerge != 'keep':
             util.copyfile(back, a) # restore from backup and try again
@@ -217,13 +217,13 @@ def _imerge(repo, mynode, orig, fcd, fco
     if r:
         a, b, c, back = files
 
         ui = repo.ui
 
-        scope = ui.config('ui', 'mergemarkersscope', 'minimal')
+        scope = ui.config('ui', 'mergemarkersscope', 'plain')
         r = simplemerge.simplemerge(ui, a, b, c, label=labels,
-                                    no_minimal=(scope == 'plain'))
+                                    no_minimal=(scope != 'minimal'))
         return True, r
     return False, 0
 
 @internaltool('dump', True)
 def _idump(repo, mynode, orig, fcd, fco, fca, toolconf, files, labels=None):
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1228,12 +1228,15 @@ User interface controls.
     Defaults to showing the hash, tags, branches, bookmarks, author, and
     the first line of the commit description.
 
 ``mergemarkersscope``
     Set the amount of information included in the markers. The default
-    ``minimal`` reduce the size of conflicting chunk as much as possible.
-    ``plain`` can be used to include the whole content of the conflicting chunk.
+    ``plain`` includes the whole content of the conflicting chunk.
+    Alternatively, ``minimal`` can be used to reduce the size of conflicting
+    chunk as much as possible. ``minimal`` can be heavily confuse when unrelated
+    content added to the same location share some common line (blank, common
+    programming construct) by chance.
 
 ``portablefilenames``
     Check for portable filenames. Can be ``warn``, ``ignore`` or ``abort``.
     Default is ``warn``.
     If set to ``warn`` (or ``true``), a warning message is printed on POSIX
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -45,17 +45,20 @@
   $ hg id
   618808747361+c0c68e4fe667+ tip
 
   $ cat a
   Small Mathematical Series.
+  <<<<<<< local: 618808747361 - test: branch2
   1
   2
   3
-  <<<<<<< local: 618808747361 - test: branch2
   6
   8
   =======
+  1
+  2
+  3
   4
   5
   >>>>>>> other: c0c68e4fe667  - test: branch1
   Hop we are done.
 
@@ -76,17 +79,20 @@ Verify custom conflict markers
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
 
   $ cat a
   Small Mathematical Series.
+  <<<<<<< local: test 2
   1
   2
   3
-  <<<<<<< local: test 2
   6
   8
   =======
+  1
+  2
+  3
   4
   5
   >>>>>>> other: test 1
   Hop we are done.
 
@@ -103,17 +109,20 @@ Verify basic conflict markers
   use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
   [1]
 
   $ cat a
   Small Mathematical Series.
+  <<<<<<< local
   1
   2
   3
-  <<<<<<< local
   6
   8
   =======
+  1
+  2
+  3
   4
   5
   >>>>>>> other
   Hop we are done.
 


More information about the Mercurial-devel mailing list