[Request] [+- ] D11972: simplemerge: use 3-way markers if mode=='merge3', ignoring number of labels
martinvonz (Martin von Zweigbergk)
phabricator at mercurial-scm.org
Wed Jan 12 06:56:25 UTC 2022
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
Before this patch, we use a combination of `mode` and `labels` to
decide which marker style to use. That's mostly my own fault because I
was the one who added the `mergediff` as a "mode" instead of adding a
separate argument for marker style. Still, let's make these arguments
more orthogonal by ignoring the number of labels when deciding which
marker style to use.
This refactoring makes it a little clearer in the simplemerge
*extension* that passing more than 2 `--label` arguments changes the
marker style.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D11972
AFFECTED FILES
contrib/simplemerge
mercurial/filemerge.py
mercurial/simplemerge.py
CHANGE DETAILS
diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py
--- a/mercurial/simplemerge.py
+++ b/mercurial/simplemerge.py
@@ -506,7 +506,7 @@
extrakwargs = {
'minimize': True,
}
- if name_base is not None:
+ if mode == b'merge3':
extrakwargs['base_marker'] = b'|||||||'
extrakwargs['name_base'] = name_base
extrakwargs['minimize'] = False
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -421,14 +421,15 @@
)
if premerge:
+ if not labels:
+ labels = _defaultconflictlabels
+ if len(labels) < 3:
+ labels.append(b'base')
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')
- if premerge == b'keep-mergediff':
- mode = b'mergediff'
+ if premerge == b'keep-mergediff':
+ mode = b'mergediff'
+ elif premerge == b'keep-merge3':
+ mode = b'merge3'
r = simplemerge.simplemerge(
ui, fcd, fca, fco, quiet=True, label=labels, mode=mode
)
@@ -532,7 +533,9 @@
labels = _defaultconflictlabels
if len(labels) < 3:
labels.append(b'base')
- return _imerge(repo, mynode, fcd, fco, fca, toolconf, backup, labels)
+ return _merge(
+ repo, mynode, fcd, fco, fca, toolconf, backup, labels, b'merge3'
+ )
@internaltool(
diff --git a/contrib/simplemerge b/contrib/simplemerge
--- a/contrib/simplemerge
+++ b/contrib/simplemerge
@@ -80,6 +80,8 @@
sys.exit(0)
if len(args) != 3:
raise ParseError(_(b'wrong number of arguments').decode('utf8'))
+ if len(opts[b'label']) > 2:
+ opts[b'mode'] = b'merge3'
local, base, other = args
sys.exit(
simplemerge.simplemerge(
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/20220112/556f73a8/attachment-0001.html>
More information about the Mercurial-patches
mailing list