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-07 00:51:12 +0100 |
commit | 20db6b6553c80e18afc4f43dc2495435f7477822 (patch) | |
tree | b1860aa5e1d23dc05c1cde292b5557cd89157d2e /lib/bb/siggen.py | |
parent | 6543a59b1ebd3194a7c6421cffc66ebe31a67c62 (diff) | |
download | bitbake-20db6b6553c80e18afc4f43dc2495435f7477822.tar.gz |
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.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/siggen.py')
-rw-r--r-- | lib/bb/siggen.py | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/bb/siggen.py b/lib/bb/siggen.py index 3c5d86247..d40c721fb 100644 --- a/lib/bb/siggen.py +++ b/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)) |