From 37afbaec09903e6ca7fc2a87151850c8aa771044 Mon Sep 17 00:00:00 2001 From: Patrick Mezard Date: Sat, 12 May 2007 21:09:29 +0200 Subject: [PATCH] Fix issue483 - mq does not work under windows with gnu-win32 patch. Add --binary option to patch command under win32. --- mercurial/patch.py | 3 +++ mercurial/util.py | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/mercurial/patch.py b/mercurial/patch.py index 2342f7300b..b446967aef 100644 --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -296,6 +296,9 @@ def patch(patchname, ui, strip=1, cwd=None, files={}): patcher = util.find_in_path('gpatch', os.environ.get('PATH', ''), 'patch') args = [] + 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 --git a/mercurial/util.py b/mercurial/util.py index 9766b3d08c..a4e584530e 100644 --- a/mercurial/util.py +++ b/mercurial/util.py @@ -793,6 +793,10 @@ def linkfunc(path, fallback): _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