equal
deleted
inserted
replaced
11 |
11 |
12 from . import ( |
12 from . import ( |
13 error, |
13 error, |
14 pycompat, |
14 pycompat, |
15 ) |
15 ) |
|
16 |
16 |
17 |
17 def addlines(fp, hunk, lena, lenb, a, b): |
18 def addlines(fp, hunk, lena, lenb, a, b): |
18 """Read lines from fp into the hunk |
19 """Read lines from fp into the hunk |
19 |
20 |
20 The hunk is parsed into two arrays, a and b. a gets the old state of |
21 The hunk is parsed into two arrays, a and b. a gets the old state of |
45 a.append(s) |
46 a.append(s) |
46 else: |
47 else: |
47 b.append(s[1:]) |
48 b.append(s[1:]) |
48 a.append(s) |
49 a.append(s) |
49 |
50 |
|
51 |
50 def fixnewline(hunk, a, b): |
52 def fixnewline(hunk, a, b): |
51 """Fix up the last lines of a and b when the patch has no newline at EOF""" |
53 """Fix up the last lines of a and b when the patch has no newline at EOF""" |
52 l = hunk[-1] |
54 l = hunk[-1] |
53 # tolerate CRLF in last line |
55 # tolerate CRLF in last line |
54 if l.endswith('\r\n'): |
56 if l.endswith('\r\n'): |
60 b[-1] = hline[1:] |
62 b[-1] = hline[1:] |
61 if hline.startswith((' ', '-')): |
63 if hline.startswith((' ', '-')): |
62 a[-1] = hline |
64 a[-1] = hline |
63 hunk[-1] = hline |
65 hunk[-1] = hline |
64 |
66 |
|
67 |
65 def testhunk(a, b, bstart): |
68 def testhunk(a, b, bstart): |
66 """Compare the lines in a with the lines in b |
69 """Compare the lines in a with the lines in b |
67 |
70 |
68 a is assumed to have a control char at the start of each line, this char |
71 a is assumed to have a control char at the start of each line, this char |
69 is ignored in the compare. |
72 is ignored in the compare. |