[issue559] patch does not work on Windows due to improper GNU patch command

David Rushby mercurial-bugs at selenic.com
Thu May 10 01:34:34 CDT 2007


New submission from David Rushby <davidrushby at gmail.com>:

I'm using the GNUWin32 port of GNU patch, version 2.5.9-6.

As you can see at http://gnuwin32.sourceforge.net/packages/patch.htm#install ,
GNU patch on Windows expects \r\n line separators, unless an overriding option
is specified.  That page warns, "On MS-Windows, the patchfile must be a text
file, i.e. CR-LF must be used as line endings. A file with LF may give the
error: "Assertion failed, hunk, file patch.c, line 343," unless the option
'--binary' is given.".

Mercurial Queues generates its patch files with the \n line separator, so "hg
qpush" does not work at all on Windows unless the patch() function in
mercurial\patch.py is modified to pass the "--binary" option to GNU patch.

Even though "hg diff" on Windows generates patch files that use \r\n, applying
such a patch to a source file that uses \n with "hg patch" still fails unless
"--binary" is passed to GNU patch.

I have tested all of the combinations of:
  - patch file has \r\n, target file has \r\n
  - patch file has \n, target file has \r\n
  - patch file has \r\n, target file has \n
  - patch file has \n, target file has \n
and none works unless "--binary" is passed to GNU patch.

A patch to apply this change is attached.

----------
files: hg-patch-windows-fix-2007_05_10_10_31.patch
messages: 3064
nosy: davidrushby
priority: urgent
status: unread
title: patch does not work on Windows due to improper GNU patch command

____________________________________________________
Mercurial issue tracker <mercurial-bugs at selenic.com>
<http://www.selenic.com/mercurial/bts/issue559>
____________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hg-patch-windows-fix-2007_05_10_10_31.patch
Type: application/octet-stream
Size: 517 bytes
Desc: not available
Url : http://selenic.com/pipermail/mercurial-devel/attachments/20070510/6e07bdb9/attachment.obj 


More information about the Mercurial-devel mailing list