Refine workflow for constructing path-groups.
* tools/hook-scripts/mailer/mailer.py:
(Config.__init__): _prep_maps() now returns sections that are being
used to map values. These should be removed from the groups that
define path-based configuration. Shift that removal here. Also,
pass the set of path-groups to _prep_groups() rather than dropping
that off in an instance variable.
(Config._prep_maps): docco. Change to return a set of the sections
used for mapping values.
(Config._prep_groups): take the groups to review, rather than pick
them up out-of-band via an instance variable.
git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@1917643 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tools/hook-scripts/mailer/mailer.py b/tools/hook-scripts/mailer/mailer.py
index 24cb7b5..9149acb 100755
--- a/tools/hook-scripts/mailer/mailer.py
+++ b/tools/hook-scripts/mailer/mailer.py
@@ -1278,10 +1278,12 @@
self.maps = _sub_section()
# prepare maps. this may remove sections from consideration as a group.
- self._prep_maps()
+ mapsections = self._prep_maps()
+ for sectname in mapsections:
+ self._groups.remove(sectname)
# process all the group sections.
- self._prep_groups(repos_dir, default_params)
+ self._prep_groups(self._groups, repos_dir, default_params)
def is_set(self, option):
"""Return None if the option is not set; otherwise, its value is returned.
@@ -1333,9 +1335,13 @@
return cmd
def _prep_maps(self):
- "Rewrite the [maps] options into callables that look up values."
+ """Rewrite the [maps] options into callables that look up values.
- mapsections = []
+ Returns a set of section names that are used for mappings, which
+ should not be considered as path-match groups.
+ """
+
+ mapsections = set()
for optname, mapvalue in vars(self.maps).items():
if mapvalue[:1] == '[':
@@ -1352,8 +1358,7 @@
value.lower(),
value))
# mark for removal when all optnames are done
- if sectname not in mapsections:
- mapsections.append(sectname)
+ mapsections.add(sectname)
# elif test for other mapper types. possible examples:
# dbm:filename.db
@@ -1365,10 +1370,9 @@
raise UnknownMappingSpec(mapvalue)
# remove each mapping section from consideration as a group
- for sectname in mapsections:
- self._groups.remove(sectname)
+ return mapsections
- def _prep_groups(self, repos_dir, default_params):
+ def _prep_groups(self, groups, repos_dir, default_params):
self._group_re = [ ]
### does it arrive as an abspath?
@@ -1399,7 +1403,7 @@
or default_params)
# select the groups that apply to this repository
- for group in self._groups:
+ for group in groups:
params = repos_params(group, self._default_params)
if params is None:
# There was a FOR_REPOS, but this repos does not match.