diff mercurial/patch.py @ 4488:62019c4427e3

Introduce find_exe. Use instead of find_in_path for programs. The behaviour of find_in_path was broken for config options containing path names, because it always searched the given path, even when not necessary. The find_exe function is more polite: if the name passed to it contains a path component, it just returns it.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 27 May 2007 14:26:54 -0700
parents a764edb6fc95
children c927c568a5ad
line wrap: on
line diff
--- a/mercurial/patch.py	Sun May 27 13:50:59 2007 -0700
+++ b/mercurial/patch.py	Sun May 27 14:26:54 2007 -0700
@@ -295,11 +295,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))
@@ -643,7 +645,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: