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