diff mercurial/filemerge.py @ 34826:18a3274ed675

configitems: register the full 'merge-tools' config and sub-options We register the merge-tools config section (which has an arbitrary base config value) and the possible sub-attribute. The sub-attribute has to be registered first or at the same time otherwise the '.*' item would shadow them. Merge tools could include "." in their name so we can't constrain any more than just ".*".
author Boris Feld <boris.feld@octobus.net>
date Sun, 08 Oct 2017 20:37:13 +0200
parents 284fa44f7f39
children cab34bda259e
line wrap: on
line diff
--- a/mercurial/filemerge.py	Sat Oct 14 17:05:41 2017 +0200
+++ b/mercurial/filemerge.py	Sun Oct 08 20:37:13 2017 +0200
@@ -29,16 +29,14 @@
     util,
 )
 
-def _toolstr(ui, tool, part, default=""):
-    return ui.config("merge-tools", tool + "." + part, default)
+def _toolstr(ui, tool, part, *args):
+    return ui.config("merge-tools", tool + "." + part, *args)
 
-def _toolbool(ui, tool, part, default=False):
-    return ui.configbool("merge-tools", tool + "." + part, default)
+def _toolbool(ui, tool, part,*args):
+    return ui.configbool("merge-tools", tool + "." + part, *args)
 
-def _toollist(ui, tool, part, default=None):
-    if default is None:
-        default = []
-    return ui.configlist("merge-tools", tool + "." + part, default)
+def _toollist(ui, tool, part):
+    return ui.configlist("merge-tools", tool + "." + part)
 
 internals = {}
 # Merge tools to document.
@@ -186,8 +184,8 @@
     for k, v in ui.configitems("merge-tools"):
         t = k.split('.')[0]
         if t not in tools:
-            tools[t] = int(_toolstr(ui, t, "priority", "0"))
-        if _toolbool(ui, t, "disabled", False):
+            tools[t] = int(_toolstr(ui, t, "priority"))
+        if _toolbool(ui, t, "disabled"):
             disabled.add(t)
     names = tools.keys()
     tools = sorted([(-p, tool) for tool, p in tools.items()
@@ -327,7 +325,7 @@
     try:
         premerge = _toolbool(ui, tool, "premerge", not binary)
     except error.ConfigError:
-        premerge = _toolstr(ui, tool, "premerge").lower()
+        premerge = _toolstr(ui, tool, "premerge", "").lower()
         if premerge not in validkeep:
             _valid = ', '.join(["'" + v + "'" for v in validkeep])
             raise error.ConfigError(_("%s.premerge not valid "
@@ -508,7 +506,7 @@
                }
         ui = repo.ui
 
-        args = _toolstr(ui, tool, "args", '$local $base $other')
+        args = _toolstr(ui, tool, "args")
         if "$output" in args:
             # read input from backup, write to original
             out = a