configitems: do not directly match generic items
authorBoris Feld <boris.feld@octobus.net>
Wed, 18 Oct 2017 12:26:08 +0200
changeset 34874 e3fbf8e3fef2
parent 34873 aa849cf5d089
child 34875 4f0d4bc63b8a
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.
mercurial/configitems.py
--- a/mercurial/configitems.py	Wed Oct 18 15:38:51 2017 +0200
+++ b/mercurial/configitems.py	Wed Oct 18 12:26:08 2017 +0200
@@ -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 = {}