##// END OF EJS Templates
configitems: document the choice of using 'match' instead of 'search'
Boris Feld -
r34876:4f0d4bc6 default
parent child Browse files
Show More
@@ -74,6 +74,17 b' class itemregister(dict):'
74 # search for a matching generic item
74 # search for a matching generic item
75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
75 generics = sorted(self._generics, key=(lambda x: (x.priority, x.name)))
76 for item in generics:
76 for item in generics:
77 # we use 'match' instead of 'search' to make the matching simpler
78 # for people unfamiliar with regular expression. Having the match
79 # rooted to the start of the string will produce less surprising
80 # result for user writing simple regex for sub-attribute.
81 #
82 # For example using "color\..*" match produces an unsurprising
83 # result, while using search could suddenly match apparently
84 # unrelated configuration that happens to contains "color."
85 # anywhere. This is a tradeoff where we favor requiring ".*" on
86 # some match to avoid the need to prefix most pattern with "^".
87 # The "^" seems more error prone.
77 if item._re.match(key):
88 if item._re.match(key):
78 return item
89 return item
79
90
General Comments 0
You need to be logged in to leave comments. Login now