Patchwork [1,of,4] filemerge: make capability check for internal tools ignore merge-tools section

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 24, 2018, 6:20 p.m.
Message ID <612d99ed365e4865f682.1535134842@blacknile>
Download mbox | patch
Permalink /patch/34031/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Aug. 24, 2018, 6:20 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1534913821 -32400
#      Wed Aug 22 13:57:01 2018 +0900
# Node ID 612d99ed365e4865f682a9483f70d525cfd85d1d
# Parent  bb2b462f81daae07d5400aee7db794857959979c
# Available At https://bitbucket.org/foozy/mercurial-wip
#              hg pull https://bitbucket.org/foozy/mercurial-wip -r 612d99ed365e
# EXP-Topic filemerge-followup
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

Patch

diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -140,9 +140,8 @@  def _picktool(repo, ui, path, binary, sy
     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):
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
@@ -1897,9 +1897,11 @@  checked strictly.
 (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 @@  internal merge tools is checked strictly
 (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 @@  capability)
 
   $ 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 @@  capability)
 
   $ hg debugpickmergetool \
   > -r 6d00b3726f6e \
+  > --config merge-tools.:other.symlink=true \
   > --config ui.merge=:other
   f = :prompt
 
@@ -2002,6 +2007,7 @@  checked striclty)
 
   $ 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 @@  checked striclty)
   > --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)