X-Git-Url: https://git.distorted.org.uk/~mdw/stgit/blobdiff_plain/61eed15276863e203a70870caa84daab60765c40..1d1485c3cb6799f561df780e8f142b0c54b8178b:/stgit/commands/mail.py diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py index 154df9c..307a129 100644 --- a/stgit/commands/mail.py +++ b/stgit/commands/mail.py @@ -52,33 +52,29 @@ SMTP authentication is also possible with '--smtp-user' and '--smtp-password' options, also available as configuration settings: 'smtpuser' and 'smtppassword'. -The template e-mail headers and body must be separated by -'%(endofheaders)s' variable, which is replaced by StGIT with -additional headers and a blank line. The patch e-mail template accepts -the following variables: +The patch e-mail template accepts the following variables: %(patch)s - patch name %(maintainer)s - 'authname ' as read from the config file %(shortdescr)s - the first line of the patch description %(longdescr)s - the rest of the patch description, after the first line - %(endofheaders)s - delimiter between e-mail headers and body %(diff)s - unified diff of the patch %(diffstat)s - diff statistics - %(date)s - current date/time %(version)s - ' version' string passed on the command line (or empty) %(prefix)s - 'prefix ' string passed on the command line %(patchnr)s - patch number %(totalnr)s - total number of patches to be sent %(number)s - empty if only one patch is sent or ' patchnr/totalnr' + %(fromauth)s - 'From: author\\n\\n' if different from maintainer %(authname)s - author's name %(authemail)s - author's email %(authdate)s - patch creation date %(commname)s - committer's name %(commemail)s - committer's e-mail -For the preamble e-mail template, only the %(maintainer)s, %(date)s, -%(endofheaders)s, %(version)s, %(patchnr)s, %(totalnr)s and %(number)s -variables are supported.""" +For the preamble e-mail template, only the %(maintainer)s, +%(version)s, %(patchnr)s, %(totalnr)s and %(number)s variables are +supported.""" options = [make_option('-a', '--all', help = 'e-mail all the applied patches', @@ -270,7 +266,7 @@ def __encode_message(msg): # encode the body and set the MIME and encoding headers msg.set_charset(charset) -def edit_message(msg): +def __edit_message(msg): fname = '.stgitmail.txt' # create the initial file @@ -342,6 +338,9 @@ def __build_cover(tmpl, total_nr, msg_id, options): raise CmdException, 'Only "%(name)s" variables are ' \ 'supported in the patch template' + if options.edit_cover: + msg_string = __edit_message(msg_string) + # The Python email message try: msg = email.message_from_string(msg_string) @@ -354,9 +353,6 @@ def __build_cover(tmpl, total_nr, msg_id, options): msg_string = msg.as_string(options.mbox) - if options.edit_cover: - msg_string = edit_message(msg_string) - return msg_string.strip('\n') def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options): @@ -370,9 +366,20 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options): short_descr = descr_lines[0].rstrip() long_descr = '\n'.join(descr_lines[1:]).lstrip() + authname = p.get_authname(); + authemail = p.get_authemail(); + commname = p.get_commname(); + commemail = p.get_commemail(); + maintainer = __get_maintainer() if not maintainer: - maintainer = '%s <%s>' % (p.get_commname(), p.get_commemail()) + maintainer = '%s <%s>' % (commname, commemail) + + fromauth = '%s <%s>' % (authname, authemail) + if fromauth != maintainer: + fromauth = 'From: %s\n\n' % fromauth + else: + fromauth = '' if options.version: version_str = ' %s' % options.version @@ -408,11 +415,12 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options): 'patchnr': patch_nr_str, 'totalnr': total_nr_str, 'number': number_str, - 'authname': p.get_authname(), - 'authemail': p.get_authemail(), + 'fromauth': fromauth, + 'authname': authname, + 'authemail': authemail, 'authdate': p.get_authdate(), - 'commname': p.get_commname(), - 'commemail': p.get_commemail()} + 'commname': commname, + 'commemail': commemail} # change None to '' for key in tmpl_dict: if not tmpl_dict[key]: @@ -427,6 +435,9 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options): raise CmdException, 'Only "%(name)s" variables are ' \ 'supported in the patch template' + if options.edit_patches: + msg_string = __edit_message(msg_string) + # The Python email message try: msg = email.message_from_string(msg_string) @@ -444,9 +455,6 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options): msg_string = msg.as_string(options.mbox) - if options.edit_patches: - msg_string = edit_message(msg_string) - return msg_string.strip('\n') def func(parser, options, args):