[Request] [+-- ] D12016: filemerge: always define a "base" label
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Fri Jan 21 23:37:09 UTC 2022
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
It simplifies the code and improves the conflict markers to always
have the "base" label defined.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D12016
AFFECTED FILES
mercurial/filemerge.py
tests/test-annotate.t
tests/test-diff-change.t
tests/test-fastannotate-hg.t
tests/test-merge-changedelete.t
tests/test-merge-force.t
tests/test-merge-tools.t
tests/test-rebase-collapse.t
tests/test-rebase-conflicts.t
tests/test-update-branches.t
CHANGE DETAILS
diff --git a/tests/test-update-branches.t b/tests/test-update-branches.t
--- a/tests/test-update-branches.t
+++ b/tests/test-update-branches.t
@@ -295,7 +295,7 @@
<<<<<<< working copy: 6efa171f091b - test: 3
three
dirty
- ||||||| base
+ ||||||| base: 6efa171f091b - test: 3
three
=======
four
diff --git a/tests/test-rebase-conflicts.t b/tests/test-rebase-conflicts.t
--- a/tests/test-rebase-conflicts.t
+++ b/tests/test-rebase-conflicts.t
@@ -374,7 +374,7 @@
a
+<<<<<<< dest: 328e4ab1f7cc ab - test: ab
b
- +||||||| base
+ +||||||| base: cb9a9f314b8b - test: a
+=======
+b
+c
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -719,7 +719,7 @@
$ cat A
<<<<<<< dest: 82b8abf9c185 D - test: D
D
- ||||||| base
+ ||||||| base: 4a2df7238c3b A - test: A
A
=======
B
@@ -747,7 +747,7 @@
$ cat A
<<<<<<< dest: 82b8abf9c185 D - test: D
BC
- ||||||| base
+ ||||||| base: f899f3910ce7 B - test: B
B
=======
C
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
@@ -1226,7 +1226,7 @@
<<<<<<< working copy: ef83787e2614 - test: revision 1
revision 1
space
- ||||||| base
+ ||||||| base: ffd2bda21d6e - test: revision 0
revision 0
space
=======
@@ -1242,7 +1242,7 @@
<<<<<<< working copy: ef83787e2614 - test: revision 1
revision 1
space
- ||||||| base
+ ||||||| base: ffd2bda21d6e - test: revision 0
revision 0
space
=======
@@ -1264,7 +1264,7 @@
$ hg merge -r 4 --config merge-tools.true.premerge=keep-mergediff
merging f
<<<<<<<
- ------- base
+ ------- base: ffd2bda21d6e - test: revision 0
+++++++ working copy: ef83787e2614 - test: revision 1
-revision 0
+revision 1
@@ -1280,7 +1280,7 @@
$ aftermerge
# cat f
<<<<<<<
- ------- base
+ ------- base: ffd2bda21d6e - test: revision 0
+++++++ working copy: ef83787e2614 - test: revision 1
-revision 0
+revision 1
diff --git a/tests/test-merge-force.t b/tests/test-merge-force.t
--- a/tests/test-merge-force.t
+++ b/tests/test-merge-force.t
@@ -400,7 +400,7 @@
M content1_content2_content1_content4-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content4
- ||||||| base
+ ||||||| base: 8ef80617fa20 - test: base
content1
=======
content2
@@ -430,7 +430,7 @@
M content1_content2_content2_content4-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content4
- ||||||| base
+ ||||||| base: 8ef80617fa20 - test: base
content1
=======
content2
@@ -460,7 +460,7 @@
M content1_content2_content3_content3-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content3
- ||||||| base
+ ||||||| base: 8ef80617fa20 - test: base
content1
=======
content2
@@ -472,7 +472,7 @@
M content1_content2_content3_content4-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content4
- ||||||| base
+ ||||||| base: 8ef80617fa20 - test: base
content1
=======
content2
@@ -502,7 +502,7 @@
M content1_content2_missing_content4-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content4
- ||||||| base
+ ||||||| base: 8ef80617fa20 - test: base
content1
=======
content2
@@ -586,7 +586,7 @@
M missing_content2_content2_content4-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content4
- ||||||| base
+ ||||||| base: 000000000000 - :
=======
content2
>>>>>>> merge rev: 85100b8c675b - test: remote
@@ -609,7 +609,7 @@
M missing_content2_content3_content3-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content3
- ||||||| base
+ ||||||| base: 000000000000 - :
=======
content2
>>>>>>> merge rev: 85100b8c675b - test: remote
@@ -620,7 +620,7 @@
M missing_content2_content3_content4-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content4
- ||||||| base
+ ||||||| base: 000000000000 - :
=======
content2
>>>>>>> merge rev: 85100b8c675b - test: remote
@@ -643,7 +643,7 @@
M missing_content2_missing_content4-tracked
<<<<<<< working copy: 0447570f1af6 - test: local
content4
- ||||||| base
+ ||||||| base: 000000000000 - :
=======
content2
>>>>>>> merge rev: 85100b8c675b - test: remote
@@ -651,7 +651,7 @@
M missing_content2_missing_content4-untracked
<<<<<<< working copy: 0447570f1af6 - test: local
content4
- ||||||| base
+ ||||||| base: 000000000000 - :
=======
content2
>>>>>>> merge rev: 85100b8c675b - test: remote
diff --git a/tests/test-merge-changedelete.t b/tests/test-merge-changedelete.t
--- a/tests/test-merge-changedelete.t
+++ b/tests/test-merge-changedelete.t
@@ -682,7 +682,7 @@
3
<<<<<<< working copy: 13910f48cf7b - test: changed file1, removed file2, chan...
changed2
- ||||||| base
+ ||||||| base: ab57bf49aa27 - test: added files
=======
changed1
>>>>>>> merge rev: 10f9a0a634e8 - test: removed file1, changed file2, chan...
diff --git a/tests/test-fastannotate-hg.t b/tests/test-fastannotate-hg.t
--- a/tests/test-fastannotate-hg.t
+++ b/tests/test-fastannotate-hg.t
@@ -169,7 +169,7 @@
b4
c
b5
- ||||||| base
+ ||||||| base: 3086dbafde1c - test: b
=======
b4
b5
@@ -793,7 +793,7 @@
1
2
3
- ||||||| base
+ ||||||| base: 1ed24be7e7a0 - test: 2
1
2
=======
diff --git a/tests/test-diff-change.t b/tests/test-diff-change.t
--- a/tests/test-diff-change.t
+++ b/tests/test-diff-change.t
@@ -284,7 +284,7 @@
7
-<<<<<<< local: fd1f17c90d7c - test: new file
z
- -||||||| base
+ -||||||| base: ae119d680c82 - test: lots of text
-8
-=======
-y
diff --git a/tests/test-annotate.t b/tests/test-annotate.t
--- a/tests/test-annotate.t
+++ b/tests/test-annotate.t
@@ -225,7 +225,7 @@
b4
c
b5
- ||||||| base
+ ||||||| base: 3086dbafde1c - test: b
=======
b4
b5
@@ -750,7 +750,7 @@
<<<<<<< working copy: 863de62655ef - test: baz:3+->3-
3- baz:3
4 baz:4
- ||||||| base
+ ||||||| base: 56fc739c091f - test: baz:3->3+
3+ baz:3
4 baz:4
=======
@@ -797,7 +797,7 @@
<<<<<<< working copy: cb8df70ae185 - test: qux:4->4+
3+ baz:3
4+ baz:4
- ||||||| base
+ ||||||| base: 56fc739c091f - test: baz:3->3+
3+ baz:3
4 baz:4
=======
@@ -1176,7 +1176,7 @@
1
2
3
- ||||||| base
+ ||||||| base: 1ed24be7e7a0 - test: 2
1
2
=======
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -421,8 +421,6 @@
)
if premerge:
- if len(labels) < 3:
- labels.append(b'base')
mode = b'merge'
if premerge == b'keep-mergediff':
mode = b'mergediff'
@@ -473,14 +471,11 @@
ui = repo.ui
local = simplemerge.MergeInput(fcd)
- if len(labels) > 0:
- local.label = labels[0]
+ local.label = labels[0]
other = simplemerge.MergeInput(fco)
- if len(labels) > 1:
- other.label = labels[1]
+ other.label = labels[1]
base = simplemerge.MergeInput(fca)
- if len(labels) > 2:
- base.label = labels[2]
+ base.label = labels[2]
r = simplemerge.simplemerge(ui, local, base, other, mode=mode)
return True, r, False
@@ -535,8 +530,6 @@
files. It will fail if there are any conflicts and leave markers in
the partially merged file. Marker will have three sections, one from each
side of the merge and one for the base content."""
- if len(labels) < 3:
- labels.append(b'base')
return _merge(repo, fcd, fco, fca, labels, b'merge3')
@@ -575,8 +568,6 @@
the partially merged file. The marker will have two sections, one with the
content from one side of the merge, and one with a diff from the base
content to the content on the other side. (experimental)"""
- if len(labels) < 3:
- labels.append(b'base')
return _merge(repo, fcd, fco, fca, labels, b'mergediff')
@@ -736,10 +727,7 @@
basepath, otherpath, localoutputpath = temppaths
outpath = b""
mylabel, otherlabel = labels[:2]
- if len(labels) >= 3:
- baselabel = labels[2]
- else:
- baselabel = b'base'
+ baselabel = labels[2]
env = {
b'HG_FILE': fcd.path(),
b'HG_MY_NODE': short(mynode),
@@ -861,9 +849,8 @@
newlabels = [
_formatlabel(cd, tmpl, labels[0], pad),
_formatlabel(co, tmpl, labels[1], pad),
+ _formatlabel(ca, tmpl, labels[2], pad),
]
- if len(labels) > 2:
- newlabels.append(_formatlabel(ca, tmpl, labels[2], pad))
return newlabels
@@ -1063,6 +1050,8 @@
if not labels:
labels = [b'local', b'other']
+ if len(labels) < 3:
+ labels.append(b'base')
if mergetype == nomerge:
return func(repo, mynode, fcd, fco, fca, toolconf, labels)
To: martinvonz, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20220121/4a06dfb8/attachment-0001.html>
More information about the Mercurial-patches
mailing list