Index: mailer.py =================================================================== --- mailer.py (revision 35231) +++ mailer.py (working copy) @@ -796,11 +796,27 @@ 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: + ending_match = re.search('\.' + ending + '$', change.path) + if ending_match != None: + label1='\nFORCED BINARY: ' + change.path + ' - %s file\n' % ending + singular=True + break + # is this change in (or out of) the set of matched paths? if (path in self.paths) != self.in_paths: continue @@ -825,12 +841,13 @@ # show the diff? if self.diffsels.delete: - diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), + 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)' - singular = True + 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: @@ -846,27 +863,29 @@ # show the diff? if self.diffsels.modify: - diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), + 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 + singular = False else: # this file was copied. kind = 'C' if self.diffsels.copy: - diff = svn.fs.FileDiff(None, None, self.repos.root_this, + 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 + singular = False else: # the file was added. kind = 'A' @@ -876,13 +895,14 @@ # show the diff? if self.diffsels.add: - diff = svn.fs.FileDiff(None, None, self.repos.root_this, + 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 + singular = True elif not change.text_changed: # the text didn't change, so nothing to show. @@ -896,28 +916,32 @@ # show the diff? if self.diffsels.modify: - diff = svn.fs.FileDiff(self.repos.get_root(change.base_rev), + 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 + 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, + })) + else: + kind='F' # return a data item for this diff return _data( @@ -1082,7 +1106,7 @@ 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 'F' != diff.kind : continue if not section_header_printed: w(section_header) @@ -1091,6 +1115,9 @@ w('\nDeleted: %s\n' % diff.base_path) elif diff.kind == 'A': w('\nAdded: %s\n' % diff.path) + elif diff.kind == 'F': + # file is considered binary because of the file ending + w(diff.label_from) elif diff.kind == 'C': w('\nCopied: %s (from r%d, %s)\n' % (diff.path, diff.base_rev, diff.base_path)) Index: mailer.conf.example =================================================================== --- mailer.conf.example (revision 35231) +++ mailer.conf.example (working copy) @@ -243,6 +243,11 @@ # Set to 0 to turn off. #truncate_subject = 200 +# Forces some file endings to be considered binary and thus no diff will be +# generated for these files. Example: file.ai will be considered binary +# if the forced_binary_file_endings contains ai +# forced_binary_file_endings = map po ai + # -------------------------------------------------------------------------- [maps]