Skip to content

Support the suppress_if_match option from old svn-mailer #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions tools/hook-scripts/mailer/mailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,6 +1384,7 @@ def _prep_maps(self):

def _prep_groups(self, groups, repos_dir, default_params):
self._group_re = [ ]
self._last_group_re = [ ]

### does it arrive as an abspath?
repos_dir = os.path.abspath(repos_dir)
Expand Down Expand Up @@ -1442,32 +1443,48 @@ def repos_params(section_name, defaults):
search_logmsg_re = re.compile(search_logmsg)
else:
search_logmsg_re = None

self._group_re.append((group,
re.compile(for_paths),
exclude_paths_re,
params,
search_logmsg_re))
suppress_if_match = getattr(sub, 'suppress_if_match', None)
if suppress_if_match == 'yes':
self._last_group_re.append((group,
re.compile(for_paths),
exclude_paths_re,
params,
search_logmsg_re,
True)) # Ignore if already matched
else:
self._group_re.append((group,
re.compile(for_paths),
exclude_paths_re,
params,
search_logmsg_re,
False))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, this is not nice. Remove the if.

self._last_group_re.append((group,
                            re.compile(for_paths),
                            exclude_paths_re,
                            params,
                            search_logmsg_re,
                            # Ignore if already matched
                            suppress_if_match == 'yes'))

Also, what guarantee is there that the true-value of suppress_if_match can only be yes? All I see is a new config option used in the code. Needs updated documentation in mailer.conf.example.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Belay that suggested code change, I'm blind. The docco request stands, though.


# after all the groups are done, add in the default group
try:
self._group_re.append((None,
self._last_group_re.append((None,
re.compile(self.defaults.for_paths),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix function argument indentation, please.

None,
self._default_params,
None))
None,
False))
except AttributeError:
# there is no self.defaults.for_paths
pass

self._group_re = self._group_re + self._last_group_re

def which_groups(self, path, logmsg):
"Return the path's associated groups."
groups = []
for group, pattern, exclude_pattern, repos_params, search_logmsg_re in self._group_re:
seen = False
for group, pattern, exclude_pattern, repos_params, search_logmsg_re, ignore in self._group_re:
if ignore and seen:
continue
match = pattern.match(path)
if match:
if exclude_pattern and exclude_pattern.match(path):
continue
seen = True
params = repos_params.copy()
params.update(match.groupdict())

Expand Down
Loading