# HG changeset patch # User Bryan O'Sullivan # Date 1180302014 25200 # Node ID a11e13d50645102bfa2cc9089e4efd932765ff80 # Parent 62019c4427e31446b5eea466339fe465f12e6576 patchbomb: Validate email config before we start prompting for info. diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -223,6 +223,9 @@ def patchbomb(ui, repo, *revs, **opts): pass os.rmdir(tmpdir) + if not opts['test']: + mail.validateconfig(ui) + # option handling commands.setremoteconfig(ui, opts) if opts.get('outgoint') and opts.get('bundle'): diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -68,3 +68,15 @@ def connect(ui): def sendmail(ui, sender, recipients, msg): return connect(ui).sendmail(sender, recipients, msg) + +def validateconfig(ui): + '''determine if we have enough config data to try sending email.''' + method = ui.config('email', 'method', 'smtp') + if method == 'smtp': + if not ui.config('smtp', 'host'): + raise util.Abort(_('smtp specified as email transport, ' + 'but no smtp host configured')) + else: + if not util.find_exe(method): + raise util.Abort(_('%r specified as email transport, ' + 'but not in PATH') % method)