equal
deleted
inserted
replaced
14 num = max(todoa, todob) |
14 num = max(todoa, todob) |
15 if num == 0: |
15 if num == 0: |
16 break |
16 break |
17 for i in xrange(num): |
17 for i in xrange(num): |
18 s = fp.readline() |
18 s = fp.readline() |
19 c = s[0] |
|
20 if s == "\\ No newline at end of file\n": |
19 if s == "\\ No newline at end of file\n": |
21 fix_newline(hunk, a, b) |
20 fix_newline(hunk, a, b) |
22 continue |
21 continue |
23 if c == "\n": |
22 if s == "\n": |
24 # Some patches may be missing the control char |
23 # Some patches may be missing the control char |
25 # on empty lines. Supply a leading space. |
24 # on empty lines. Supply a leading space. |
26 s = " \n" |
25 s = " \n" |
27 hunk.append(s) |
26 hunk.append(s) |
28 if c == "+": |
27 if s.startswith('+'): |
29 b.append(s[1:]) |
28 b.append(s[1:]) |
30 elif c == "-": |
29 elif s.startswith('-'): |
31 a.append(s) |
30 a.append(s) |
32 else: |
31 else: |
33 b.append(s[1:]) |
32 b.append(s[1:]) |
34 a.append(s) |
33 a.append(s) |
35 return 0 |
34 return 0 |
39 # tolerate CRLF in last line |
38 # tolerate CRLF in last line |
40 if l.endswith('\r\n'): |
39 if l.endswith('\r\n'): |
41 hline = l[:-2] |
40 hline = l[:-2] |
42 else: |
41 else: |
43 hline = l[:-1] |
42 hline = l[:-1] |
44 c = hline[0] |
|
45 |
43 |
46 if c in " +": |
44 if hline.startswith((' ', '+')): |
47 b[-1] = hline[1:] |
45 b[-1] = hline[1:] |
48 if c in " -": |
46 if hline.startswith((' ', '-')): |
49 a[-1] = hline |
47 a[-1] = hline |
50 hunk[-1] = hline |
48 hunk[-1] = hline |
51 return 0 |
49 return 0 |
52 |
50 |
53 |
51 |