[PATCH] Fix issue483 - mq does not work under windows with gnu-win32 patch

Patrick Mezard pmezard at gmail.com
Thu May 10 21:00:48 UTC 2007


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1178830466 -7200
# Node ID 2e0f3a96803dafabc4860556198239c5e39aa19f
# Parent  ba22e867cb23fb11f83c37705743e050afd66a6a
Fix issue483 - mq does not work under windows with gnu-win32 patch.

Look in hgrc.ui.patch for a patch command, then default to PATH. If hgrc.ui.patch is not supplied, add a --binary option under win32.

diff -r ba22e867cb23 -r 2e0f3a96803d doc/hgrc.5.txt
--- a/doc/hgrc.5.txt	Mon May 07 21:44:11 2007 +0900
+++ b/doc/hgrc.5.txt	Thu May 10 22:54:26 2007 +0200
@@ -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;;
diff -r ba22e867cb23 -r 2e0f3a96803d mercurial/commands.py
--- a/mercurial/commands.py	Mon May 07 21:44:11 2007 +0900
+++ b/mercurial/commands.py	Thu May 10 22:54:26 2007 +0200
@@ -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"))
diff -r ba22e867cb23 -r 2e0f3a96803d mercurial/patch.py
--- a/mercurial/patch.py	Mon May 07 21:44:11 2007 +0900
+++ b/mercurial/patch.py	Thu May 10 22:54:26 2007 +0200
@@ -293,9 +293,15 @@ 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 = []
+        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))
         fp = os.popen('%s %s -p%d < %s' % (patcher, ' '.join(args), strip,
diff -r ba22e867cb23 -r 2e0f3a96803d mercurial/util.py
--- a/mercurial/util.py	Mon May 07 21:44:11 2007 +0900
+++ b/mercurial/util.py	Thu May 10 22:54:26 2007 +0200
@@ -793,6 +793,10 @@ _umask = os.umask(0)
 _umask = os.umask(0)
 os.umask(_umask)
 
+def needbinarypatch():
+    """return True if patches should be applied in binary mode by default."""
+    return os.name == 'nt'
+
 # Platform specific variants
 if os.name == 'nt':
     import msvcrt



More information about the Mercurial-devel mailing list