summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2017-04-07 09:52:05 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-04-07 00:51:12 +0100
commit4d254ae63a35231c98e3f73f669b040ed1144042 (patch)
treec743e9a5e1ef885b93d7abcabe7cb745b0cdc51e
parentf0d7ab259d8ef95643e7229474b7850608aa4426 (diff)
downloadbitbake-contrib-4d254ae63a35231c98e3f73f669b040ed1144042.tar.gz
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. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xbin/bitbake-diffsigs4
-rw-r--r--lib/bb/siggen.py12
2 files changed, 14 insertions, 2 deletions
diff --git a/bin/bitbake-diffsigs b/bin/bitbake-diffsigs
index 5400e5b92..4ca085f07 100755
--- a/bin/bitbake-diffsigs
+++ b/bin/bitbake-diffsigs
@@ -67,7 +67,9 @@ def find_compare_task(bbhandler, pn, taskname):
recout.append("Unable to find matching sigdata for %s with hash %s" % (key, hash2))
else:
out2 = bb.siggen.compare_sigfiles(hashfiles[hash1], hashfiles[hash2], recursecb)
- recout.extend(list(' ' + l for l in out2))
+ for change in out2:
+ for line in change.splitlines():
+ recout.append(' ' + line)
return recout
diff --git a/lib/bb/siggen.py b/lib/bb/siggen.py
index f47af6ded..f497fb9ca 100644
--- a/lib/bb/siggen.py
+++ b/lib/bb/siggen.py
@@ -5,6 +5,7 @@ import re
import tempfile
import pickle
import bb.data
+import difflib
from bb.checksum import FileChecksumCache
logger = logging.getLogger('BitBake.SigGen')
@@ -462,7 +463,16 @@ def compare_sigfiles(a, b, recursecb = None):
changed, added, removed = dict_diff(a_data['varvals'], b_data['varvals'])
if changed:
for dep in changed:
- output.append("Variable %s value changed from '%s' to '%s'" % (dep, a_data['varvals'][dep], b_data['varvals'][dep]))
+ oldval = a_data['varvals'][dep]
+ newval = b_data['varvals'][dep]
+ if newval and oldval and ('\n' in oldval or '\n' in newval):
+ diff = difflib.unified_diff(oldval.splitlines(), newval.splitlines(), lineterm='')
+ # Cut off the first two lines, since we aren't interested in
+ # the old/new filename (they are blank anyway in this case)
+ difflines = list(diff)[2:]
+ output.append("Variable %s value changed:\n%s" % (dep, '\n'.join(difflines)))
+ else:
+ output.append("Variable %s value changed from '%s' to '%s'" % (dep, oldval, newval))
if not 'file_checksum_values' in a_data:
a_data['file_checksum_values'] = {}