help = 'send a patch or series of patches by e-mail'
-usage = """%prog [options] [<patch>]
+usage = """%prog [options] [<patch> [<patch2...]]
Send a patch or a range of patches (defaulting to the applied patches)
by e-mail using the 'smtpserver' configuration option. The From
"""Return a two elements tuple: (from, [to])
"""
def __addr_list(string):
- return re.split('.*?([\w\.]+@[\w\.]+)', string)[1:-1:2]
+ return re.split('.*?([-\w\.]+@[-\w\.]+)', string)[1:-1:2]
from_addr_list = []
to_addr_list = []
elif re.match('(to|cc|bcc):\s+', line, re.I):
to_addr_list += __addr_list(line)
- if len(from_addr_list) != 1:
+ if len(from_addr_list) == 0:
raise CmdException, 'No "From" address'
if len(to_addr_list) == 0:
raise CmdException, 'No "To/Cc/Bcc" addresses'
"""Send the patches by e-mail using the patchmail.tmpl file as
a template
"""
- if len(args) > 1:
- parser.error('incorrect number of arguments')
-
if not config.has_option('stgit', 'smtpserver'):
raise CmdException, 'smtpserver not defined'
smtpserver = config.get('stgit', 'smtpserver')
applied = crt_series.get_applied()
- if len(args) == 1:
- if args[0] in applied:
- patches = [args[0]]
- else:
- raise CmdException, 'Patch "%s" not applied' % args[0]
+ if len(args) >= 1:
+ for patch in args:
+ if not patch in applied:
+ raise CmdException, 'Patch "%s" not applied' % patch
+ patches = args
elif options.all:
patches = applied
elif options.range: