diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-04-07 09:52:10 +1200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-04-10 23:00:32 +0100 |
| commit | 5f7bf1f66d21155dfa5328aa57b4302cc64c132b (patch) | |
| tree | ce0fd73f0c03de93a367ab124b0e6a42247f7850 /bitbake/lib/bb | |
| parent | 5d8b89fc0b9a703243dcd4cce483c335effee78d (diff) | |
| download | poky-5f7bf1f66d21155dfa5328aa57b4302cc64c132b.tar.gz | |
bitbake: lib/bb/siggen: show word-diff for single-line values containing spaces
If a variable value has changed and either the new or old value contains
spaces, a word diff should be appropriate and may be a bit more readable.
Import the "simplediff" module and use it to show a word diff (in the
style of GNU wdiff and git diff --word-diff).
Also use a similar style diff to show changes in the runtaskhashes list.
I didn't use an actual word-diff here since it's a little different - we
can be sure that the list is a list and not simply a free-format string.
(Bitbake rev: 20db6b6553c80e18afc4f43dc2495435f7477822)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
| -rw-r--r-- | bitbake/lib/bb/siggen.py | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py index 3c5d86247c..d40c721fbf 100644 --- a/bitbake/lib/bb/siggen.py +++ b/bitbake/lib/bb/siggen.py | |||
| @@ -6,6 +6,7 @@ import tempfile | |||
| 6 | import pickle | 6 | import pickle |
| 7 | import bb.data | 7 | import bb.data |
| 8 | import difflib | 8 | import difflib |
| 9 | import simplediff | ||
| 9 | from bb.checksum import FileChecksumCache | 10 | from bb.checksum import FileChecksumCache |
| 10 | 11 | ||
| 11 | logger = logging.getLogger('BitBake.SigGen') | 12 | logger = logging.getLogger('BitBake.SigGen') |
| @@ -352,6 +353,39 @@ def dump_this_task(outfile, d): | |||
| 352 | referencestamp = bb.build.stamp_internal(task, d, None, True) | 353 | referencestamp = bb.build.stamp_internal(task, d, None, True) |
| 353 | bb.parse.siggen.dump_sigtask(fn, task, outfile, "customfile:" + referencestamp) | 354 | bb.parse.siggen.dump_sigtask(fn, task, outfile, "customfile:" + referencestamp) |
| 354 | 355 | ||
| 356 | def worddiff_str(oldstr, newstr): | ||
| 357 | diff = simplediff.diff(oldstr.split(' '), newstr.split(' ')) | ||
| 358 | ret = [] | ||
| 359 | for change, value in diff: | ||
| 360 | value = ' '.join(value) | ||
| 361 | if change == '=': | ||
| 362 | ret.append(value) | ||
| 363 | elif change == '+': | ||
| 364 | item = '{+%s+}' % value | ||
| 365 | ret.append(item) | ||
| 366 | elif change == '-': | ||
| 367 | item = '[-%s-]' % value | ||
| 368 | ret.append(item) | ||
| 369 | whitespace_note = '' | ||
| 370 | if oldstr != newstr and ' '.join(oldstr.split()) == ' '.join(newstr.split()): | ||
| 371 | whitespace_note = ' (whitespace changed)' | ||
| 372 | return '"%s"%s' % (' '.join(ret), whitespace_note) | ||
| 373 | |||
| 374 | def list_inline_diff(oldlist, newlist): | ||
| 375 | diff = simplediff.diff(oldlist, newlist) | ||
| 376 | ret = [] | ||
| 377 | for change, value in diff: | ||
| 378 | value = ' '.join(value) | ||
| 379 | if change == '=': | ||
| 380 | ret.append("'%s'" % value) | ||
| 381 | elif change == '+': | ||
| 382 | item = "+'%s'" % value | ||
| 383 | ret.append(item) | ||
| 384 | elif change == '-': | ||
| 385 | item = "-'%s'" % value | ||
| 386 | ret.append(item) | ||
| 387 | return '[%s]' % (', '.join(ret)) | ||
| 388 | |||
| 355 | def clean_basepath(a): | 389 | def clean_basepath(a): |
| 356 | mc = None | 390 | mc = None |
| 357 | if a.startswith("multiconfig:"): | 391 | if a.startswith("multiconfig:"): |
| @@ -471,6 +505,8 @@ def compare_sigfiles(a, b, recursecb=None, collapsed=False): | |||
| 471 | # the old/new filename (they are blank anyway in this case) | 505 | # the old/new filename (they are blank anyway in this case) |
| 472 | difflines = list(diff)[2:] | 506 | difflines = list(diff)[2:] |
| 473 | output.append("Variable %s value changed:\n%s" % (dep, '\n'.join(difflines))) | 507 | output.append("Variable %s value changed:\n%s" % (dep, '\n'.join(difflines))) |
| 508 | elif newval and oldval and (' ' in oldval or ' ' in newval): | ||
| 509 | output.append("Variable %s value changed:\n%s" % (dep, worddiff_str(oldval, newval))) | ||
| 474 | else: | 510 | else: |
| 475 | output.append("Variable %s value changed from '%s' to '%s'" % (dep, oldval, newval)) | 511 | output.append("Variable %s value changed from '%s' to '%s'" % (dep, oldval, newval)) |
| 476 | 512 | ||
| @@ -510,7 +546,7 @@ def compare_sigfiles(a, b, recursecb=None, collapsed=False): | |||
| 510 | clean_a = clean_basepaths_list(a_data['runtaskdeps']) | 546 | clean_a = clean_basepaths_list(a_data['runtaskdeps']) |
| 511 | clean_b = clean_basepaths_list(b_data['runtaskdeps']) | 547 | clean_b = clean_basepaths_list(b_data['runtaskdeps']) |
| 512 | if clean_a != clean_b: | 548 | if clean_a != clean_b: |
| 513 | output.append("runtaskdeps changed from %s to %s" % (clean_a, clean_b)) | 549 | output.append("runtaskdeps changed:\n%s" % list_inline_diff(clean_a, clean_b)) |
| 514 | else: | 550 | else: |
| 515 | output.append("runtaskdeps changed:") | 551 | output.append("runtaskdeps changed:") |
| 516 | output.append("\n".join(changed)) | 552 | output.append("\n".join(changed)) |
