--- a/contrib/patchbomb Tue Aug 09 20:53:50 2005 -0800
+++ b/contrib/patchbomb Fri Aug 12 08:04:31 2005 -0800
@@ -12,8 +12,8 @@
#
# The remainder of the changeset description.
#
-# If the diffstat program is installed, the result of running
-# diffstat on the patch.
+# [Optional] If the diffstat program is installed, the result of
+# running diffstat on the patch.
#
# The patch itself, as generated by "hg export".
#
@@ -26,8 +26,8 @@
# changes.
#
# It is best to run this script with the "-n" (test only) flag before
-# firing it up "for real", in which case it will display each of the
-# messages that it would send.
+# firing it up "for real", in which case it will use your pager to
+# display each of the messages that it would send.
#
# To configure a default mail host, add a section like this to your
# hgrc file:
@@ -35,6 +35,14 @@
# [smtp]
# host = my_mail_host
# port = 1025
+#
+# To configure other defaults, add a section like this to your hgrc
+# file:
+#
+# [patchbomb]
+# from = My Name <my@email>
+# to = recipient1, recipient2, ...
+# cc = cc1, cc2, ...
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
@@ -81,7 +89,7 @@
if r: return r
if default is not None: return default
if empty_ok: return r
- print >> sys.stderr, 'Please enter a valid value.'
+ ui.warn('Please enter a valid value.\n')
def confirm(s):
if not prompt(s, default = 'y', rest = '? ').lower().startswith('y'):
@@ -108,7 +116,9 @@
if not node: raise ValueError
body = ('\n'.join(desc[1:]).strip() or
'Patch subject is complete summary.')
- body += '\n\n\n' + cdiffstat('\n'.join(desc), patch) + '\n\n'
+ body += '\n\n\n'
+ if opts['diffstat']:
+ body += cdiffstat('\n'.join(desc), patch) + '\n\n'
body += '\n'.join(patch)
msg = MIMEText(body)
subj = '[PATCH %d of %d] %s' % (idx, total, desc[0].strip())
@@ -150,14 +160,18 @@
ui.write('\nWrite the introductory message for the patch series.\n\n')
- sender = opts['sender'] or prompt('From', ui.username())
+ sender = (opts['from'] or ui.config('patchbomb', 'from') or
+ prompt('From', ui.username()))
msg = MIMEMultipart()
msg['Subject'] = '[PATCH 0 of %d] %s' % (
len(patches),
+ opts['subject'] or
prompt('Subject:', rest = ' [PATCH 0 of %d] ' % len(patches)))
- to = opts['to'] or [s.strip() for s in prompt('To').split(',')]
- cc = opts['cc'] or [s.strip() for s in prompt('Cc', default = '').split(',')]
+ to = (opts['to'] or ui.config('patchbomb', 'to') or
+ [s.strip() for s in prompt('To').split(',')])
+ cc = (opts['cc'] or ui.config('patchbomb', 'cc') or
+ [s.strip() for s in prompt('Cc', default = '').split(',')])
ui.write('Finish with ^D or a dot on a line by itself.\n\n')
@@ -194,7 +208,7 @@
m['In-Reply-To'] = parent
else:
parent = m['Message-Id']
- m['Date'] = time.strftime('%a, %m %b %Y %T ', time.localtime(start_time)) + tz
+ m['Date'] = time.strftime('%a, %e %b %Y %T ', time.localtime(start_time)) + tz
start_time += 1
m['From'] = sender
m['To'] = ', '.join(to)
@@ -212,8 +226,10 @@
if __name__ == '__main__':
optspec = [('c', 'cc', [], 'email addresses of copy recipients'),
+ ('d', 'diffstat', None, 'add diffstat output to messages'),
+ ('f', 'from', '', 'email address of sender'),
('n', 'test', None, 'print messages that would be sent'),
- ('s', 'sender', '', 'email address of sender'),
+ ('s', 'subject', '', 'subject of introductory message'),
('t', 'to', [], 'email addresses of recipients')]
options = {}
try: