Show More
@@ -274,7 +274,7 b' def unidiff(a, ad, b, bd, fn1, fn2, bina' | |||||
274 | headerlines = [] |
|
274 | headerlines = [] | |
275 | hunks = (None, ['Binary file %s has changed\n' % fn1]), |
|
275 | hunks = (None, ['Binary file %s has changed\n' % fn1]), | |
276 | elif not a: |
|
276 | elif not a: | |
277 |
without_newline = b |
|
277 | without_newline = not b.endswith('\n') | |
278 | b = splitnewlines(b) |
|
278 | b = splitnewlines(b) | |
279 | if a is None: |
|
279 | if a is None: | |
280 | l1 = '--- /dev/null%s' % datetag(epoch) |
|
280 | l1 = '--- /dev/null%s' % datetag(epoch) | |
@@ -290,7 +290,7 b' def unidiff(a, ad, b, bd, fn1, fn2, bina' | |||||
290 | hunklines.append(_missing_newline_marker) |
|
290 | hunklines.append(_missing_newline_marker) | |
291 | hunks = (hunkrange, hunklines), |
|
291 | hunks = (hunkrange, hunklines), | |
292 | elif not b: |
|
292 | elif not b: | |
293 |
without_newline = a |
|
293 | without_newline = not a.endswith('\n') | |
294 | a = splitnewlines(a) |
|
294 | a = splitnewlines(a) | |
295 | l1 = "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1)) |
|
295 | l1 = "--- %s%s%s" % (aprefix, fn1, datetag(ad, fn1)) | |
296 | if b is None: |
|
296 | if b is None: | |
@@ -383,17 +383,17 b' def _unidiff(t1, t2, opts=defaultopts):' | |||||
383 | # a newline, print only one marker. That's the only case in |
|
383 | # a newline, print only one marker. That's the only case in | |
384 | # which the hunk can end in a shared line without a newline. |
|
384 | # which the hunk can end in a shared line without a newline. | |
385 | skip = False |
|
385 | skip = False | |
386 |
if t1 |
|
386 | if not t1.endswith('\n') and astart + alen == len(l1) + 1: | |
387 | for i in xrange(len(hunklines) - 1, -1, -1): |
|
387 | for i in xrange(len(hunklines) - 1, -1, -1): | |
388 |
if hunklines[i] |
|
388 | if hunklines[i].startswith(('-', ' ')): | |
389 |
if hunklines[i] |
|
389 | if hunklines[i].startswith(' '): | |
390 | skip = True |
|
390 | skip = True | |
391 | hunklines[i] += '\n' |
|
391 | hunklines[i] += '\n' | |
392 | hunklines.insert(i + 1, _missing_newline_marker) |
|
392 | hunklines.insert(i + 1, _missing_newline_marker) | |
393 | break |
|
393 | break | |
394 |
if not skip and t2 |
|
394 | if not skip and not t2.endswith('\n') and bstart + blen == len(l2) + 1: | |
395 | for i in xrange(len(hunklines) - 1, -1, -1): |
|
395 | for i in xrange(len(hunklines) - 1, -1, -1): | |
396 |
if hunklines[i] |
|
396 | if hunklines[i].startswith('+'): | |
397 | hunklines[i] += '\n' |
|
397 | hunklines[i] += '\n' | |
398 | hunklines.insert(i + 1, _missing_newline_marker) |
|
398 | hunklines.insert(i + 1, _missing_newline_marker) | |
399 | break |
|
399 | break |
General Comments 0
You need to be logged in to leave comments.
Login now