Mercurial > public > mercurial-scm > hg
comparison mercurial/diffhelpers.py @ 37575:230eb9594150
diffhelpers: be more tolerant for stripped empty lines of CRLF ending
Exchange. It appears to trim lines containing only whitespace as well as
converting LF to CRLF.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 07 Apr 2018 01:37:25 +0900 |
parents | a1bcc7ff0eac |
children | 090c89a8db32 |
comparison
equal
deleted
inserted
replaced
37574:a1bcc7ff0eac | 37575:230eb9594150 |
---|---|
31 if not s: | 31 if not s: |
32 raise error.ParseError(_('incomplete hunk')) | 32 raise error.ParseError(_('incomplete hunk')) |
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:]) |
43 elif s.startswith('-'): | 43 elif s.startswith('-'): |
44 a.append(s) | 44 a.append(s) |