[PATCH 1 of 1] patch: generate .rej wihtout eol adaptation
Mads Kiilerich
mads at kiilerich.com
Thu Dec 2 07:38:56 CST 2010
On 12/02/2010 02:16 PM, Shun-ichi Goto wrote:
> 2010/12/2 Mads Kiilerich<mads at kiilerich.com>:
>>> To reproduce this issue:
>>> 1. make taget file having CRLF line ending
>>> 2. make patch file having CRLF content line ending
>>> 3. prepare patch which would conflict
>>> 4. applying patch with option 'patch.eol=auto'
>>> 5. check .rej file has CRCRLF<= incorrect!
>>
>> Could this reproducer description go into a test in the test suite?
>
> I only have a simple shell script because I'm not familiar with hg's test suit.
See http://mercurial.selenic.com/wiki/WritingTests
Writing tests this way is not only a boring task, but also a nice tool
when investigating and documenting issues and developing fixes.
> And it use mq (qpush) to kick patching as I experienced.
> (Note that it has ^M code)
The script you gave can be transformed quite straight forward:
$ echo "[extensions]" >> $HGRCPATH
$ echo "mq=" >> $HGRCPATH
$ hg init r
$ cd r
$ printf '4 hello\r\n' >> a.txt
$ printf '5 hello\r\n' >> a.txt
$ printf '6 hello\r\n' >> a.txt
$ printf '7 hello\r\n' >> a.txt
$ hg ci -Am 1
adding a.txt
$ rm a.txt
$ printf '4 hello\r\n' >> a.txt
$ printf '5 hello\r\n' >> a.txt
$ printf '6 HELLO\r\n' >> a.txt
$ printf '7 hello\r\n' >> a.txt
$ hg qnew -fm "line 2" m1
$ hg qpop
popping m1
patch queue now empty
$ rm a.txt
$ printf '4 hello\r\n' >> a.txt
$ printf '5 good morning\r\n' >> a.txt
$ printf '6 HELLO\r\n' >> a.txt
$ printf '7 hello\r\n' >> a.txt
$ hg ci -m 2
$ hg --config 'patch.eol=LF' qpush
applying m1
patching file a.txt
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file a.txt.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working dir
errors during apply, please fix and refresh m1
[2]
$ hg qpop
popping m1
patch queue now empty
$ cat a.txt
4 hello\r (esc)
5 good morning\r (esc)
6 HELLO\r (esc)
7 hello\r (esc)
$ cat a.txt.rej
--- a.txt
+++ a.txt
@@ -1,4 +1,4 @@
4 hello\r (esc)
5 hello\r (esc)
-6 hello\r (esc)
+6 HELLO\r (esc)
7 hello\r (esc)
$ hg --config 'patch.eol=auto' qpush
applying m1
patching file a.txt
Hunk #1 FAILED at 0
1 out of 1 hunks FAILED -- saving rejects to file a.txt.rej
patch failed, unable to continue (try -v)
patch failed, rejects left in working dir
errors during apply, please fix and refresh m1
[2]
$ hg qpop
popping m1
patch queue now empty
$ cat a.txt
4 hello\r (esc)
5 good morning\r (esc)
6 HELLO\r (esc)
7 hello\r (esc)
$ cat a.txt.rej
--- a.txt
+++ a.txt
@@ -1,4 +1,4 @@
4 hello\r (esc)
5 hello\r (esc)
-6 hello\r (esc)
+6 HELLO\r (esc)
7 hello\r (esc)
I haven't looked into if it actually is a relevant test ;-)
/Mads
More information about the Mercurial-devel
mailing list