Patchwork [6,of,6] merge: include base content in merge markers

login
register
mail settings
Submitter Pierre-Yves David
Date June 10, 2014, 8:50 p.m.
Message ID <aa17dc9623be4a67c7a7.1402433430@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4968/
State Changes Requested
Headers show

Comments

Pierre-Yves David - June 10, 2014, 8:50 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1402343082 25200
#      Mon Jun 09 12:44:42 2014 -0700
# Node ID aa17dc9623be4a67c7a727c0ca377c02ae926307
# Parent  fe435e1caaab581f4c67ea44c7075f38e7102575
merge: include base content in merge markers

Since including the base is the only viable option while grafting, we includes
content from merge base by default. This should make conflict from graft (and
related operation) usable by users.

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -188,11 +188,11 @@  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', 'plain')
+        scope = ui.config('ui', 'mergemarkersscope', 'base')
         r = simplemerge.simplemerge(ui, a, b, c, quiet=True, label=labels,
                                     no_minimal=(scope != 'minimal'))
         if not r:
             ui.debug(" premerge successful\n")
             return 0
@@ -217,11 +217,11 @@  def _imerge(repo, mynode, orig, fcd, fco
     if r:
         a, b, c, back = files
 
         ui = repo.ui
 
-        scope = ui.config('ui', 'mergemarkersscope', 'plain')
+        scope = ui.config('ui', 'mergemarkersscope', 'base')
         r = simplemerge.simplemerge(ui, a, b, c, label=labels,
                                     no_minimal=(scope != 'minimal'))
         return True, r
     return False, 0
 
@@ -386,11 +386,11 @@  def filemerge(repo, mynode, orig, fcd, f
     ui.debug("my %s other %s ancestor %s\n" % (fcd, fco, fca))
 
     markerstyle = ui.config('ui', 'mergemarkers', 'detailed')
     if not labels:
         labels = _defaultconflictlabels
-    markersscope = ui.config('ui', 'mergemarkersscope', 'plain')
+    markersscope = ui.config('ui', 'mergemarkersscope', 'base')
     if markersscope == 'base' and len(labels) < 3:
         labels.append('base')
     if markerstyle != 'basic':
         labels = _formatlabels(repo, fcd, fco, fca, labels)
 
diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -1228,16 +1228,17 @@  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
-    ``plain`` includes the whole content of the conflicting chunk.
-    ``base`` will also include the content from the merge base in a third block.
-    Finally, ``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.
+    ``base`` will include the content from the merge base in a third block.
+    Alternatively, ``plain`` display conflicting chunk only for each side of the
+    merge (two total) This is likely to produce confusing marker during grafting
+    and rebasing. Finally, ``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-commit-amend.t b/tests/test-commit-amend.t
--- a/tests/test-commit-amend.t
+++ b/tests/test-commit-amend.t
@@ -587,11 +587,11 @@  Amend a merge changeset (with renames an
   [1]
   $ hg resolve -m cc
   no more unresolved files
   $ hg ci -m 'merge bar'
   $ hg log --config diff.git=1 -pr .
-  changeset:   23:93cd4445f720
+  changeset:   23:a9f00f6f41d4
   tag:         tip
   parent:      22:30d96aeaf27b
   parent:      21:1aa437659d19
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
@@ -601,13 +601,14 @@  Amend a merge changeset (with renames an
   copy from a
   copy to aa
   diff --git a/cc b/cc
   --- a/cc
   +++ b/cc
-  @@ -1,1 +1,5 @@
+  @@ -1,1 +1,6 @@
   +<<<<<<< local: 30d96aeaf27b - test: aa
    dd
+  +======= base:  000000000000  - : 
   +=======
   +cc
   +>>>>>>> other: 1aa437659d19  bar - test: aazzcc
   diff --git a/z b/zz
   rename from z
@@ -619,11 +620,11 @@  Amend a merge changeset (with renames an
   zz renamed from z:69a1b67522704ec122181c0890bd16e9d3e7516a
   $ hg debugrename cc
   cc not renamed
   $ hg ci --amend -m 'merge bar (amend message)'
   $ hg log --config diff.git=1 -pr .
-  changeset:   24:832b50f2c271
+  changeset:   24:d33a8691f0b7
   tag:         tip
   parent:      22:30d96aeaf27b
   parent:      21:1aa437659d19
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
@@ -633,13 +634,14 @@  Amend a merge changeset (with renames an
   copy from a
   copy to aa
   diff --git a/cc b/cc
   --- a/cc
   +++ b/cc
-  @@ -1,1 +1,5 @@
+  @@ -1,1 +1,6 @@
   +<<<<<<< local: 30d96aeaf27b - test: aa
    dd
+  +======= base:  000000000000  - : 
   +=======
   +cc
   +>>>>>>> other: 1aa437659d19  bar - test: aazzcc
   diff --git a/z b/zz
   rename from z
@@ -652,11 +654,11 @@  Amend a merge changeset (with renames an
   $ hg debugrename cc
   cc not renamed
   $ hg mv zz z
   $ hg ci --amend -m 'merge bar (undo rename)'
   $ hg log --config diff.git=1 -pr .
-  changeset:   26:bdafc5c72f74
+  changeset:   26:3446332ae915
   tag:         tip
   parent:      22:30d96aeaf27b
   parent:      21:1aa437659d19
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
@@ -666,13 +668,14 @@  Amend a merge changeset (with renames an
   copy from a
   copy to aa
   diff --git a/cc b/cc
   --- a/cc
   +++ b/cc
-  @@ -1,1 +1,5 @@
+  @@ -1,1 +1,6 @@
   +<<<<<<< local: 30d96aeaf27b - test: aa
    dd
+  +======= base:  000000000000  - : 
   +=======
   +cc
   +>>>>>>> other: 1aa437659d19  bar - test: aazzcc
   
   $ hg debugrename z
@@ -688,13 +691,13 @@  Amend a merge changeset (with renames du
   $ hg merge -q bar
   $ hg mv aa aaa
   $ echo aa >> aaa
   $ hg ci -m 'merge bar again'
   $ hg log --config diff.git=1 -pr .
-  changeset:   28:32f19415b634
+  changeset:   28:edcb44f6de79
   tag:         tip
-  parent:      26:bdafc5c72f74
+  parent:      26:3446332ae915
   parent:      27:4c94d5bc65f5
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     merge bar again
   
@@ -723,13 +726,13 @@  Amend a merge changeset (with renames du
   $ hg debugrename aaa
   aaa renamed from aa:37d9b5d994eab34eda9c16b195ace52c7b129980
   $ hg mv aaa aa
   $ hg ci --amend -m 'merge bar again (undo rename)'
   $ hg log --config diff.git=1 -pr .
-  changeset:   30:1e2a06b3d312
+  changeset:   30:cf1f13b05c61
   tag:         tip
-  parent:      26:bdafc5c72f74
+  parent:      26:3446332ae915
   parent:      27:4c94d5bc65f5
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     merge bar again (undo rename)
   
@@ -763,25 +766,25 @@  Amend a merge changeset (with manifest-l
   $ hg merge -q bar
   local changed aa which remote deleted
   use (c)hanged version or (d)elete? c
   $ hg ci -m 'merge bar (with conflicts)'
   $ hg log --config diff.git=1 -pr .
-  changeset:   33:97a298b0c59f
+  changeset:   33:0ff09fa7aac8
   tag:         tip
-  parent:      32:3d78ce4226b8
+  parent:      32:bfd9b6f74c11
   parent:      31:67db8847a540
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     merge bar (with conflicts)
   
   
   $ hg rm aa
   $ hg ci --amend -m 'merge bar (with conflicts, amended)'
   $ hg log --config diff.git=1 -pr .
-  changeset:   35:6de0c1bde1c8
+  changeset:   35:47fd9564aac3
   tag:         tip
-  parent:      32:3d78ce4226b8
+  parent:      32:bfd9b6f74c11
   parent:      31:67db8847a540
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     merge bar (with conflicts, amended)
   
diff --git a/tests/test-conflict.t b/tests/test-conflict.t
--- a/tests/test-conflict.t
+++ b/tests/test-conflict.t
@@ -51,10 +51,16 @@ 
   1
   2
   3
   6
   8
+  ======= base:  bb6627f8ca18  - test: ancestor
+  One
+  Two
+  Three
+  Four
+  Five
   =======
   1
   2
   3
   4
@@ -85,10 +91,16 @@  Verify custom conflict markers
   1
   2
   3
   6
   8
+  ======= base:  test 0
+  One
+  Two
+  Three
+  Four
+  Five
   =======
   1
   2
   3
   4
@@ -115,10 +127,16 @@  Verify basic conflict markers
   1
   2
   3
   6
   8
+  ======= base
+  One
+  Two
+  Three
+  Four
+  Five
   =======
   1
   2
   3
   4
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -1049,10 +1049,11 @@  conflict: keyword should stay outside co
   [1]
   $ cat m
   $Id$
   <<<<<<< local: 88a80c8d172e - test: 8bar
   bar
+  ======= base:  38d7794d6dad  - test: 4kw
   =======
   foo
   >>>>>>> other: 85d2d2d732a5  - test: simplemerge
 
 resolve to local
diff --git a/tests/test-merge-local.t b/tests/test-merge-local.t
--- a/tests/test-merge-local.t
+++ b/tests/test-merge-local.t
@@ -73,10 +73,12 @@  Local merge with bad merge tool:
   +++ b/zzz1_merge_ok
   +new last line
   --- a/zzz2_merge_bad
   +++ b/zzz2_merge_bad
   +another last line
+  +======= base:         432e9bca7678 - test: revision 1
+  +new last line
   +=======
 
   $ hg st
   M zzz1_merge_ok
   M zzz2_merge_bad
@@ -107,13 +109,18 @@  Local merge with conflicts:
   +++ b/zzz1_merge_ok
   +new last line
   --- a/zzz2_merge_bad
   +++ b/zzz2_merge_bad
   +another last line
+  +======= base:         432e9bca7678 - test: revision 1
+  +new last line
   +=======
+  +======= base:         c929647821fa  - test: revision 0
   +=======
   +new last line
+  +======= base:         432e9bca7678 - test: revision 1
+  +new last line
   +=======
 
   $ hg st
   M zzz1_merge_ok
   M zzz2_merge_bad
diff --git a/tests/test-merge-revert2.t b/tests/test-merge-revert2.t
--- a/tests/test-merge-revert2.t
+++ b/tests/test-merge-revert2.t
@@ -52,15 +52,16 @@ 
 
   $ hg diff --nodates
   diff -r dfab7f3c2efb file1
   --- a/file1
   +++ b/file1
-  @@ -1,3 +1,7 @@
+  @@ -1,3 +1,8 @@
    added file1
    another line of text
   +<<<<<<< working copy: c3fa057dd86f  - test: added file1 and file2
   +changed file1 different
+  +======= base:         c3fa057dd86f  - test: added file1 and file2
   +=======
    changed file1
   +>>>>>>> destination:  dfab7f3c2efb - test: changed file1
 
   $ hg status
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
@@ -66,10 +66,12 @@  running from a devel copy, not a temp in
   [1]
   $ aftermerge
   # cat f
   <<<<<<< local: ef83787e2614  - test: revision 1
   revision 1
+  ======= base:  ffd2bda21d6e  - test: revision 0
+  revision 0
   =======
   revision 2
   >>>>>>> other: 0185f4e0cf02  - test: revision 2
   space
   # hg stat
diff --git a/tests/test-merge-types.t b/tests/test-merge-types.t
--- a/tests/test-merge-types.t
+++ b/tests/test-merge-types.t
@@ -290,17 +290,19 @@  h: l vs l, different
   U h
   $ tellmeabout a
   a is a plain file with content:
   <<<<<<< local: 0139c5610547 - test: 2
   2
+  ======= base:  000000000000  - : 
   =======
   1
   >>>>>>> other: 97e29675e796  - test: 1
   $ tellmeabout b
   b is a plain file with content:
   <<<<<<< local: 0139c5610547 - test: 2
   2
+  ======= base:  000000000000  - : 
   =======
   1
   >>>>>>> other: 97e29675e796  - test: 1
   $ tellmeabout c
   c is a plain file with content:
@@ -345,17 +347,19 @@  h: l vs l, different
   [1]
   $ tellmeabout a
   a is a plain file with content:
   <<<<<<< local: 97e29675e796  - test: 1
   1
+  ======= base:  000000000000  - : 
   =======
   2
   >>>>>>> other: 0139c5610547 - test: 2
   $ tellmeabout b
   b is an executable file with content:
   <<<<<<< local: 97e29675e796  - test: 1
   1
+  ======= base:  000000000000  - : 
   =======
   2
   >>>>>>> other: 0139c5610547 - test: 2
   $ tellmeabout c
   c is an executable file with content:
diff --git a/tests/test-merge7.t b/tests/test-merge7.t
--- a/tests/test-merge7.t
+++ b/tests/test-merge7.t
@@ -98,10 +98,12 @@  pull and merge from test-a again
 
   $ cat test.txt
   one
   <<<<<<< local: 50c3a7e29886  - test: Merge 1
   two-point-five
+  ======= base:  96b70246a118  - test: Numbers as words
+  two
   =======
   two-point-one
   >>>>>>> other: 40d11a4173a8 - test: two -> two-point-one
   three
 
diff --git a/tests/test-shelve.t b/tests/test-shelve.t
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -210,14 +210,15 @@  ensure that we have a merge with unresol
   ? a/a.orig
   $ hg diff
   diff --git a/a/a b/a/a
   --- a/a/a
   +++ b/a/a
-  @@ -1,2 +1,6 @@
+  @@ -1,2 +1,7 @@
    a
   +<<<<<<< dest:   *  - shelve: pending changes temporary commit (glob)
    c
+  +======= base:   cc01e2b0c59f  - test: initial commit
   +=======
   +a
   +>>>>>>> source: 4702e8911fe0 - shelve: changes to '[mq]: second.patch'
   diff --git a/b.rename/b b/b.rename/b
   new file mode 100644
@@ -616,10 +617,11 @@  unshelve and conflicts with tracked and 
   M f
   ? f.orig
   $ cat f
   <<<<<<< dest:   5f6b880e719b  - shelve: pending changes temporary commit
   g
+  ======= base:   000000000000  - : 
   =======
   f
   >>>>>>> source: 23b29cada8ba - shelve: changes to 'commit stuff'
   $ cat f.orig
   g
@@ -659,10 +661,11 @@  unshelve and conflicts with tracked and 
   M f
   ? f.orig
   $ cat f
   <<<<<<< dest:   *  - test: intermediate other change (glob)
   g
+  ======= base:   000000000000  - : 
   =======
   f
   >>>>>>> source: 23b29cada8ba - shelve: changes to 'commit stuff'
   $ cat f.orig
   g
diff --git a/tests/test-subrepo.t b/tests/test-subrepo.t
--- a/tests/test-subrepo.t
+++ b/tests/test-subrepo.t
@@ -298,10 +298,12 @@  merge tests
 should conflict
 
   $ cat t/t
   <<<<<<< local: 20a0db6fbf6c - test: 10
   conflict
+  ======= base:  6747d179aa9a  - test: 6
+  t2
   =======
   t3
   >>>>>>> other: 7af322bc1198  - test: 7
 
 clone