Show More
@@ -168,6 +168,31 b' def _getpatches(repo, revs, **opts):' | |||
|
168 | 168 | cmdutil.export(repo, [r], fp=output, |
|
169 | 169 | opts=patch.diffopts(ui, opts)) |
|
170 | 170 | yield output.getvalue().split('\n') |
|
171 | def _getbundle(repo, dest, **opts): | |
|
172 | """return a bundle containing changesets missing in "dest" | |
|
173 | ||
|
174 | The `opts` keyword-arguments are the same as the one accepted by the | |
|
175 | `bundle` command. | |
|
176 | ||
|
177 | The bundle is a returned as a single in-memory binary blob. | |
|
178 | """ | |
|
179 | ui = repo.ui | |
|
180 | tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-') | |
|
181 | tmpfn = os.path.join(tmpdir, 'bundle') | |
|
182 | try: | |
|
183 | commands.bundle(ui, repo, tmpfn, dest, **opts) | |
|
184 | fp = open(tmpfn, 'rb') | |
|
185 | data = fp.read() | |
|
186 | fp.close() | |
|
187 | return data | |
|
188 | finally: | |
|
189 | try: | |
|
190 | os.unlink(tmpfn) | |
|
191 | except OSError: | |
|
192 | pass | |
|
193 | os.rmdir(tmpdir) | |
|
194 | ||
|
195 | ||
|
171 | 196 | emailopts = [ |
|
172 | 197 | ('', 'body', None, _('send patches as inline message text (default)')), |
|
173 | 198 | ('a', 'attach', None, _('send patches as attachments')), |
@@ -307,22 +332,6 b' def patchbomb(ui, repo, *revs, **opts):' | |||
|
307 | 332 | return [] |
|
308 | 333 | return [str(r) for r in revs] |
|
309 | 334 | |
|
310 | def getbundle(dest): | |
|
311 | tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-') | |
|
312 | tmpfn = os.path.join(tmpdir, 'bundle') | |
|
313 | try: | |
|
314 | commands.bundle(ui, repo, tmpfn, dest, **opts) | |
|
315 | fp = open(tmpfn, 'rb') | |
|
316 | data = fp.read() | |
|
317 | fp.close() | |
|
318 | return data | |
|
319 | finally: | |
|
320 | try: | |
|
321 | os.unlink(tmpfn) | |
|
322 | except OSError: | |
|
323 | pass | |
|
324 | os.rmdir(tmpdir) | |
|
325 | ||
|
326 | 335 | if not (opts.get('test') or mbox): |
|
327 | 336 | # really sending |
|
328 | 337 | mail.validateconfig(ui) |
@@ -452,7 +461,7 b' def patchbomb(ui, repo, *revs, **opts):' | |||
|
452 | 461 | if patches: |
|
453 | 462 | msgs = getpatchmsgs(patches, opts.get('patchnames')) |
|
454 | 463 | elif bundle: |
|
455 | msgs = getbundlemsgs(getbundle(dest)) | |
|
464 | msgs = getbundlemsgs(_getbundle(repo, dest, **opts)) | |
|
456 | 465 | else: |
|
457 | 466 | msgs = getpatchmsgs(list(_getpatches(repo, revs, **opts))) |
|
458 | 467 |
General Comments 0
You need to be logged in to leave comments.
Login now