Mercurial > hg
comparison hgext/patchbomb.py @ 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 | 10e95059ffd7 |
comparison
equal
deleted
inserted
replaced
2707:4af7b178976a | 2708:084f07cacba0 |
---|---|
43 from mercurial.demandload import * | 43 from mercurial.demandload import * |
44 demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils | 44 demandload(globals(), '''email.MIMEMultipart email.MIMEText email.Utils |
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 |
51 # present on windows | 52 # present on windows |
52 import readline | 53 import readline |
131 if opts['diffstat']: | 132 if opts['diffstat']: |
132 body += cdiffstat('\n'.join(desc), patch) + '\n\n' | 133 body += cdiffstat('\n'.join(desc), patch) + '\n\n' |
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) |
140 if total == 1: | 154 if total == 1: |
141 subj = '[PATCH] ' + desc[0].strip() | 155 subj = '[PATCH] ' + desc[0].strip() |