Patchwork [1,of,6,RFC] ui.config: fix bug in config alternatives from cc669e4fec95

login
register
mail settings
Submitter Augie Fackler
Date Aug. 2, 2013, 2:15 p.m.
Message ID <123bd5dda28b5452afd8.1375452900@arthedain.pit.corp.google.com>
Download mbox | patch
Permalink /patch/1982/
State Accepted
Commit ab3cf67740d660de5ba3e4c9d9b30a31b0e21548
Headers show

Comments

Augie Fackler - Aug. 2, 2013, 2:15 p.m.
# HG changeset patch
# User Augie Fackler <durin42@gmail.com>
# Date 1374707619 14400
#      Wed Jul 24 19:13:39 2013 -0400
# Node ID 123bd5dda28b5452afd8881488d14056f53ae421
# Parent  a58251c0568fc5e86089a803ca75f75cc8c01678
ui.config: fix bug in config alternatives from cc669e4fec95
Matt Mackall - Aug. 7, 2013, 10:13 p.m.
On Fri, 2013-08-02 at 10:15 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <durin42@gmail.com>
> # Date 1374707619 14400
> #      Wed Jul 24 19:13:39 2013 -0400
> # Node ID 123bd5dda28b5452afd8881488d14056f53ae421
> # Parent  a58251c0568fc5e86089a803ca75f75cc8c01678
> ui.config: fix bug in config alternatives from cc669e4fec95

Queued the first one.

I think we need another think about the namespace issue we discussed on
IRC:

[foo]
barbaz = False
bar_baz = True # this one should take precedence if we accept both forms

How do we handle this intelligently?

Thought: we give config a set of characters to fold on (ie [-_]) and it
builds a parallel tree of folded identifiers. Iff we do a lookup with
alternatives, we consult that tree, otherwise we consult the normal
tree.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -176,7 +176,7 @@ 
             alternates = [name]
 
         for n in alternates:
-            value = self._data(untrusted).get(section, name, None)
+            value = self._data(untrusted).get(section, n, None)
             if value is not None:
                 name = n
                 break
@@ -184,10 +184,11 @@ 
             value = default
 
         if self.debugflag and not untrusted and self._reportuntrusted:
-            uvalue = self._ucfg.get(section, name)
-            if uvalue is not None and uvalue != value:
-                self.debug("ignoring untrusted configuration option "
-                           "%s.%s = %s\n" % (section, name, uvalue))
+            for n in alternates:
+                uvalue = self._ucfg.get(section, n)
+                if uvalue is not None and uvalue != value:
+                    self.debug("ignoring untrusted configuration option "
+                               "%s.%s = %s\n" % (section, n, uvalue))
         return value
 
     def configpath(self, section, name, default=None, untrusted=False):