##// END OF EJS Templates
diffhelpers: be more tolerant for stripped empty lines of CRLF ending...
Yuya Nishihara -
r37593:230eb959 default
parent child Browse files
Show More
@@ -33,10 +33,10 b' def addlines(fp, hunk, lena, lenb, a, b)'
33 if s == "\\ No newline at end of file\n":
33 if s == "\\ No newline at end of file\n":
34 fixnewline(hunk, a, b)
34 fixnewline(hunk, a, b)
35 continue
35 continue
36 if s == "\n":
36 if s == '\n' or s == '\r\n':
37 # Some patches may be missing the control char
37 # Some patches may be missing the control char
38 # on empty lines. Supply a leading space.
38 # on empty lines. Supply a leading space.
39 s = " \n"
39 s = ' ' + s
40 hunk.append(s)
40 hunk.append(s)
41 if s.startswith('+'):
41 if s.startswith('+'):
42 b.append(s[1:])
42 b.append(s[1:])
@@ -1,5 +1,6 b''
1 $ cat > makepatch.py <<EOF
1 $ cat > makepatch.py <<EOF
2 > f = open('eol.diff', 'wb')
2 > import sys
3 > f = open(sys.argv[2], 'wb')
3 > w = f.write
4 > w = f.write
4 > w(b'test message\n')
5 > w(b'test message\n')
5 > w(b'diff --git a/a b/a\n')
6 > w(b'diff --git a/a b/a\n')
@@ -10,7 +11,10 b''
10 > w(b'-bbb\r\n')
11 > w(b'-bbb\r\n')
11 > w(b'+yyyy\r\n')
12 > w(b'+yyyy\r\n')
12 > w(b' cc\r\n')
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 > w(b' d\n')
18 > w(b' d\n')
15 > w(b'-e\n')
19 > w(b'-e\n')
16 > w(b'\ No newline at end of file\n')
20 > w(b'\ No newline at end of file\n')
@@ -29,8 +33,10 b' Test different --eol values'
29 $ hg ci -Am adda
33 $ hg ci -Am adda
30 adding .hgignore
34 adding .hgignore
31 adding a
35 adding a
32 $ $PYTHON ../makepatch.py
36 $ $PYTHON ../makepatch.py empty:lf eol.diff
33
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 invalid eol
41 invalid eol
36
42
@@ -45,6 +51,8 b' force LF'
45
51
46 $ hg --traceback --config patch.eol='LF' import eol.diff
52 $ hg --traceback --config patch.eol='LF' import eol.diff
47 applying eol.diff
53 applying eol.diff
54 $ hg id
55 9e4ef7b3d4af tip
48 $ cat a
56 $ cat a
49 a
57 a
50 yyyy
58 yyyy
@@ -54,6 +62,25 b' force LF'
54 e (no-eol)
62 e (no-eol)
55 $ hg st
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 force CRLF
85 force CRLF
59
86
General Comments 0
You need to be logged in to leave comments. Login now