##// END OF EJS Templates
patchbomb: extract 'getpatches' closure in its own function...
Pierre-Yves David -
r23210:79f74445 default
parent child Browse files
Show More
@@ -153,6 +153,21 b' def makepatch(ui, repo, patchlines, opts'
153 msg['X-Mercurial-Series-Total'] = '%i' % total
153 msg['X-Mercurial-Series-Total'] = '%i' % total
154 return msg, subj, ds
154 return msg, subj, ds
155
155
156 def _getpatches(repo, revs, **opts):
157 """return a list of patches for a list of revisions
158
159 Each patch in the list is itself a list of lines.
160 """
161 ui = repo.ui
162 prev = repo['.'].rev()
163 for r in scmutil.revrange(repo, revs):
164 if r == prev and (repo[None].files() or repo[None].deleted()):
165 ui.warn(_('warning: working directory has '
166 'uncommitted changes\n'))
167 output = cStringIO.StringIO()
168 cmdutil.export(repo, [r], fp=output,
169 opts=patch.diffopts(ui, opts))
170 yield output.getvalue().split('\n')
156 emailopts = [
171 emailopts = [
157 ('', 'body', None, _('send patches as inline message text (default)')),
172 ('', 'body', None, _('send patches as inline message text (default)')),
158 ('a', 'attach', None, _('send patches as attachments')),
173 ('a', 'attach', None, _('send patches as attachments')),
@@ -292,17 +307,6 b' def patchbomb(ui, repo, *revs, **opts):'
292 return []
307 return []
293 return [str(r) for r in revs]
308 return [str(r) for r in revs]
294
309
295 def getpatches(revs):
296 prev = repo['.'].rev()
297 for r in scmutil.revrange(repo, revs):
298 if r == prev and (repo[None].files() or repo[None].deleted()):
299 ui.warn(_('warning: working directory has '
300 'uncommitted changes\n'))
301 output = cStringIO.StringIO()
302 cmdutil.export(repo, [r], fp=output,
303 opts=patch.diffopts(ui, opts))
304 yield output.getvalue().split('\n')
305
306 def getbundle(dest):
310 def getbundle(dest):
307 tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-')
311 tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-')
308 tmpfn = os.path.join(tmpdir, 'bundle')
312 tmpfn = os.path.join(tmpdir, 'bundle')
@@ -450,7 +454,7 b' def patchbomb(ui, repo, *revs, **opts):'
450 elif bundle:
454 elif bundle:
451 msgs = getbundlemsgs(getbundle(dest))
455 msgs = getbundlemsgs(getbundle(dest))
452 else:
456 else:
453 msgs = getpatchmsgs(list(getpatches(revs)))
457 msgs = getpatchmsgs(list(_getpatches(repo, revs, **opts)))
454
458
455 showaddrs = []
459 showaddrs = []
456
460
General Comments 0
You need to be logged in to leave comments. Login now