[PATCH 1 of 1] patch: generate .rej wihtout eol adaptation

Patrick Mézard pmezard at gmail.com
Mon Dec 6 13:08:55 CST 2010

Le 05/12/10 00:07, Matt Mackall a écrit :
> On Fri, 2010-12-03 at 11:44 +0900, Shun-ichi Goto wrote:
>> # HG changeset patch
>> # User Shun-ichi GOTO <shunichi.goto at gmail.com>
>> # Date 1291344030 -32400
>> # Node ID ad4e934ef9dbe2a82d9477f5aed39ec0df6fc7d2
>> # Parent  cec6140b0f3c8c00515dbf3589068d1e2d233fdf
>> patch: generate .rej wihtout eol adaptation
> Martin or Patrick, do you have an opinion about this?

The analysis is correct and it is great to have a test but I will work on a different solution.

patchfile.writelines() was introduced to centralize all write I/Os so they can be overriden to support things like memory patching. hgsubversion uses it for instance. But passing .rej output to writefiles() seems wrong to me : the caller probably expects to get only patch output data and has no way to tell this is a reject file except for the extension. So, I am likely to fix it by:
1- Moving the reject file generation code into hunk class
2- Restore the previous hard-coded opener

That way, custom reject file handling could be done properly by overriding write_rej(). Existing code was probably doing this already because wild guessing on file name is brittle. And it has the advantage of not changing writelines() signature and thus not break third-party code.

Patrick Mézard

More information about the Mercurial-devel mailing list