diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2017-04-07 09:52:05 +1200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-04-10 23:00:32 +0100 |
commit | 445e622b237edebbcfd02044b2b25a311a91af8f (patch) | |
tree | 0b68678a2601000fdb1f721c82a4977ee327effe | |
parent | d88a4ade7e755cf9dd4ab2baed70cddcf4314330 (diff) | |
download | poky-445e622b237edebbcfd02044b2b25a311a91af8f.tar.gz |
bitbake: lib/bb/siggen: show a diff when dumping changes to multi-line values
When dumping changes to signatures e.g. output of bitbake -s printdiff,
if for example a function has changed, it's much more readable to see a
unified diff of the changes rather than just printing the old function
followed by the new function, so use difflib to do that.
Note: I elected to keep to one item in the returned list per change,
rather than one line per line of output, so that the caller can still
look at changes individually if needed. Thus I've added some handling to
bitbake-diffsigs to split the change into lines so that each line is
displayed indented.
(Bitbake rev: 4d254ae63a35231c98e3f73f669b040ed1144042)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bitbake/bin/bitbake-diffsigs | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/siggen.py | 12 |
2 files changed, 14 insertions, 2 deletions
diff --git a/bitbake/bin/bitbake-diffsigs b/bitbake/bin/bitbake-diffsigs index 5400e5b92b..4ca085f073 100755 --- a/bitbake/bin/bitbake-diffsigs +++ b/bitbake/bin/bitbake-diffsigs | |||
@@ -67,7 +67,9 @@ def find_compare_task(bbhandler, pn, taskname): | |||
67 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash2)) | 67 | recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash2)) |
68 | else: | 68 | else: |
69 | out2 = bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb) | 69 | out2 = bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb) |
70 | recout.extend(list(' ' + l for l in out2)) | 70 | for change in out2: |
71 | for line in change.splitlines(): | ||
72 | recout.append(' ' + line) | ||
71 | 73 | ||
72 | return recout | 74 | return recout |
73 | 75 | ||
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py index f47af6ded8..f497fb9caf 100644 --- a/bitbake/lib/bb/siggen.py +++ b/bitbake/lib/bb/siggen.py | |||
@@ -5,6 +5,7 @@ import re | |||
5 | import tempfile | 5 | import tempfile |
6 | import pickle | 6 | import pickle |
7 | import bb.data | 7 | import bb.data |
8 | import difflib | ||
8 | from bb.checksum import FileChecksumCache | 9 | from bb.checksum import FileChecksumCache |
9 | 10 | ||
10 | logger = logging.getLogger('BitBake.SigGen') | 11 | logger = logging.getLogger('BitBake.SigGen') |
@@ -462,7 +463,16 @@ def compare_sigfiles(a, b, recursecb = None): | |||
462 | changed, added, removed = dict_diff(a_data['varvals'], b_data['varvals']) | 463 | changed, added, removed = dict_diff(a_data['varvals'], b_data['varvals']) |
463 | if changed: | 464 | if changed: |
464 | for dep in changed: | 465 | for dep in changed: |
465 | output.append("Variable %s value changed from '%s' to '%s'" % (dep, a_data['varvals'][dep], b_data['varvals'][dep])) | 466 | oldval = a_data['varvals'][dep] |
467 | newval = b_data['varvals'][dep] | ||
468 | if newval and oldval and ('\n' in oldval or '\n' in newval): | ||
469 | diff = difflib.unified_diff(oldval.splitlines(), newval.splitlines(), lineterm='') | ||
470 | # Cut off the first two lines, since we aren't interested in | ||
471 | # the old/new filename (they are blank anyway in this case) | ||
472 | difflines = list(diff)[2:] | ||
473 | output.append("Variable %s value changed:\n%s" % (dep, '\n'.join(difflines))) | ||
474 | else: | ||
475 | output.append("Variable %s value changed from '%s' to '%s'" % (dep, oldval, newval)) | ||
466 | 476 | ||
467 | if not 'file_checksum_values' in a_data: | 477 | if not 'file_checksum_values' in a_data: |
468 | a_data['file_checksum_values'] = {} | 478 | a_data['file_checksum_values'] = {} |