hgext/patchbomb.py
changeset 7321 e016b65fd284
parent 7192 f31ba106fc19
child 7322 b05834d6be3c
equal deleted inserted replaced
7320:8dca507e56ce 7321:e016b65fd284
    65 import email.MIMEMultipart, email.MIMEBase
    65 import email.MIMEMultipart, email.MIMEBase
    66 import email.Utils, email.Encoders, email.Generator
    66 import email.Utils, email.Encoders, email.Generator
    67 from mercurial import cmdutil, commands, hg, mail, patch, util
    67 from mercurial import cmdutil, commands, hg, mail, patch, util
    68 from mercurial.i18n import _
    68 from mercurial.i18n import _
    69 from mercurial.node import bin
    69 from mercurial.node import bin
       
    70 
       
    71 class exportee:
       
    72     def __init__(self, container):
       
    73         self.lines = []
       
    74         self.container = container
       
    75         self.name = 'email'
       
    76 
       
    77     def write(self, data):
       
    78         self.lines.append(data)
       
    79 
       
    80     def close(self):
       
    81         self.container.append(''.join(self.lines).split('\n'))
       
    82         self.lines = []
    70 
    83 
    71 def patchbomb(ui, repo, *revs, **opts):
    84 def patchbomb(ui, repo, *revs, **opts):
    72     '''send changesets by email
    85     '''send changesets by email
    73 
    86 
    74     By default, diffs are sent in the format generated by hg export,
    87     By default, diffs are sent in the format generated by hg export,
   285             body = ui.edit(body, sender)
   298             body = ui.edit(body, sender)
   286         return body
   299         return body
   287 
   300 
   288     def getexportmsgs():
   301     def getexportmsgs():
   289         patches = []
   302         patches = []
   290 
       
   291         class exportee:
       
   292             def __init__(self, container):
       
   293                 self.lines = []
       
   294                 self.container = container
       
   295                 self.name = 'email'
       
   296 
       
   297             def write(self, data):
       
   298                 self.lines.append(data)
       
   299 
       
   300             def close(self):
       
   301                 self.container.append(''.join(self.lines).split('\n'))
       
   302                 self.lines = []
       
   303 
       
   304         commands.export(ui, repo, *revs, **{'output': exportee(patches),
   303         commands.export(ui, repo, *revs, **{'output': exportee(patches),
   305                                             'switch_parent': False,
   304                                             'switch_parent': False,
   306                                             'text': None,
   305                                             'text': None,
   307                                             'git': opts.get('git')})
   306                                             'git': opts.get('git')})
   308 
   307