Mercurial > hg-stable
changeset 2708:084f07cacba0
patchbomb: add content-disposition to make display inline and add filename
if rev being emailed has tag that ends in .patch or .diff then use that as
filename. else make up filename from name of repo.
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Thu, 27 Jul 2006 15:19:58 -0700 |
parents | 4af7b178976a |
children | 58913ed8f7f5 |
files | hgext/patchbomb.py |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/patchbomb.py Thu Jul 27 22:28:03 2006 +0200 +++ b/hgext/patchbomb.py Thu Jul 27 15:19:58 2006 -0700 @@ -45,6 +45,7 @@ mercurial:commands,hg,ui os errno popen2 socket sys tempfile time''') from mercurial.i18n import gettext as _ +from mercurial.node import * try: # readline gives raw_input editing capabilities, but is not @@ -133,7 +134,20 @@ if opts['attach']: msg = email.MIMEMultipart.MIMEMultipart() if body: msg.attach(email.MIMEText.MIMEText(body, 'plain')) - msg.attach(email.MIMEText.MIMEText('\n'.join(patch), 'x-patch')) + p = email.MIMEText.MIMEText('\n'.join(patch), 'x-patch') + node = bin(node) + # if node is mq patch, it will have patch file name as tag + patchname = [t for t in repo.nodetags(node) + if t.endswith('.patch') or t.endswith('.diff')] + if patchname: + patchname = patchname[0] + elif total > 1: + patchname = commands.make_filename(repo, '%b-%n.patch', + node, idx, total) + else: + patchname = commands.make_filename(repo, '%b.patch', node) + p['Content-Disposition'] = 'inline; filename=' + patchname + msg.attach(p) else: body += '\n'.join(patch) msg = email.MIMEText.MIMEText(body)