Show More
@@ -33,10 +33,10 b' def addlines(fp, hunk, lena, lenb, a, b)' | |||
|
33 | 33 | if s == "\\ No newline at end of file\n": |
|
34 | 34 | fixnewline(hunk, a, b) |
|
35 | 35 | continue |
|
36 |
if s == |
|
|
36 | if s == '\n' or s == '\r\n': | |
|
37 | 37 | # Some patches may be missing the control char |
|
38 | 38 | # on empty lines. Supply a leading space. |
|
39 |
s = |
|
|
39 | s = ' ' + s | |
|
40 | 40 | hunk.append(s) |
|
41 | 41 | if s.startswith('+'): |
|
42 | 42 | b.append(s[1:]) |
@@ -1,5 +1,6 b'' | |||
|
1 | 1 | $ cat > makepatch.py <<EOF |
|
2 | > f = open('eol.diff', 'wb') | |
|
2 | > import sys | |
|
3 | > f = open(sys.argv[2], 'wb') | |
|
3 | 4 | > w = f.write |
|
4 | 5 | > w(b'test message\n') |
|
5 | 6 | > w(b'diff --git a/a b/a\n') |
@@ -10,7 +11,10 b'' | |||
|
10 | 11 | > w(b'-bbb\r\n') |
|
11 | 12 | > w(b'+yyyy\r\n') |
|
12 | 13 | > w(b' cc\r\n') |
|
13 |
> w(b' \n' |
|
|
14 | > w({'empty:lf': b' \n', | |
|
15 | > 'empty:crlf': b' \r\n', | |
|
16 | > 'empty:stripped-lf': b'\n', | |
|
17 | > 'empty:stripped-crlf': b'\r\n'}[sys.argv[1]]) | |
|
14 | 18 | > w(b' d\n') |
|
15 | 19 | > w(b'-e\n') |
|
16 | 20 | > w(b'\ No newline at end of file\n') |
@@ -29,8 +33,10 b' Test different --eol values' | |||
|
29 | 33 | $ hg ci -Am adda |
|
30 | 34 | adding .hgignore |
|
31 | 35 | adding a |
|
32 | $ $PYTHON ../makepatch.py | |
|
33 | ||
|
36 | $ $PYTHON ../makepatch.py empty:lf eol.diff | |
|
37 | $ $PYTHON ../makepatch.py empty:crlf eol-empty-crlf.diff | |
|
38 | $ $PYTHON ../makepatch.py empty:stripped-lf eol-empty-stripped-lf.diff | |
|
39 | $ $PYTHON ../makepatch.py empty:stripped-crlf eol-empty-stripped-crlf.diff | |
|
34 | 40 | |
|
35 | 41 | invalid eol |
|
36 | 42 | |
@@ -45,6 +51,8 b' force LF' | |||
|
45 | 51 | |
|
46 | 52 | $ hg --traceback --config patch.eol='LF' import eol.diff |
|
47 | 53 | applying eol.diff |
|
54 | $ hg id | |
|
55 | 9e4ef7b3d4af tip | |
|
48 | 56 | $ cat a |
|
49 | 57 | a |
|
50 | 58 | yyyy |
@@ -54,6 +62,25 b' force LF' | |||
|
54 | 62 | e (no-eol) |
|
55 | 63 | $ hg st |
|
56 | 64 | |
|
65 | (test empty-line variants: all of them should generate the same revision) | |
|
66 | ||
|
67 | $ hg up -qC 0 | |
|
68 | $ hg --config patch.eol='LF' import eol-empty-crlf.diff | |
|
69 | applying eol-empty-crlf.diff | |
|
70 | $ hg id | |
|
71 | 9e4ef7b3d4af tip | |
|
72 | ||
|
73 | $ hg up -qC 0 | |
|
74 | $ hg --config patch.eol='LF' import eol-empty-stripped-lf.diff | |
|
75 | applying eol-empty-stripped-lf.diff | |
|
76 | $ hg id | |
|
77 | 9e4ef7b3d4af tip | |
|
78 | ||
|
79 | $ hg up -qC 0 | |
|
80 | $ hg --config patch.eol='LF' import eol-empty-stripped-crlf.diff | |
|
81 | applying eol-empty-stripped-crlf.diff | |
|
82 | $ hg id | |
|
83 | 9e4ef7b3d4af tip | |
|
57 | 84 | |
|
58 | 85 | force CRLF |
|
59 | 86 |
General Comments 0
You need to be logged in to leave comments.
Login now