Merge with crew.
--- a/hgext/acl.py
+++ b/hgext/acl.py
@@ -55,7 +55,7 @@ class checker(object):
def buildmatch(self, key):
'''return tuple of (match function, list enabled).'''
- if not self.ui.has_config(key):
+ if not self.ui.has_section(key):
self.ui.debug(_('acl: %s not enabled\n') % key)
return None, False
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -70,12 +70,6 @@ from mercurial import cmdutil, commands,
from mercurial.i18n import _
from mercurial.node import *
-try:
- # readline gives raw_input editing capabilities, but is not
- # present on windows
- import readline
-except ImportError: pass
-
def patchbomb(ui, repo, *revs, **opts):
'''send changesets by email
@@ -120,6 +114,12 @@ def patchbomb(ui, repo, *revs, **opts):
'''
def prompt(prompt, default = None, rest = ': ', empty_ok = False):
+ try:
+ # readline gives raw_input editing capabilities, but is not
+ # present on windows
+ import readline
+ except ImportError: pass
+
if default: prompt += ' [%s]' % default
prompt += rest
while True:
@@ -223,9 +223,14 @@ def patchbomb(ui, repo, *revs, **opts):
pass
os.rmdir(tmpdir)
- # option handling
+ if not opts['test']:
+ mail.validateconfig(ui)
+
+ if not (revs or opts.get('rev') or opts.get('outgoing')):
+ raise util.Abort(_('specify at least one changeset with -r or -o'))
+
commands.setremoteconfig(ui, opts)
- if opts.get('outgoint') and opts.get('bundle'):
+ if opts.get('outgoing') and opts.get('bundle'):
raise util.Abort(_("--outgoing mode always on with --bundle; do not re-specify --outgoing"))
if opts.get('outgoing') or opts.get('bundle'):
@@ -250,23 +255,6 @@ def patchbomb(ui, repo, *revs, **opts):
def genmsgid(id):
return '<%s.%s@%s>' % (id[:20], int(start_time[0]), socket.getfqdn())
- sender = (opts['from'] or ui.config('email', 'from') or
- ui.config('patchbomb', 'from') or
- prompt('From', ui.username()))
-
- def getaddrs(opt, prpt, default = None):
- addrs = opts[opt] or (ui.config('email', opt) or
- ui.config('patchbomb', opt) or
- prompt(prpt, default = default)).split(',')
- return [a.strip() for a in addrs if a.strip()]
-
- to = getaddrs('to', 'To')
- cc = getaddrs('cc', 'Cc', '')
-
- bcc = opts['bcc'] or (ui.config('email', 'bcc') or
- ui.config('patchbomb', 'bcc') or '').split(',')
- bcc = [a.strip() for a in bcc if a.strip()]
-
def getexportmsgs():
patches = []
@@ -339,11 +327,28 @@ def patchbomb(ui, repo, *revs, **opts):
msg['Subject'] = subj
return [msg]
+ sender = (opts['from'] or ui.config('email', 'from') or
+ ui.config('patchbomb', 'from') or
+ prompt('From', ui.username()))
+
if opts.get('bundle'):
msgs = getbundlemsgs(getbundle(dest))
else:
msgs = getexportmsgs()
+ def getaddrs(opt, prpt, default = None):
+ addrs = opts[opt] or (ui.config('email', opt) or
+ ui.config('patchbomb', opt) or
+ prompt(prpt, default = default)).split(',')
+ return [a.strip() for a in addrs if a.strip()]
+
+ to = getaddrs('to', 'To')
+ cc = getaddrs('cc', 'Cc', '')
+
+ bcc = opts['bcc'] or (ui.config('email', 'bcc') or
+ ui.config('patchbomb', 'bcc') or '').split(',')
+ bcc = [a.strip() for a in bcc if a.strip()]
+
ui.write('\n')
if not opts['test'] and not opts['mbox']:
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -886,11 +886,10 @@ def debuginstall(ui):
# patch
ui.status(_("Checking patch...\n"))
- path = os.environ.get('PATH', '')
patcher = ui.config('ui', 'patch')
- if not patcher:
- patcher = util.find_in_path('gpatch', path,
- util.find_in_path('patch', path, None))
+ patcher = ((patcher and util.find_exe(patcher)) or
+ util.find_exe('gpatch') or
+ util.find_exe('patch'))
if not patcher:
ui.write(_(" Can't find patch or gpatch in PATH\n"))
ui.write(_(" (specify a patch utility in your .hgrc file)\n"))
@@ -928,9 +927,7 @@ def debuginstall(ui):
ui.status(_("Checking merge helper...\n"))
cmd = (os.environ.get("HGMERGE") or ui.config("ui", "merge")
or "hgmerge")
- cmdpath = util.find_in_path(cmd, path)
- if not cmdpath:
- cmdpath = util.find_in_path(cmd.split()[0], path)
+ cmdpath = util.find_exe(cmd) or util.find_exe(cmd.split()[0])
if not cmdpath:
if cmd == 'hgmerge':
ui.write(_(" No merge helper set and can't find default"
@@ -964,9 +961,7 @@ def debuginstall(ui):
editor = (os.environ.get("HGEDITOR") or
ui.config("ui", "editor") or
os.environ.get("EDITOR", "vi"))
- cmdpath = util.find_in_path(editor, path)
- if not cmdpath:
- cmdpath = util.find_in_path(editor.split()[0], path)
+ cmdpath = util.find_exe(editor) or util.find_exe(editor.split()[0])
if not cmdpath:
if editor == 'vi':
ui.write(_(" No commit editor set and can't find vi in PATH\n"))
--- 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)
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -298,11 +298,13 @@ def patch(patchname, ui, strip=1, cwd=No
args = []
patcher = ui.config('ui', 'patch')
+ patcher = ((patcher and util.find_exe(patcher)) or
+ util.find_exe('gpatch') or
+ util.find_exe('patch'))
if not patcher:
- patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''),
- 'patch')
- if util.needbinarypatch():
- args.append('--binary')
+ raise util.Abort(_('no patch command found in hgrc or PATH'))
+ if util.needbinarypatch():
+ args.append('--binary')
if cwd:
args.append('-d %s' % util.shellquote(cwd))
@@ -646,7 +648,7 @@ def export(repo, revs, template='hg-%h.p
single(rev, seqno+1, fp)
def diffstat(patchlines):
- if not util.find_in_path('diffstat', os.environ.get('PATH', '')):
+ if not util.find_exe('diffstat'):
return
fd, name = tempfile.mkstemp(prefix="hg-patchbomb-", suffix=".txt")
try:
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -270,7 +270,7 @@ class ui(object):
result = result.replace(",", " ").split()
return result
- def has_config(self, section, untrusted=False):
+ def has_section(self, section, untrusted=False):
'''tell whether section exists in config.'''
cdata = self._get_cdata(untrusted)
return cdata.has_section(section)
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -1087,6 +1087,18 @@ else:
return p_name
return default
+def find_exe(name, default=None):
+ '''find path of an executable.
+ if name contains a path component, return it as is. otherwise,
+ use normal executable search path.'''
+
+ if os.sep in name:
+ # don't check the executable bit. if the file isn't
+ # executable, whoever tries to actually run it will give a
+ # much more useful error message.
+ return name
+ return find_in_path(name, os.environ.get('PATH', ''), default=default)
+
def _buildencodefun():
e = '_'
win_reserved = [ord(x) for x in '\\:*?"<>|']