Index: mailer.py =================================================================== --- mailer.py (revision 35283) +++ mailer.py (working copy) @@ -223,7 +224,7 @@ def __init__(self, cfg, repos, prefix_param): OutputBase.__init__(self, cfg, repos, prefix_param) - def start(self, group, params): + def start(self, group, params, header_list): # whitespace (or another character) separated list of addresses # which must be split into a clean list to_addr_in = self.cfg.get('to_addr', group, params) @@ -250,7 +251,13 @@ and self.reply_to[2] == ']': self.reply_to = self.reply_to[3:] - def mail_headers(self, group, params): + def mail_headers(self, group, params, header_list): + header_detail = header_list[0] + modules = header_list[1] + branches = header_list[2] + submodules = header_list[3] + files = header_list[4] + subject = self.make_subject(group, params) try: subject.encode('ascii') @@ -262,23 +269,38 @@ 'Subject: %s\n' \ 'MIME-Version: 1.0\n' \ 'Content-Type: text/plain; charset=UTF-8\n' \ - 'Content-Transfer-Encoding: 8bit\n' \ + 'Content-Transfer-Encoding: 8bit' \ % (self.from_addr, ', '.join(self.to_addrs), subject) if self.reply_to: - hdrs = '%sReply-To: %s\n' % (hdrs, self.reply_to) + hdrs = '%s\nReply-To: %s' % (hdrs, self.reply_to) + for header in header_detail: + if 'group' == header: + hdrs = '%s\nX-group: %s' % (hdrs, group) + if 'module' == header: + for m in modules: + hdrs = '%s\nX-module: %s' % (hdrs, m) + if 'branch' == header: + for b in branches: + hdrs = '%s\nX-branch: %s' % (hdrs, b) + if 'submodule' == header: + for s in submodules: + hdrs = '%s\nX-submod: %s' % (hdrs, s) + if 'file' == header: + for f in files: + hdrs = '%s\nX-file: %s' % (hdrs, f) return hdrs + '\n' class SMTPOutput(MailedOutput): "Deliver a mail message to an MTA using SMTP." - def start(self, group, params): + def start(self, group, params, header_list): MailedOutput.start(self, group, params) self.buffer = StringIO() self.write = self.buffer.write - self.write(self.mail_headers(group, params)) + self.write(self.mail_headers(group, params, header_list)) def finish(self): server = smtplib.SMTP(self.cfg.general.smtp_hostname) @@ -313,8 +335,8 @@ # figure out the command for delivery self.cmd = cfg.general.mail_command.split() - def start(self, group, params): - MailedOutput.start(self, group, params) + def start(self, group, params, header_list): + MailedOutput.start(self, group, params, header_list) ### gotta fix this. this is pretty specific to sendmail and qmail's ### mailwrapper program. should be able to use option param substitution @@ -333,7 +355,7 @@ self.pipe.fromchild.close() # start writing out the mail message - self.write(self.mail_headers(group, params)) + self.write(self.mail_headers(group, params, header_list)) def finish(self): # signal that we're done sending content @@ -429,7 +451,44 @@ renderer = TextCommitRenderer(self.output) for (group, param_tuple), (params, paths) in self.groups.items(): - self.output.start(group, params) + header_list = [] + module = [] + branch = [] + submodule = [] + file = [] + h_detail = self.cfg.get('header_detail', group, params) + if len(h_detail) >= 3 and h_detail[0] == '[' \ + and h_detail[2] == ']': + header_detail = \ + [_f for _f in h_detail[3:].split(h_detail[1]) if _f] + else: + header_detail = [_f for _f in h_detail.split() if _f] + # we should only generate the header details we truely want, but + # since we split the entire path, we might as well make all sets + for p in paths: + plist = p.split('/') + try: + module = module[:] + [plist[0]] + except IndexError: + dummy = 0 + try: + branch = branch[:] + [plist[1]] + except IndexError: + dummy = 0 + try: + submodule = submodule[:] + [plist[2]] + except IndexError: + dummy = 0 + try: + file = file[:] + [plist[-1]] + except IndexError: + dummy = 0 + module = set(module) + branch = set(branch) + submodule = set(submodule) + file = set(file) + header_list = [header_detail, module, branch, submodule, file] + self.output.start(group, params, header_list) # generate the content for this group and set of params generate_content(renderer, self.cfg, self.repos, self.changelist, Index: mailer.conf.example =================================================================== --- mailer.conf.example (revision 35283) +++ mailer.conf.example (working copy) @@ -243,6 +243,18 @@ # Set to 0 to turn off. #truncate_subject = 200 +# specify which information you want included in extra headers +# for some reason author is always in the header as Author: +# group generates a X-group: header +# asuming paths in SVN looks like: ///.../ +# module generates a X-module: header for every module +# branch generates a X-branch: header for every branch +# submodule generates a X-submod: header for every submodule +# file generates a X-file: header for every file +# having an empty or specifying no header_detail variable means no extra +# headers. Specifying all is not an option +# header_detail = group module branch submodule file + # -------------------------------------------------------------------------- [maps] @@ -328,4 +340,5 @@ # # commits to personal repositories should go to that person # for_repos = /home/(?P[^/]*)/repos # to_addr = %(who)s@example.com +# header_detail = branch module submodule #