hgext/patchbomb.py
changeset 26587 56b2bcea2529
parent 26563 d4a1bfe1de63
child 26626 dca161728dc9
equal deleted inserted replaced
26586:d51c658d3f04 26587:56b2bcea2529
    58 '''
    58 '''
    59 
    59 
    60 import os, errno, socket, tempfile, cStringIO
    60 import os, errno, socket, tempfile, cStringIO
    61 import email
    61 import email
    62 
    62 
    63 from mercurial import cmdutil, commands, hg, mail, patch, util
    63 from mercurial import cmdutil, commands, hg, mail, patch, util, error
    64 from mercurial import scmutil
    64 from mercurial import scmutil
    65 from mercurial.i18n import _
    65 from mercurial.i18n import _
    66 from mercurial.node import bin
    66 from mercurial.node import bin
    67 
    67 
    68 cmdtable = {}
    68 cmdtable = {}
   499     if not (opts.get('test') or mbox):
   499     if not (opts.get('test') or mbox):
   500         # really sending
   500         # really sending
   501         mail.validateconfig(ui)
   501         mail.validateconfig(ui)
   502 
   502 
   503     if not (revs or rev or outgoing or bundle or patches):
   503     if not (revs or rev or outgoing or bundle or patches):
   504         raise util.Abort(_('specify at least one changeset with -r or -o'))
   504         raise error.Abort(_('specify at least one changeset with -r or -o'))
   505 
   505 
   506     if outgoing and bundle:
   506     if outgoing and bundle:
   507         raise util.Abort(_("--outgoing mode always on with --bundle;"
   507         raise error.Abort(_("--outgoing mode always on with --bundle;"
   508                            " do not re-specify --outgoing"))
   508                            " do not re-specify --outgoing"))
   509 
   509 
   510     if outgoing or bundle:
   510     if outgoing or bundle:
   511         if len(revs) > 1:
   511         if len(revs) > 1:
   512             raise util.Abort(_("too many destinations"))
   512             raise error.Abort(_("too many destinations"))
   513         if revs:
   513         if revs:
   514             dest = revs[0]
   514             dest = revs[0]
   515         else:
   515         else:
   516             dest = None
   516             dest = None
   517         revs = []
   517         revs = []
   518 
   518 
   519     if rev:
   519     if rev:
   520         if revs:
   520         if revs:
   521             raise util.Abort(_('use only one form to specify the revision'))
   521             raise error.Abort(_('use only one form to specify the revision'))
   522         revs = rev
   522         revs = rev
   523 
   523 
   524     revs = scmutil.revrange(repo, revs)
   524     revs = scmutil.revrange(repo, revs)
   525     if outgoing:
   525     if outgoing:
   526         revs = _getoutgoing(repo, dest, revs)
   526         revs = _getoutgoing(repo, dest, revs)
   576             return default
   576             return default
   577 
   577 
   578     to = getaddrs('To', ask=True)
   578     to = getaddrs('To', ask=True)
   579     if not to:
   579     if not to:
   580         # we can get here in non-interactive mode
   580         # we can get here in non-interactive mode
   581         raise util.Abort(_('no recipient addresses provided'))
   581         raise error.Abort(_('no recipient addresses provided'))
   582     cc = getaddrs('Cc', ask=True, default='') or []
   582     cc = getaddrs('Cc', ask=True, default='') or []
   583     bcc = getaddrs('Bcc') or []
   583     bcc = getaddrs('Bcc') or []
   584     replyto = getaddrs('Reply-To')
   584     replyto = getaddrs('Reply-To')
   585 
   585 
   586     confirm = ui.configbool('patchbomb', 'confirm')
   586     confirm = ui.configbool('patchbomb', 'confirm')
   596             if ds:
   596             if ds:
   597                 ui.write(ds, label='patchbomb.diffstats')
   597                 ui.write(ds, label='patchbomb.diffstats')
   598         ui.write('\n')
   598         ui.write('\n')
   599         if ui.promptchoice(_('are you sure you want to send (yn)?'
   599         if ui.promptchoice(_('are you sure you want to send (yn)?'
   600                              '$$ &Yes $$ &No')):
   600                              '$$ &Yes $$ &No')):
   601             raise util.Abort(_('patchbomb canceled'))
   601             raise error.Abort(_('patchbomb canceled'))
   602 
   602 
   603     ui.write('\n')
   603     ui.write('\n')
   604 
   604 
   605     parent = opts.get('in_reply_to') or None
   605     parent = opts.get('in_reply_to') or None
   606     # angle brackets may be omitted, they're not semantically part of the msg-id
   606     # angle brackets may be omitted, they're not semantically part of the msg-id