equal
deleted
inserted
replaced
11 |
11 |
12 from . import ( |
12 from . import ( |
13 error, |
13 error, |
14 pycompat, |
14 pycompat, |
15 ) |
15 ) |
|
16 |
|
17 MISSING_NEWLINE_MARKER = b'\\ No newline at end of file\n' |
16 |
18 |
17 |
19 |
18 def addlines(fp, hunk, lena, lenb, a, b): |
20 def addlines(fp, hunk, lena, lenb, a, b): |
19 """Read lines from fp into the hunk |
21 """Read lines from fp into the hunk |
20 |
22 |
30 break |
32 break |
31 for i in pycompat.xrange(num): |
33 for i in pycompat.xrange(num): |
32 s = fp.readline() |
34 s = fp.readline() |
33 if not s: |
35 if not s: |
34 raise error.ParseError(_(b'incomplete hunk')) |
36 raise error.ParseError(_(b'incomplete hunk')) |
35 if s == b"\\ No newline at end of file\n": |
37 if s == MISSING_NEWLINE_MARKER: |
36 fixnewline(hunk, a, b) |
38 fixnewline(hunk, a, b) |
37 continue |
39 continue |
38 if s == b'\n' or s == b'\r\n': |
40 if s == b'\n' or s == b'\r\n': |
39 # Some patches may be missing the control char |
41 # Some patches may be missing the control char |
40 # on empty lines. Supply a leading space. |
42 # on empty lines. Supply a leading space. |