Patchwork [1,of,2] configitems: do not directly match generic items

login
register
mail settings
Submitter Boris Feld
Date Oct. 18, 2017, 2:04 p.m.
Message ID <a3110a4c8aa98ebd9fc2.1508335471@FB>
Download mbox | patch
Permalink /patch/25166/
State Accepted
Headers show

Comments

Boris Feld - Oct. 18, 2017, 2:04 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1508322368 -7200
#      Wed Oct 18 12:26:08 2017 +0200
# Node ID a3110a4c8aa98ebd9fc26702eb81b9366edf7335
# Parent  537de0b14030868e3e850ae388b08f88cabc88e8
# EXP-Topic config.register.fixup
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a3110a4c8aa9
configitems: do not directly match generic items

Before this changesets, a literal '.*:foo$' config would match a registered
'.*:foo$' generic. This is wrong since generic should be matched through
regular exception only. This changeset fixes this problem.

Thanks for to Yuya Nishihara for spotting the issue.

Patch

diff --git a/mercurial/configitems.py b/mercurial/configitems.py
--- a/mercurial/configitems.py
+++ b/mercurial/configitems.py
@@ -67,8 +67,9 @@ 
             self._generics.add(item)
 
     def get(self, key):
-        if key in self:
-            return self[key]
+        baseitem = super(itemregister, self).get(key)
+        if baseitem is not None and not baseitem.generic:
+            return baseitem
 
         # search for a matching generic item
         generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
@@ -76,8 +77,7 @@ 
             if item._re.match(key):
                 return item
 
-        # fallback to dict get
-        return super(itemregister, self).get(key)
+        return None
 
 coreitems = {}