##// END OF EJS Templates
patchbomb: make `hg email` reusable for other patch sources...
Peter Arrenbrecht -
r7353:982b55ec default
parent child Browse files
Show More
@@ -159,7 +159,7 b' def patchbomb(ui, repo, *revs, **opts):'
159 159 s = ''
160 160 return s
161 161
162 def makepatch(patch, idx, total):
162 def makepatch(patch, idx, total, patchname=None):
163 163 desc = []
164 164 node = None
165 165 body = ''
@@ -171,7 +171,7 b' def patchbomb(ui, repo, *revs, **opts):'
171 171 if line.startswith('diff -r') or line.startswith('diff --git'):
172 172 break
173 173 desc.append(line)
174 if not node:
174 if not patchname and not node:
175 175 raise ValueError
176 176
177 177 if opts.get('attach'):
@@ -197,15 +197,16 b' def patchbomb(ui, repo, *revs, **opts):'
197 197 opts.get('test'))
198 198 binnode = bin(node)
199 199 # if node is mq patch, it will have patch file name as tag
200 patchname = [t for t in repo.nodetags(binnode)
201 if t.endswith('.patch') or t.endswith('.diff')]
202 if patchname:
203 patchname = patchname[0]
204 elif total > 1:
205 patchname = cmdutil.make_filename(repo, '%b-%n.patch',
206 binnode, idx, total)
207 else:
208 patchname = cmdutil.make_filename(repo, '%b.patch', binnode)
200 if not patchname:
201 patchtags = [t for t in repo.nodetags(binnode)
202 if t.endswith('.patch') or t.endswith('.diff')]
203 if patchtags:
204 patchname = patchtags[0]
205 elif total > 1:
206 patchname = cmdutil.make_filename(repo, '%b-%n.patch',
207 binnode, idx, total)
208 else:
209 patchname = cmdutil.make_filename(repo, '%b.patch', binnode)
209 210 disposition = 'inline'
210 211 if opts.get('attach'):
211 212 disposition = 'attachment'
@@ -256,7 +257,8 b' def patchbomb(ui, repo, *revs, **opts):'
256 257 mail.validateconfig(ui)
257 258
258 259 if not (revs or opts.get('rev')
259 or opts.get('outgoing') or opts.get('bundle')):
260 or opts.get('outgoing') or opts.get('bundle')
261 or opts.get('patches')):
260 262 raise util.Abort(_('specify at least one changeset with -r or -o'))
261 263
262 264 cmdutil.setremoteconfig(ui, opts)
@@ -298,22 +300,19 b' def patchbomb(ui, repo, *revs, **opts):'
298 300 body = ui.edit(body, sender)
299 301 return body
300 302
301 def getexportmsgs():
302 patches = []
303 commands.export(ui, repo, *revs, **{'output': exportee(patches),
304 'switch_parent': False,
305 'text': None,
306 'git': opts.get('git')})
307
303 def getpatchmsgs(patches, patchnames=None):
308 304 jumbo = []
309 305 msgs = []
310 306
311 307 ui.write(_('This patch series consists of %d patches.\n\n')
312 308 % len(patches))
313 309
310 name = None
314 311 for p, i in zip(patches, xrange(len(patches))):
315 312 jumbo.extend(p)
316 msgs.append(makepatch(p, i + 1, len(patches)))
313 if patchnames:
314 name = patchnames[i]
315 msgs.append(makepatch(p, i + 1, len(patches), name))
317 316
318 317 if len(patches) > 1:
319 318 tlen = len(str(len(patches)))
@@ -359,10 +358,18 b' def patchbomb(ui, repo, *revs, **opts):'
359 358 ui.config('patchbomb', 'from') or
360 359 prompt('From', ui.username()))
361 360
362 if opts.get('bundle'):
361 patches = opts.get('patches')
362 if patches:
363 msgs = getpatchmsgs(patches, opts.get('patchnames'))
364 elif opts.get('bundle'):
363 365 msgs = getbundlemsgs(getbundle(dest))
364 366 else:
365 msgs = getexportmsgs()
367 patches = []
368 commands.export(ui, repo, *revs, **{'output': exportee(patches),
369 'switch_parent': False,
370 'text': None,
371 'git': opts.get('git')})
372 msgs = getpatchmsgs(patches)
366 373
367 374 def getaddrs(opt, prpt, default = None):
368 375 addrs = opts.get(opt) or (ui.config('email', opt) or
General Comments 0
You need to be logged in to leave comments. Login now