changeset 4435:aac150af09e8

Add ui.patch option. ui.patch overrides the default patch/gpatch command and options.
author Patrick Mezard <pmezard@gmail.com>
date Sat, 12 May 2007 21:09:31 +0200
parents 439b1c35348a
children a764edb6fc95
files doc/hgrc.5.txt mercurial/commands.py mercurial/patch.py
diffstat 3 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/doc/hgrc.5.txt
+++ b/doc/hgrc.5.txt
@@ -432,6 +432,9 @@ ui::
   merge;;
     The conflict resolution program to use during a manual merge.
     Default is "hgmerge".
+  patch;;
+    command to use to apply patches. Look for 'gpatch' or 'patch' in PATH if
+    unset.
   quiet;;
     Reduce the amount of output printed.  True or False.  Default is False.
   remotecmd;;
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -881,8 +881,10 @@ def debuginstall(ui):
     # patch
     ui.status(_("Checking patch...\n"))
     path = os.environ.get('PATH', '')
-    patcher = util.find_in_path('gpatch', path,
-                                util.find_in_path('patch', path, None))
+    patcher = ui.config('ui', 'patch')
+    if not patcher:
+        patcher = util.find_in_path('gpatch', path,
+                                    util.find_in_path('patch', path, None))
     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"))
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -293,11 +293,13 @@ def patch(patchname, ui, strip=1, cwd=No
         """patch and updates the files and fuzz variables"""
         fuzz = False
 
-        patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''),
-                                    'patch')
         args = []
-        if util.needbinarypatch():
-            args.append('--binary')
+        patcher = ui.config('ui', 'patch')
+        if not patcher:
+            patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''),
+                                        'patch')
+            if util.needbinarypatch():
+                args.append('--binary')
                                     
         if cwd:
             args.append('-d %s' % util.shellquote(cwd))