filemerge: make capability check for internal tools ignore merge-tools section
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 22 Aug 2018 13:57:01 +0900
changeset 39266 82555d7186d0
parent 39265 f98d3c57906f
child 39267 88c5a3ef54b1
filemerge: make capability check for internal tools ignore merge-tools section This is follow up of 4d7b11877dd0. Before this patch, capability check of internal merge tools falls back to _toolbool(), which examines configurations in "merge-tools" section. But "hg help config" explicitly says that "merge-tools" section configures external merge tools. Therefore, this patch makes capability check for internal tools in hascapability() always ignore configurations in merge-tools section. In this patch, command line configurations below are added at tests in tests/test-merge-tools.t, in order to confirm that explicit configuration is intentionally ignored at tool selection. --config merge-tools.:INTERNAL_TOOL.CAPABILITY=true
mercurial/filemerge.py
tests/test-merge-tools.t
--- a/mercurial/filemerge.py	Fri Aug 24 22:21:04 2018 -0700
+++ b/mercurial/filemerge.py	Wed Aug 22 13:57:01 2018 +0900
@@ -140,9 +140,8 @@
     strictcheck = ui.configbool('merge', 'strict-capability-check')
 
     def hascapability(tool, capability, strict=False):
-        if strict and tool in internals:
-            if internals[tool].capabilities.get(capability):
-                return True
+        if tool in internals:
+            return strict and internals[tool].capabilities.get(capability)
         return _toolbool(ui, tool, capability)
 
     def supportscd(tool):
--- a/tests/test-merge-tools.t	Fri Aug 24 22:21:04 2018 -0700
+++ b/tests/test-merge-tools.t	Wed Aug 22 13:57:01 2018 +0900
@@ -1897,9 +1897,11 @@
 (for ui.merge, ignored unintentionally)
 
   $ hg merge 9 \
+  > --config merge-tools.:other.binary=true \
   > --config ui.merge=:other
   tool :other (for pattern b) can't handle binary
   tool true can't handle binary
+  tool :other can't handle binary
   tool false can't handle binary
   no tool found to merge b
   keep (l)ocal [working copy], take (o)ther [merge rev], or leave (u)nresolved for b? u
@@ -1918,6 +1920,7 @@
 (for merge-patterns)
 
   $ hg merge 9 --config merge.strict-capability-check=true \
+  > --config merge-tools.:merge-other.binary=true \
   > --config merge-patterns.b=:merge-other \
   > --config merge-patterns.re:[a-z]=:other
   tool :merge-other (for pattern b) can't handle binary
@@ -1987,6 +1990,7 @@
 
   $ hg debugpickmergetool \
   > -r 6d00b3726f6e \
+  > --config merge-tools.:merge-other.symlink=true \
   > --config merge-patterns.f=:merge-other \
   > --config merge-patterns.re:[f]=:merge-local \
   > --config merge-patterns.re:[a-z]=:other
@@ -1994,6 +1998,7 @@
 
   $ hg debugpickmergetool \
   > -r 6d00b3726f6e \
+  > --config merge-tools.:other.symlink=true \
   > --config ui.merge=:other
   f = :prompt
 
@@ -2002,6 +2007,7 @@
 
   $ hg debugpickmergetool --config merge.strict-capability-check=true \
   > -r 6d00b3726f6e \
+  > --config merge-tools.:merge-other.symlink=true \
   > --config merge-patterns.f=:merge-other \
   > --config merge-patterns.re:[f]=:merge-local \
   > --config merge-patterns.re:[a-z]=:other
@@ -2012,6 +2018,12 @@
   > --config ui.merge=:other
   f = :other
 
+  $ hg debugpickmergetool --config merge.strict-capability-check=true \
+  > -r 6d00b3726f6e \
+  > --config merge-tools.:merge-other.symlink=true \
+  > --config ui.merge=:merge-other
+  f = :prompt
+
 #endif
 
 (--verbose shows some configurations)