comparison hgext/patchbomb.py @ 4279:126d1967a3f8

Add common bundle/outgoing options to hg email
author John Goerzen <jgoerzen@complete.org>
date Mon, 26 Mar 2007 13:57:49 -0500
parents cfe886c14ddf
children a9336520a4ee
comparison
equal deleted inserted replaced
4278:cfe886c14ddf 4279:126d1967a3f8
183 ui.status(_("no changes found\n")) 183 ui.status(_("no changes found\n"))
184 return [] 184 return []
185 o = repo.changelog.nodesbetween(o, revs or None)[0] 185 o = repo.changelog.nodesbetween(o, revs or None)[0]
186 return [str(repo.changelog.rev(r)) for r in o] 186 return [str(repo.changelog.rev(r)) for r in o]
187 187
188 def getbundle(dest, revs): 188 def getbundle(dest):
189 tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-') 189 tmpdir = tempfile.mkdtemp(prefix='hg-email-bundle-')
190 tmpfn = os.path.join(tmpdir, 'bundle') 190 tmpfn = os.path.join(tmpdir, 'bundle')
191 try: 191 try:
192 commands.bundle(ui, repo, tmpfn, dest, *revs, **{'force': 0}) 192 commands.bundle(ui, repo, tmpfn, dest, **opts)
193 return open(tmpfn).read() 193 return open(tmpfn).read()
194 finally: 194 finally:
195 try: 195 try:
196 os.unlink(tmpfn) 196 os.unlink(tmpfn)
197 except: 197 except:
214 raise util.Abort(_('use only one form to specify the revision')) 214 raise util.Abort(_('use only one form to specify the revision'))
215 revs = opts.get('rev') 215 revs = opts.get('rev')
216 216
217 if opts.get('outgoing'): 217 if opts.get('outgoing'):
218 revs = outgoing(dest, opts.get('rev')) 218 revs = outgoing(dest, opts.get('rev'))
219 if opts.get('bundle'):
220 opts['revs'] = revs
219 221
220 # start 222 # start
221 start_time = util.makedate() 223 start_time = util.makedate()
222 224
223 def genmsgid(id): 225 def genmsgid(id):
309 msg.attach(datapart) 311 msg.attach(datapart)
310 msg['Subject'] = subj 312 msg['Subject'] = subj
311 return [msg] 313 return [msg]
312 314
313 if opts.get('bundle'): 315 if opts.get('bundle'):
314 msgs = getbundlemsgs(getbundle(dest, revs)) 316 msgs = getbundlemsgs(getbundle(dest))
315 else: 317 else:
316 msgs = getexportmsgs() 318 msgs = getexportmsgs()
317 319
318 ui.write('\n') 320 ui.write('\n')
319 321
378 ('m', 'mbox', '', 'write messages to mbox file instead of sending them'), 380 ('m', 'mbox', '', 'write messages to mbox file instead of sending them'),
379 ('o', 'outgoing', None, _('send changes not found in the target repository')), 381 ('o', 'outgoing', None, _('send changes not found in the target repository')),
380 ('b', 'bundle', None, _('send changes not in target as a binary bundle')), 382 ('b', 'bundle', None, _('send changes not in target as a binary bundle')),
381 ('r', 'rev', [], _('a revision to send')), 383 ('r', 'rev', [], _('a revision to send')),
382 ('s', 'subject', '', 'subject of first message (intro or single patch)'), 384 ('s', 'subject', '', 'subject of first message (intro or single patch)'),
383 ('t', 'to', [], 'email addresses of recipients')] + commands.remoteopts, 385 ('t', 'to', [], 'email addresses of recipients'),
386 ('', 'force', None, _('run even when remote repository is unrelated (with -b)')),
387 ('', 'base', [],
388 _('a base changeset to specify instead of a destination (with -b)'))]
389 + commands.remoteopts,
384 "hg email [OPTION]... [DEST]...") 390 "hg email [OPTION]... [DEST]...")
385 } 391 }