Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/diffhelper.py @ 45154:10f48720ef95
diff: move no-eol text constant to a common location
Differential Revision: https://phab.mercurial-scm.org/D8763
author | Rodrigo Damazio Bovendorp <rdamazio@google.com> |
---|---|
date | Fri, 17 Jul 2020 03:53:19 -0700 |
parents | 687b865b95ad |
children | d4ba4d51f85f |
comparison
equal
deleted
inserted
replaced
45153:8b6a446508c2 | 45154:10f48720ef95 |
---|---|
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. |