changeset 49167:7af798e497f5

filemerge: add configs to disable some or all partial merge tools When rolling out partial merge tools to users, it's useful to be able to easily turn one or all of them off if a problem is discovered. This patch adds support for that. They can of course also be useful for individual users to be able to temporarily turn off a tool they are otherwise using. Differential Revision: https://phab.mercurial-scm.org/D12588
author Martin von Zweigbergk <martinvonz@google.com>
date Tue, 26 Apr 2022 09:06:30 -0700
parents a932cad26d37
children 5996640fc6fe
files mercurial/configitems.py mercurial/filemerge.py tests/test-merge-partial-tool.t
diffstat 3 files changed, 69 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/configitems.py	Wed May 04 18:17:44 2022 +0200
+++ b/mercurial/configitems.py	Tue Apr 26 09:06:30 2022 -0700
@@ -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,
--- a/mercurial/filemerge.py	Wed May 04 18:17:44 2022 +0200
+++ b/mercurial/filemerge.py	Tue Apr 26 09:06:30 2022 -0700
@@ -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)
--- a/tests/test-merge-partial-tool.t	Wed May 04 18:17:44 2022 +0200
+++ b/tests/test-merge-partial-tool.t	Tue Apr 26 09:06:30 2022 -0700
@@ -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