~mdw
/
stgit
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Only create a 'From: author' line if needed
[stgit]
/
stgit
/
commands
/
mail.py
diff --git
a/stgit/commands/mail.py
b/stgit/commands/mail.py
index
7875fac
..
307a129
100644
(file)
--- a/
stgit/commands/mail.py
+++ b/
stgit/commands/mail.py
@@
-65,6
+65,7
@@
The patch e-mail template accepts the following variables:
%(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'
%(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
%(authname)s - author's name
%(authemail)s - author's email
%(authdate)s - patch creation date
@@
-265,7
+266,7
@@
def __encode_message(msg):
# encode the body and set the MIME and encoding headers
msg.set_charset(charset)
# 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
fname = '.stgitmail.txt'
# create the initial file
@@
-337,6
+338,9
@@
def __build_cover(tmpl, total_nr, msg_id, options):
raise CmdException, 'Only "%(name)s" variables are ' \
'supported in the patch template'
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)
# The Python email message
try:
msg = email.message_from_string(msg_string)
@@
-349,9
+353,6
@@
def __build_cover(tmpl, total_nr, msg_id, options):
msg_string = msg.as_string(options.mbox)
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):
return msg_string.strip('\n')
def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
@@
-365,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()
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 = __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
if options.version:
version_str = ' %s' % options.version
@@
-403,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,
'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(),
'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]:
# change None to ''
for key in tmpl_dict:
if not tmpl_dict[key]:
@@
-422,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'
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)
# The Python email message
try:
msg = email.message_from_string(msg_string)
@@
-439,9
+455,6
@@
def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
msg_string = msg.as_string(options.mbox)
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):
return msg_string.strip('\n')
def func(parser, options, args):