# HG changeset patch # User Lee Cantey # Date 1141707918 28800 # Node ID cfe689ab3f063758da0cfcf641a6c35590996002 # Parent b768f3ae0c2c01868aa2b5054d191d54219d5362 Patchbomb only sends introductory message [0 of N] if there are multiple patches. diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -180,17 +180,9 @@ def patchbomb(ui, repo, *revs, **opts): jumbo.extend(p) msgs.append(makepatch(p, i + 1, len(patches))) - ui.write(_('\nWrite the introductory message for the patch series.\n\n')) - sender = (opts['from'] or ui.config('patchbomb', 'from') or prompt('From', ui.username())) - msg = email.MIMEMultipart.MIMEMultipart() - msg['Subject'] = '[PATCH 0 of %d] %s' % ( - len(patches), - opts['subject'] or - prompt('Subject:', rest = ' [PATCH 0 of %d] ' % len(patches))) - def getaddrs(opt, prpt, default = None): addrs = opts[opt] or (ui.config('patchbomb', opt) or prompt(prpt, default = default)).split(',') @@ -198,26 +190,35 @@ def patchbomb(ui, repo, *revs, **opts): to = getaddrs('to', 'To') cc = getaddrs('cc', 'Cc', '') - ui.write(_('Finish with ^D or a dot on a line by itself.\n\n')) + if len(patches) > 1: + ui.write(_('\nWrite the introductory message for the patch series.\n\n')) - body = [] + msg = email.MIMEMultipart.MIMEMultipart() + msg['Subject'] = '[PATCH 0 of %d] %s' % ( + len(patches), + opts['subject'] or + prompt('Subject:', rest = ' [PATCH 0 of %d] ' % len(patches))) + + ui.write(_('Finish with ^D or a dot on a line by itself.\n\n')) + + body = [] - while True: - try: l = raw_input() - except EOFError: break - if l == '.': break - body.append(l) + while True: + try: l = raw_input() + except EOFError: break + if l == '.': break + body.append(l) - msg.attach(email.MIMEText.MIMEText('\n'.join(body) + '\n')) + msg.attach(email.MIMEText.MIMEText('\n'.join(body) + '\n')) + + if opts['diffstat']: + d = cdiffstat(_('Final summary:\n'), jumbo) + if d: msg.attach(email.MIMEText.MIMEText(d)) + + msgs.insert(0, msg) ui.write('\n') - if opts['diffstat']: - d = cdiffstat(_('Final summary:\n'), jumbo) - if d: msg.attach(email.MIMEText.MIMEText(d)) - - msgs.insert(0, msg) - if not opts['test'] and not opts['mbox']: s = smtplib.SMTP() s.connect(host = ui.config('smtp', 'host', 'mail'),