diff --git a/mercurial/configitems.py b/mercurial/configitems.py --- a/mercurial/configitems.py +++ b/mercurial/configitems.py @@ -1570,6 +1570,12 @@ default=False, ) coreconfigitem( + b'merge', + b'disable-partial-tools', + default=False, + experimental=True, +) +coreconfigitem( b'partial-merge-tools', b'.*', default=None, @@ -1609,6 +1615,14 @@ experimental=True, ) coreconfigitem( + b'partial-merge-tools', + br'.*\.disable', + default=False, + generic=True, + priority=-1, + experimental=True, +) +coreconfigitem( b'merge-tools', b'.*', default=None, diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -1119,6 +1119,8 @@ def _run_partial_resolution_tools(repo, local, other, base): """Runs partial-resolution tools on the three inputs and updates them.""" ui = repo.ui + if ui.configbool(b'merge', b'disable-partial-tools'): + return # Tuples of (order, name, executable path, args) tools = [] seen = set() @@ -1133,6 +1135,8 @@ m = match.match(repo.root, b'', patterns) is_match = m(local.fctx.path()) if is_match: + if ui.configbool(section, b'%s.disable' % name): + continue order = ui.configint(section, b'%s.order' % name, 0) executable = ui.config(section, b'%s.executable' % name, name) args = ui.config(section, b'%s.args' % name) diff --git a/tests/test-merge-partial-tool.t b/tests/test-merge-partial-tool.t --- a/tests/test-merge-partial-tool.t +++ b/tests/test-merge-partial-tool.t @@ -120,6 +120,57 @@ e +Can disable all partial merge tools (the `head` tool would have resolved this +conflict it had been enabled) + + $ hg up -C 4 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg merge 3 -t :merge3 --config merge.disable-partial-tools=yes + merging file + warning: conflicts while merging file! (edit, then use 'hg resolve --mark') + 0 files updated, 0 files merged, 0 files removed, 1 files unresolved + use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon + [1] + $ cat file + a + b + c + d + e + <<<<<<< working copy: d57edaa6e21a - test: a b c d e f3 + f3 + ||||||| common ancestor: 8ae8bb9cc43a - test: a b c d e f + f + ======= + f2 + >>>>>>> merge rev: 8c217da987be - test: a b c d e f2 + + +Can disable one partial merge tool (the `head` tool would have resolved this +conflict it had been enabled) + + $ hg up -C 4 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg merge 3 -t :merge3 --config partial-merge-tools.head.disable=yes + merging file + warning: conflicts while merging file! (edit, then use 'hg resolve --mark') + 0 files updated, 0 files merged, 0 files removed, 1 files unresolved + use 'hg resolve' to retry unresolved file merges or 'hg merge --abort' to abandon + [1] + $ cat file + b + c + d + e + <<<<<<< working copy: d57edaa6e21a - test: a b c d e f3 + f3 + ||||||| common ancestor: 8ae8bb9cc43a - test: a b c d e f + f + ======= + f2 + >>>>>>> merge rev: 8c217da987be - test: a b c d e f2 + + Only tools whose patterns match are run. We make `head` not match here, so only `tail` should run