From 5f7bf1f66d21155dfa5328aa57b4302cc64c132b Mon Sep 17 00:00:00 2001 From: Paul Eggleton Date: Fri, 7 Apr 2017 09:52:10 +1200 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/siggen.py | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'bitbake/lib/bb/siggen.py') 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 import pickle import bb.data import difflib +import simplediff from bb.checksum import FileChecksumCache logger = logging.getLogger('BitBake.SigGen') @@ -352,6 +353,39 @@ def dump_this_task(outfile, d): referencestamp = bb.build.stamp_internal(task, d, None, True) bb.parse.siggen.dump_sigtask(fn, task, outfile, "customfile:" + referencestamp) +def worddiff_str(oldstr, newstr): + diff = simplediff.diff(oldstr.split(' '), newstr.split(' ')) + ret = [] + for change, value in diff: + value = ' '.join(value) + if change == '=': + ret.append(value) + elif change == '+': + item = '{+%s+}' % value + ret.append(item) + elif change == '-': + item = '[-%s-]' % value + ret.append(item) + whitespace_note = '' + if oldstr != newstr and ' '.join(oldstr.split()) == ' '.join(newstr.split()): + whitespace_note = ' (whitespace changed)' + return '"%s"%s' % (' '.join(ret), whitespace_note) + +def list_inline_diff(oldlist, newlist): + diff = simplediff.diff(oldlist, newlist) + ret = [] + for change, value in diff: + value = ' '.join(value) + if change == '=': + ret.append("'%s'" % value) + elif change == '+': + item = "+'%s'" % value + ret.append(item) + elif change == '-': + item = "-'%s'" % value + ret.append(item) + return '[%s]' % (', '.join(ret)) + def clean_basepath(a): mc = None if a.startswith("multiconfig:"): @@ -471,6 +505,8 @@ def compare_sigfiles(a, b, recursecb=None, collapsed=False): # 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))) + elif newval and oldval and (' ' in oldval or ' ' in newval): + output.append("Variable %s value changed:\n%s" % (dep, worddiff_str(oldval, newval))) else: output.append("Variable %s value changed from '%s' to '%s'" % (dep, oldval, newval)) @@ -510,7 +546,7 @@ def compare_sigfiles(a, b, recursecb=None, collapsed=False): clean_a = clean_basepaths_list(a_data['runtaskdeps']) clean_b = clean_basepaths_list(b_data['runtaskdeps']) if clean_a != clean_b: - output.append("runtaskdeps changed from %s to %s" % (clean_a, clean_b)) + output.append("runtaskdeps changed:\n%s" % list_inline_diff(clean_a, clean_b)) else: output.append("runtaskdeps changed:") output.append("\n".join(changed)) -- cgit v1.2.3-54-g00ecf