equal
deleted
inserted
replaced
94 return '\t%s\n' % date |
94 return '\t%s\n' % date |
95 if addtab and ' ' in fn1: |
95 if addtab and ' ' in fn1: |
96 return '\t\n' |
96 return '\t\n' |
97 return '\n' |
97 return '\n' |
98 |
98 |
99 if not a and not b: return "" |
99 if not a and not b: |
|
100 return "" |
100 epoch = util.datestr((0, 0)) |
101 epoch = util.datestr((0, 0)) |
101 |
102 |
102 if not opts.text and (util.binary(a) or util.binary(b)): |
103 if not opts.text and (util.binary(a) or util.binary(b)): |
103 if a and b and len(a) == len(b) and a == b: |
104 if a and b and len(a) == len(b) and a == b: |
104 return "" |
105 return "" |
123 l = [l1, l2, l3] + ["-" + e for e in a] |
124 l = [l1, l2, l3] + ["-" + e for e in a] |
124 else: |
125 else: |
125 al = splitnewlines(a) |
126 al = splitnewlines(a) |
126 bl = splitnewlines(b) |
127 bl = splitnewlines(b) |
127 l = list(bunidiff(a, b, al, bl, "a/" + fn1, "b/" + fn2, opts=opts)) |
128 l = list(bunidiff(a, b, al, bl, "a/" + fn1, "b/" + fn2, opts=opts)) |
128 if not l: return "" |
129 if not l: |
|
130 return "" |
129 # difflib uses a space, rather than a tab |
131 # difflib uses a space, rather than a tab |
130 l[0] = "%s%s" % (l[0][:-2], datetag(ad)) |
132 l[0] = "%s%s" % (l[0][:-2], datetag(ad)) |
131 l[1] = "%s%s" % (l[1][:-2], datetag(bd)) |
133 l[1] = "%s%s" % (l[1][:-2], datetag(bd)) |
132 |
134 |
133 for ln in xrange(len(l)): |
135 for ln in xrange(len(l)): |
180 for x in delta: |
182 for x in delta: |
181 yield x |
183 yield x |
182 for x in xrange(a2, aend): |
184 for x in xrange(a2, aend): |
183 yield ' ' + l1[x] |
185 yield ' ' + l1[x] |
184 |
186 |
185 header = [ "--- %s\t\n" % header1, "+++ %s\t\n" % header2 ] |
187 header = ["--- %s\t\n" % header1, "+++ %s\t\n" % header2] |
186 |
188 |
187 if opts.showfunc: |
189 if opts.showfunc: |
188 funcre = re.compile('\w') |
190 funcre = re.compile('\w') |
189 |
191 |
190 # bdiff.blocks gives us the matching sequences in the files. The loop |
192 # bdiff.blocks gives us the matching sequences in the files. The loop |
201 # The first match is special. |
203 # The first match is special. |
202 # we've either found a match starting at line 0 or a match later |
204 # we've either found a match starting at line 0 or a match later |
203 # in the file. If it starts later, old and new below will both be |
205 # in the file. If it starts later, old and new below will both be |
204 # empty and we'll continue to the next match. |
206 # empty and we'll continue to the next match. |
205 if i > 0: |
207 if i > 0: |
206 s = diff[i-1] |
208 s = diff[i - 1] |
207 else: |
209 else: |
208 s = [0, 0, 0, 0] |
210 s = [0, 0, 0, 0] |
209 delta = [] |
211 delta = [] |
210 a1 = s[1] |
212 a1 = s[1] |
211 a2 = s1[0] |
213 a2 = s1[0] |
244 hunk[1] = a2 |
246 hunk[1] = a2 |
245 hunk[3] = b2 |
247 hunk[3] = b2 |
246 delta = hunk[4] |
248 delta = hunk[4] |
247 else: |
249 else: |
248 # create a new hunk |
250 # create a new hunk |
249 hunk = [ astart, a2, bstart, b2, delta ] |
251 hunk = [astart, a2, bstart, b2, delta] |
250 |
252 |
251 delta[len(delta):] = [ ' ' + x for x in l1[astart:a1] ] |
253 delta[len(delta):] = [' ' + x for x in l1[astart:a1]] |
252 delta[len(delta):] = [ '-' + x for x in old ] |
254 delta[len(delta):] = ['-' + x for x in old] |
253 delta[len(delta):] = [ '+' + x for x in new ] |
255 delta[len(delta):] = ['+' + x for x in new] |
254 |
256 |
255 if hunk: |
257 if hunk: |
256 for x in yieldhunk(hunk, header): |
258 for x in yieldhunk(hunk, header): |
257 yield x |
259 yield x |
258 |
260 |