Mercurial > hg
changeset 4494:649dd2492ae5
Merge with crew.
author | Bryan O'Sullivan <bos@serpentine.com> |
---|---|
date | Sat, 02 Jun 2007 09:04:23 -0700 |
parents | ead2fa544cbf (diff) b2b55acbacdd (current diff) |
children | fc20fa9f2dfd |
files | mercurial/commands.py |
diffstat | 7 files changed, 68 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/acl.py Fri Jun 01 18:40:14 2007 -0500 +++ b/hgext/acl.py Sat Jun 02 09:04:23 2007 -0700 @@ -55,7 +55,7 @@ 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 Fri Jun 01 18:40:14 2007 -0500 +++ b/hgext/patchbomb.py Sat Jun 02 09:04:23 2007 -0700 @@ -70,12 +70,6 @@ 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 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 @@ 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 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 @@ 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 Fri Jun 01 18:40:14 2007 -0500 +++ b/mercurial/commands.py Sat Jun 02 09:04:23 2007 -0700 @@ -886,11 +886,10 @@ # 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 @@ 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 @@ 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 Fri Jun 01 18:40:14 2007 -0500 +++ b/mercurial/mail.py Sat Jun 02 09:04:23 2007 -0700 @@ -68,3 +68,15 @@ 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 Fri Jun 01 18:40:14 2007 -0500 +++ b/mercurial/patch.py Sat Jun 02 09:04:23 2007 -0700 @@ -298,11 +298,13 @@ 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 @@ 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 Fri Jun 01 18:40:14 2007 -0500 +++ b/mercurial/ui.py Sat Jun 02 09:04:23 2007 -0700 @@ -270,7 +270,7 @@ 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 Fri Jun 01 18:40:14 2007 -0500 +++ b/mercurial/util.py Sat Jun 02 09:04:23 2007 -0700 @@ -1087,6 +1087,18 @@ 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 '\\:*?"<>|']