##// END OF EJS Templates
patchbomb: add content-disposition to make display inline and add filename...
Vadim Gelfer -
r2708:084f07ca default
parent child Browse files
Show More
@@ -45,6 +45,7 b" demandload(globals(), '''email.MIMEMulti"
45 mercurial:commands,hg,ui
45 mercurial:commands,hg,ui
46 os errno popen2 socket sys tempfile time''')
46 os errno popen2 socket sys tempfile time''')
47 from mercurial.i18n import gettext as _
47 from mercurial.i18n import gettext as _
48 from mercurial.node import *
48
49
49 try:
50 try:
50 # readline gives raw_input editing capabilities, but is not
51 # readline gives raw_input editing capabilities, but is not
@@ -133,7 +134,20 b' def patchbomb(ui, repo, *revs, **opts):'
133 if opts['attach']:
134 if opts['attach']:
134 msg = email.MIMEMultipart.MIMEMultipart()
135 msg = email.MIMEMultipart.MIMEMultipart()
135 if body: msg.attach(email.MIMEText.MIMEText(body, 'plain'))
136 if body: msg.attach(email.MIMEText.MIMEText(body, 'plain'))
136 msg.attach(email.MIMEText.MIMEText('\n'.join(patch), 'x-patch'))
137 p = email.MIMEText.MIMEText('\n'.join(patch), 'x-patch')
138 node = bin(node)
139 # if node is mq patch, it will have patch file name as tag
140 patchname = [t for t in repo.nodetags(node)
141 if t.endswith('.patch') or t.endswith('.diff')]
142 if patchname:
143 patchname = patchname[0]
144 elif total > 1:
145 patchname = commands.make_filename(repo, '%b-%n.patch',
146 node, idx, total)
147 else:
148 patchname = commands.make_filename(repo, '%b.patch', node)
149 p['Content-Disposition'] = 'inline; filename=' + patchname
150 msg.attach(p)
137 else:
151 else:
138 body += '\n'.join(patch)
152 body += '\n'.join(patch)
139 msg = email.MIMEText.MIMEText(body)
153 msg = email.MIMEText.MIMEText(body)
General Comments 0
You need to be logged in to leave comments. Login now