Index: mailer.py =================================================================== --- mailer.py (revision 35245) +++ mailer.py (working copy) @@ -722,7 +722,7 @@ params, diffsels, diffurls, pool), other_diffs=other_diffs, ) - renderer.render(data) + renderer.render(data,cfg,group,params) def generate_list(changekind, changelist, paths, in_paths): @@ -1005,7 +1005,7 @@ def __init__(self, output): self.output = output - def render(self, data): + def render(self, data,cfg,group,params): "Render the commit defined by 'data'." w = self.output.write @@ -1038,11 +1038,11 @@ else: w('and changes in other areas\n') - self._render_diffs(data.diffs, '') + self._render_diffs(data.diffs, '',cfg,group,params) if data.other_diffs: self._render_diffs(data.other_diffs, '\nDiffs of changes in other areas also' - ' in this revision:\n') + ' in this revision:\n',cfg,group,params) def _render_list(self, header, data_list): if not data_list: @@ -1073,13 +1073,20 @@ w(' - copied%s from r%d, %s%s\n' % (text, d.base_rev, d.base_path, is_dir)) - def _render_diffs(self, diffs, section_header): + def _render_diffs(self, diffs, section_header,cfg,group,params): """Render diffs. Write the SECTION_HEADER if there are actually any diffs to render.""" if not diffs: return w = self.output.write section_header_printed = False + jmail = cfg.get('max_mail_size',group,params) + try: + max_mail_size = int(jmail) + mail_size = max_mail_size + except ValueError: + max_mail_size = -1 + mail_size = -1 for diff in diffs: if not diff.diff and not diff.diff_url: @@ -1117,9 +1124,20 @@ continue for line in diff.content: + max_mail_size = max_mail_size - len(line.raw) + if max_mail_size <= 0 and -1 != mail_size: + w('\n============= MAX MAILSIZE=%s ' % mail_size) + w('IS REACHED NO MORE FILE DIFF INCLUDED =============\n\n') + # We ought to stop the generation of more diffs, but it + # might already be too late + break w(line.raw) + if max_mail_size <= 0 and -1 != mail_size: + # we dont need the rest of this email + break + class Repository: "Hold roots and other information about the repository." Index: mailer.conf.example =================================================================== --- mailer.conf.example (revision 35245) +++ mailer.conf.example (working copy) @@ -243,6 +243,12 @@ # Set to 0 to turn off. #truncate_subject = 200 +# The maximum size in bytes that an email can be. 0 means zero +# -1 means unlimited, and if the variable is not mentioned it means -1 +# The count is ONLY the actual diffs, so there will used bytes to inform +# which files was added, changed, deleted, modified, ... +# max_mail_size = 65536 + # -------------------------------------------------------------------------- [maps] @@ -328,4 +334,5 @@ # # commits to personal repositories should go to that person # for_repos = /home/(?P[^/]*)/repos # to_addr = %(who)s@example.com +# max_mail_size = 32768 #