Show More
@@ -240,7 +240,7 b' def unidiff(a, ad, b, bd, fn1, fn2, opts' | |||
|
240 | 240 | l3 = "@@ -1,%d +0,0 @@\n" % len(a) |
|
241 | 241 | l = [l1, l2, l3] + ["-" + e for e in a] |
|
242 | 242 | else: |
|
243 |
l = |
|
|
243 | l = sum((hlines for hrange, hlines in _unidiff(a, b, opts=opts)), []) | |
|
244 | 244 | if not l: |
|
245 | 245 | return "" |
|
246 | 246 | |
@@ -254,7 +254,14 b' def unidiff(a, ad, b, bd, fn1, fn2, opts' | |||
|
254 | 254 | return "".join(l) |
|
255 | 255 | |
|
256 | 256 | def _unidiff(t1, t2, opts=defaultopts): |
|
257 |
"""Yield hunks of a headerless unified diff from t1 and t2 texts. |
|
|
257 | """Yield hunks of a headerless unified diff from t1 and t2 texts. | |
|
258 | ||
|
259 | Each hunk consists of a (hunkrange, hunklines) tuple where `hunkrange` is a | |
|
260 | tuple (s1, l1, s2, l2) representing the range information of the hunk to | |
|
261 | form the '@@ -s1,l1 +s2,l2 @@' header and `hunklines` is a list of lines | |
|
262 | of the hunk combining said header followed by line additions and | |
|
263 | deletions. | |
|
264 | """ | |
|
258 | 265 | l1 = splitnewlines(t1) |
|
259 | 266 | l2 = splitnewlines(t2) |
|
260 | 267 | def contextend(l, len): |
@@ -298,12 +305,13 b' def _unidiff(t1, t2, opts=defaultopts):' | |||
|
298 | 305 | if blen: |
|
299 | 306 | bstart += 1 |
|
300 | 307 | |
|
301 | yield "@@ -%d,%d +%d,%d @@%s\n" % (astart, alen, | |
|
302 | bstart, blen, func) | |
|
303 | for x in delta: | |
|
304 |
|
|
|
305 |
for x in xrange(a2, aend) |
|
|
306 | yield ' ' + l1[x] | |
|
308 | hunkrange = astart, alen, bstart, blen | |
|
309 | hunklines = ( | |
|
310 | ["@@ -%d,%d +%d,%d @@%s\n" % (hunkrange + (func,))] | |
|
311 | + delta | |
|
312 | + [' ' + l1[x] for x in xrange(a2, aend)] | |
|
313 | ) | |
|
314 | yield hunkrange, hunklines | |
|
307 | 315 | |
|
308 | 316 | # bdiff.blocks gives us the matching sequences in the files. The loop |
|
309 | 317 | # below finds the spaces between those matching sequences and translates |
General Comments 0
You need to be logged in to leave comments.
Login now