Mercurial > public > mercurial-scm > hg-stable
comparison hgext/patchbomb.py @ 1845:cfe689ab3f06
Patchbomb only sends introductory message [0 of N] if there are multiple patches.
author | Lee Cantey <lcantey@gmail.com> |
---|---|
date | Mon, 06 Mar 2006 21:05:18 -0800 |
parents | 26dd4ae77b7b |
children | 4d2791f4ef80 |
comparison
equal
deleted
inserted
replaced
1844:b768f3ae0c2c | 1845:cfe689ab3f06 |
---|---|
178 | 178 |
179 for p, i in zip(patches, range(len(patches))): | 179 for p, i in zip(patches, range(len(patches))): |
180 jumbo.extend(p) | 180 jumbo.extend(p) |
181 msgs.append(makepatch(p, i + 1, len(patches))) | 181 msgs.append(makepatch(p, i + 1, len(patches))) |
182 | 182 |
183 ui.write(_('\nWrite the introductory message for the patch series.\n\n')) | |
184 | |
185 sender = (opts['from'] or ui.config('patchbomb', 'from') or | 183 sender = (opts['from'] or ui.config('patchbomb', 'from') or |
186 prompt('From', ui.username())) | 184 prompt('From', ui.username())) |
187 | |
188 msg = email.MIMEMultipart.MIMEMultipart() | |
189 msg['Subject'] = '[PATCH 0 of %d] %s' % ( | |
190 len(patches), | |
191 opts['subject'] or | |
192 prompt('Subject:', rest = ' [PATCH 0 of %d] ' % len(patches))) | |
193 | 185 |
194 def getaddrs(opt, prpt, default = None): | 186 def getaddrs(opt, prpt, default = None): |
195 addrs = opts[opt] or (ui.config('patchbomb', opt) or | 187 addrs = opts[opt] or (ui.config('patchbomb', opt) or |
196 prompt(prpt, default = default)).split(',') | 188 prompt(prpt, default = default)).split(',') |
197 return [a.strip() for a in addrs if a.strip()] | 189 return [a.strip() for a in addrs if a.strip()] |
198 to = getaddrs('to', 'To') | 190 to = getaddrs('to', 'To') |
199 cc = getaddrs('cc', 'Cc', '') | 191 cc = getaddrs('cc', 'Cc', '') |
200 | 192 |
201 ui.write(_('Finish with ^D or a dot on a line by itself.\n\n')) | 193 if len(patches) > 1: |
202 | 194 ui.write(_('\nWrite the introductory message for the patch series.\n\n')) |
203 body = [] | 195 |
204 | 196 msg = email.MIMEMultipart.MIMEMultipart() |
205 while True: | 197 msg['Subject'] = '[PATCH 0 of %d] %s' % ( |
206 try: l = raw_input() | 198 len(patches), |
207 except EOFError: break | 199 opts['subject'] or |
208 if l == '.': break | 200 prompt('Subject:', rest = ' [PATCH 0 of %d] ' % len(patches))) |
209 body.append(l) | 201 |
210 | 202 ui.write(_('Finish with ^D or a dot on a line by itself.\n\n')) |
211 msg.attach(email.MIMEText.MIMEText('\n'.join(body) + '\n')) | 203 |
204 body = [] | |
205 | |
206 while True: | |
207 try: l = raw_input() | |
208 except EOFError: break | |
209 if l == '.': break | |
210 body.append(l) | |
211 | |
212 msg.attach(email.MIMEText.MIMEText('\n'.join(body) + '\n')) | |
213 | |
214 if opts['diffstat']: | |
215 d = cdiffstat(_('Final summary:\n'), jumbo) | |
216 if d: msg.attach(email.MIMEText.MIMEText(d)) | |
217 | |
218 msgs.insert(0, msg) | |
212 | 219 |
213 ui.write('\n') | 220 ui.write('\n') |
214 | |
215 if opts['diffstat']: | |
216 d = cdiffstat(_('Final summary:\n'), jumbo) | |
217 if d: msg.attach(email.MIMEText.MIMEText(d)) | |
218 | |
219 msgs.insert(0, msg) | |
220 | 221 |
221 if not opts['test'] and not opts['mbox']: | 222 if not opts['test'] and not opts['mbox']: |
222 s = smtplib.SMTP() | 223 s = smtplib.SMTP() |
223 s.connect(host = ui.config('smtp', 'host', 'mail'), | 224 s.connect(host = ui.config('smtp', 'host', 'mail'), |
224 port = int(ui.config('smtp', 'port', 25))) | 225 port = int(ui.config('smtp', 'port', 25))) |