Show More
@@ -307,22 +307,14 b' def unidiff(a, ad, b, bd, fn1, fn2, opts' | |||
|
307 | 307 | hunklines.append(_missing_newline_marker) |
|
308 | 308 | hunks = (hunkrange, hunklines), |
|
309 | 309 | else: |
|
310 |
|
|
|
311 | try: | |
|
312 | hunkrange, hunklines = next(diffhunks) | |
|
313 | except StopIteration: | |
|
310 | hunks = _unidiff(a, b, opts=opts) | |
|
311 | if not next(hunks): | |
|
314 | 312 | return sentinel |
|
315 | 313 | |
|
316 | 314 | headerlines = [ |
|
317 | 315 | "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1)), |
|
318 | 316 | "+++ %s%s%s" % (bprefix, fn2, datetag(bd, fn2)), |
|
319 | 317 | ] |
|
320 | def rewindhunks(): | |
|
321 | yield hunkrange, hunklines | |
|
322 | for hr, hl in diffhunks: | |
|
323 | yield hr, hl | |
|
324 | ||
|
325 | hunks = rewindhunks() | |
|
326 | 318 | |
|
327 | 319 | return headerlines, hunks |
|
328 | 320 | |
@@ -414,6 +406,7 b' def _unidiff(t1, t2, opts=defaultopts):' | |||
|
414 | 406 | # |
|
415 | 407 | hunk = None |
|
416 | 408 | ignoredlines = 0 |
|
409 | has_hunks = False | |
|
417 | 410 | for s, stype in allblocks(t1, t2, opts, l1, l2): |
|
418 | 411 | a1, a2, b1, b2 = s |
|
419 | 412 | if stype != '!': |
@@ -440,6 +433,9 b' def _unidiff(t1, t2, opts=defaultopts):' | |||
|
440 | 433 | astart = hunk[1] |
|
441 | 434 | bstart = hunk[3] |
|
442 | 435 | else: |
|
436 | if not has_hunks: | |
|
437 | has_hunks = True | |
|
438 | yield True | |
|
443 | 439 | for x in yieldhunk(hunk): |
|
444 | 440 | yield x |
|
445 | 441 | if prev: |
@@ -456,8 +452,13 b' def _unidiff(t1, t2, opts=defaultopts):' | |||
|
456 | 452 | delta[len(delta):] = ['+' + x for x in new] |
|
457 | 453 | |
|
458 | 454 | if hunk: |
|
455 | if not has_hunks: | |
|
456 | has_hunks = True | |
|
457 | yield True | |
|
459 | 458 | for x in yieldhunk(hunk): |
|
460 | 459 | yield x |
|
460 | elif not has_hunks: | |
|
461 | yield False | |
|
461 | 462 | |
|
462 | 463 | def b85diff(to, tn): |
|
463 | 464 | '''print base85-encoded binary diff''' |
General Comments 0
You need to be logged in to leave comments.
Login now