Index: mailer.py =================================================================== --- mailer.py (revision 35240) +++ 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 + jdiff = cfg.get('max_diff_size', group, params) + try: + max_diff_size = int(jdiff) + diff_size = max_diff_size + except ValueError: + max_diff_size = -1 + diff_size = -1 for diff in diffs: if not diff.diff and not diff.diff_url: @@ -1116,7 +1123,15 @@ w('Binary file (source and/or target). No diff available.\n') continue + max_diff_size = diff_size for line in diff.content: + max_diff_size = max_diff_size - len(line.raw) + if max_diff_size <= 0 and -1 != diff_size: + w('\n============= MAX DIFF SIZE=%s ' % diff_size) + w('IS REACHED NO MORE OF THIS DIFF INCLUDED =============\n\n') + # We ought to stop the generation of more diffs, but it + # might already be too late + break w(line.raw) Index: mailer.conf.example =================================================================== --- mailer.conf.example (revision 35240) +++ mailer.conf.example (working copy) @@ -243,6 +243,12 @@ # Set to 0 to turn off. #truncate_subject = 200 +# The maximum size in bytes that a diff can be. 0 means 0 bytes. -1 +# means no limit. If there is no such variable, the limit is -1 +# The counted bytes are ONLY the actual diffs, not which files are +# changed, modified, added, deleted, ... +# max_diff_size = 8192 + # -------------------------------------------------------------------------- [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_diff_size = 16384 #