Index: mailer.py =================================================================== --- mailer.py (revision 35413) +++ mailer.py (working copy) @@ -796,11 +796,26 @@ binary = None singular = None content = None + ending_match = None # just skip directories. they have no diffs. if change.item_kind == svn.core.svn_node_dir: continue + file_endings = self.cfg.get('forced_binary_file_endings',\ + self.group, self.params) + if len(file_endings) >= 3 and file_endings[0] == '[' \ + and file_endings[2] == ']': + forced_binary = \ + [_f for _f in file_endings[3:].split(file_endings[1]) if _f] + else: + forced_binary = [_f for _f in file_endings.split() if _f] + for ending in forced_binary: + if None != change.path and change.path.endswith('.' + ending): + ending_match = ending + binary=2 + break + # is this change in (or out of) the set of matched paths? if (path in self.paths) != self.in_paths: continue @@ -825,13 +840,13 @@ # show the diff? if self.diffsels.delete: - diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), + singular = True + if None == ending_match: + diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), base_path, None, None, self.pool) + label1 = '%s\t%s\t(r%s)' % (base_path, self.date, change.base_rev) + label2 = '/dev/null\t00:00:00 1970\t(deleted)' - label1 = '%s\t%s\t(r%s)' % (base_path, self.date, change.base_rev) - label2 = '/dev/null\t00:00:00 1970\t(deleted)' - singular = True - elif change.action == svn.repos.CHANGE_ACTION_ADD \ or change.action == svn.repos.CHANGE_ACTION_REPLACE: if base_path and (change.base_rev != -1): @@ -846,27 +861,29 @@ # show the diff? if self.diffsels.modify: - diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), + singular = False + if None == ending_match: + diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), base_path, self.repos.root_this, change.path, self.pool) - label1 = '%s\t%s\t(r%s, copy source)' \ + label1 = '%s\t%s\t(r%s, copy source)' \ % (base_path, base_date, change.base_rev) - label2 = '%s\t%s\t(r%s)' \ + label2 = '%s\t%s\t(r%s)' \ % (change.path, self.date, self.repos.rev) - singular = False else: # this file was copied. kind = 'C' if self.diffsels.copy: - diff = svn.fs.FileDiff(None, None, self.repos.root_this, + singular = False + if None == ending_match: + diff = svn.fs.FileDiff(None, None, self.repos.root_this, change.path, self.pool) - label1 = '/dev/null\t00:00:00 1970\t' \ + label1 = '/dev/null\t00:00:00 1970\t' \ '(empty, because file is newly added)' - label2 = '%s\t%s\t(r%s, copy of r%s, %s)' \ + label2 = '%s\t%s\t(r%s, copy of r%s, %s)' \ % (change.path, self.date, self.repos.rev, \ change.base_rev, base_path) - singular = False else: # the file was added. kind = 'A' @@ -876,13 +893,14 @@ # show the diff? if self.diffsels.add: - diff = svn.fs.FileDiff(None, None, self.repos.root_this, + singular = True + if None == ending_match: + diff = svn.fs.FileDiff(None, None, self.repos.root_this, change.path, self.pool) - label1 = '/dev/null\t00:00:00 1970\t' \ + label1 = '/dev/null\t00:00:00 1970\t' \ '(empty, because file is newly added)' - label2 = '%s\t%s\t(r%s)' \ + label2 = '%s\t%s\t(r%s)' \ % (change.path, self.date, self.repos.rev) - singular = True elif not change.text_changed: # the text didn't change, so nothing to show. @@ -896,28 +914,30 @@ # show the diff? if self.diffsels.modify: - diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), + singular = False + if None == ending_match: + diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), base_path, self.repos.root_this, change.path, self.pool) - label1 = '%s\t%s\t(r%s)' \ + label1 = '%s\t%s\t(r%s)' \ % (base_path, base_date, change.base_rev) - label2 = '%s\t%s\t(r%s)' \ + label2 = '%s\t%s\t(r%s)' \ % (change.path, self.date, self.repos.rev) - singular = False - if diff: - binary = diff.either_binary() - if binary: - content = src_fname = dst_fname = None - else: - src_fname, dst_fname = diff.get_files() - content = DiffContent(self.cfg.get_diff_cmd(self.group, { - 'label_from' : label1, - 'label_to' : label2, - 'from' : src_fname, - 'to' : dst_fname, - })) + if None == ending_match: + if diff: + binary = diff.either_binary() + if binary: + content = src_fname = dst_fname = None + else: + src_fname, dst_fname = diff.get_files() + content = DiffContent(self.cfg.get_diff_cmd(self.group, { + 'label_from' : label1, + 'label_to' : label2, + 'from' : src_fname, + 'to' : dst_fname, + })) # return a data item for this diff return _data( @@ -1082,8 +1102,10 @@ section_header_printed = False for diff in diffs: - if not diff.diff and not diff.diff_url: + if not diff.diff and not diff.diff_url and 2 != diff.binary: continue + # if the binary is 2, then it means that the file is + # forced to be considered as a binary file if not section_header_printed: w(section_header) section_header_printed = True @@ -1104,17 +1126,29 @@ if diff.diff_url: w('URL: %s\n' % diff.diff_url) - if not diff.diff: + if not diff.diff and 2 != diff.binary: continue w(SEPARATOR + '\n') if diff.binary: - if diff.singular: - w('Binary file. No diff available.\n') - else: - w('Binary file (source and/or target). No diff available.\n') - continue + if 2 == diff.binary: + # special binary. used when a file is FORCED to be + # considered as a binary because of the file ending + if diff.singular: + w('Forced binary file because of the file ending.' + \ + ' No diff available.\n') + else: + w('Forced binary file because of the file ending ' + \ + '(source and/or target). No diff available.\n') + continue + else: + # must be regular binary + if diff.singular: + w('Binary file. No diff available.\n') + else: + w('Binary file (source and/or target). No diff available.\n') + continue for line in diff.content: w(line.raw)