Automated merge with http://hg.intevation.org/mercurial/crew
authorBryan O'Sullivan <bos@serpentine.com>
Sun, 27 May 2007 14:43:29 -0700
changeset 4490 c927c568a5ad
parent 4489 a11e13d50645 (diff)
parent 4450 8fa54b9c6c5a (current diff)
child 4491 6d2d1dcd5f74
Automated merge with http://hg.intevation.org/mercurial/crew
mercurial/commands.py
mercurial/patch.py
--- a/hgext/acl.py	Thu May 17 13:55:24 2007 -0400
+++ b/hgext/acl.py	Sun May 27 14:43:29 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	Thu May 17 13:55:24 2007 -0400
+++ b/hgext/patchbomb.py	Sun May 27 14:43:29 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,6 +223,9 @@
                 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'):
@@ -250,23 +253,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 = []
 
@@ -344,6 +330,23 @@
     else:
         msgs = getexportmsgs()
 
+    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()]
+
     ui.write('\n')
 
     if not opts['test'] and not opts['mbox']:
--- a/mercurial/commands.py	Thu May 17 13:55:24 2007 -0400
+++ b/mercurial/commands.py	Sun May 27 14:43:29 2007 -0700
@@ -885,11 +885,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"))
@@ -927,9 +926,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"
@@ -963,9 +960,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	Thu May 17 13:55:24 2007 -0400
+++ b/mercurial/mail.py	Sun May 27 14:43:29 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	Thu May 17 13:55:24 2007 -0400
+++ b/mercurial/patch.py	Sun May 27 14:43:29 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	Thu May 17 13:55:24 2007 -0400
+++ b/mercurial/ui.py	Sun May 27 14:43:29 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	Thu May 17 13:55:24 2007 -0400
+++ b/mercurial/util.py	Sun May 27 14:43:29 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 '\\:*?"<>|']