summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/lib/oe/buildhistory_analysis.py51
-rwxr-xr-xscripts/buildhistory-diff12
2 files changed, 43 insertions, 20 deletions
diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py
index 3a5b7b6b44..3e86a46a3f 100644
--- a/meta/lib/oe/buildhistory_analysis.py
+++ b/meta/lib/oe/buildhistory_analysis.py
@@ -143,22 +143,25 @@ class ChangeRecord:
143 out += '\n '.join(list(diff)[2:]) 143 out += '\n '.join(list(diff)[2:])
144 out += '\n --' 144 out += '\n --'
145 elif self.fieldname in img_monitor_files or '/image-files/' in self.path: 145 elif self.fieldname in img_monitor_files or '/image-files/' in self.path:
146 fieldname = self.fieldname 146 if self.filechanges or (self.oldvalue and self.newvalue):
147 if '/image-files/' in self.path: 147 fieldname = self.fieldname
148 fieldname = os.path.join('/' + self.path.split('/image-files/')[1], self.fieldname) 148 if '/image-files/' in self.path:
149 out = 'Changes to %s:\n ' % fieldname 149 fieldname = os.path.join('/' + self.path.split('/image-files/')[1], self.fieldname)
150 else: 150 out = 'Changes to %s:\n ' % fieldname
151 if outer: 151 else:
152 prefix = 'Changes to %s ' % self.path 152 if outer:
153 out = '(%s):\n ' % self.fieldname 153 prefix = 'Changes to %s ' % self.path
154 if self.filechanges: 154 out = '(%s):\n ' % self.fieldname
155 out += '\n '.join(['%s' % i for i in self.filechanges]) 155 if self.filechanges:
156 out += '\n '.join(['%s' % i for i in self.filechanges])
157 else:
158 alines = self.oldvalue.splitlines()
159 blines = self.newvalue.splitlines()
160 diff = difflib.unified_diff(alines, blines, fieldname, fieldname, lineterm='')
161 out += '\n '.join(list(diff))
162 out += '\n --'
156 else: 163 else:
157 alines = self.oldvalue.splitlines() 164 out = ''
158 blines = self.newvalue.splitlines()
159 diff = difflib.unified_diff(alines, blines, fieldname, fieldname, lineterm='')
160 out += '\n '.join(list(diff))
161 out += '\n --'
162 else: 165 else:
163 out = '%s changed from "%s" to "%s"' % (self.fieldname, self.oldvalue, self.newvalue) 166 out = '%s changed from "%s" to "%s"' % (self.fieldname, self.oldvalue, self.newvalue)
164 167
@@ -169,7 +172,7 @@ class ChangeRecord:
169 for line in chg._str_internal(False).splitlines(): 172 for line in chg._str_internal(False).splitlines():
170 out += '\n * %s' % line 173 out += '\n * %s' % line
171 174
172 return '%s%s' % (prefix, out) 175 return '%s%s' % (prefix, out) if out else ''
173 176
174class FileChange: 177class FileChange:
175 changetype_add = 'A' 178 changetype_add = 'A'
@@ -508,7 +511,8 @@ def compare_siglists(a_blob, b_blob, taskdiff=False):
508 return '\n'.join(out) 511 return '\n'.join(out)
509 512
510 513
511def process_changes(repopath, revision1, revision2='HEAD', report_all=False, report_ver=False, sigs=False, sigsdiff=False): 514def process_changes(repopath, revision1, revision2='HEAD', report_all=False, report_ver=False,
515 sigs=False, sigsdiff=False, exclude_path=None):
512 repo = git.Repo(repopath) 516 repo = git.Repo(repopath)
513 assert repo.bare == False 517 assert repo.bare == False
514 commit = repo.commit(revision1) 518 commit = repo.commit(revision1)
@@ -601,6 +605,19 @@ def process_changes(repopath, revision1, revision2='HEAD', report_all=False, rep
601 elif chg.path == chg2.path and chg.path.startswith('packages/') and chg2.fieldname in ['PE', 'PV', 'PR']: 605 elif chg.path == chg2.path and chg.path.startswith('packages/') and chg2.fieldname in ['PE', 'PV', 'PR']:
602 chg.related.append(chg2) 606 chg.related.append(chg2)
603 607
608 # filter out unwanted paths
609 if exclude_path:
610 for chg in changes:
611 if chg.filechanges:
612 fchgs = []
613 for fchg in chg.filechanges:
614 for epath in exclude_path:
615 if fchg.path.startswith(epath):
616 break
617 else:
618 fchgs.append(fchg)
619 chg.filechanges = fchgs
620
604 if report_all: 621 if report_all:
605 return changes 622 return changes
606 else: 623 else:
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff
index dd9745e80c..1b2e0d1f4e 100755
--- a/scripts/buildhistory-diff
+++ b/scripts/buildhistory-diff
@@ -39,6 +39,8 @@ def main():
39 parser.add_option("-S", "--signatures-with-diff", 39 parser.add_option("-S", "--signatures-with-diff",
40 help = "Report on actual signature differences instead of output (requires signature data to have been generated, either by running the actual tasks or using bitbake -S)", 40 help = "Report on actual signature differences instead of output (requires signature data to have been generated, either by running the actual tasks or using bitbake -S)",
41 action="store_true", dest="sigsdiff", default=False) 41 action="store_true", dest="sigsdiff", default=False)
42 parser.add_option("-e", "--exclude-path", action="append",
43 help = "exclude path from the output")
42 44
43 options, args = parser.parse_args(sys.argv) 45 options, args = parser.parse_args(sys.argv)
44 46
@@ -75,7 +77,7 @@ def main():
75 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n") 77 sys.stderr.write("Unable to find bitbake by searching parent directory of this script or PATH\n")
76 sys.exit(1) 78 sys.exit(1)
77 79
78 import oe.buildhistory_analysis 80 from oe.buildhistory_analysis import process_changes
79 81
80 fromrev = 'build-minus-1' 82 fromrev = 'build-minus-1'
81 torev = 'HEAD' 83 torev = 'HEAD'
@@ -92,7 +94,9 @@ def main():
92 94
93 import gitdb 95 import gitdb
94 try: 96 try:
95 changes = oe.buildhistory_analysis.process_changes(options.buildhistory_dir, fromrev, torev, options.report_all, options.report_ver, options.sigs, options.sigsdiff) 97 changes = process_changes(options.buildhistory_dir, fromrev, torev,
98 options.report_all, options.report_ver, options.sigs,
99 options.sigsdiff, options.exclude_path)
96 except gitdb.exc.BadObject as e: 100 except gitdb.exc.BadObject as e:
97 if len(args) == 1: 101 if len(args) == 1:
98 sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n") 102 sys.stderr.write("Unable to find previous build revision in buildhistory repository\n\n")
@@ -102,7 +106,9 @@ def main():
102 sys.exit(1) 106 sys.exit(1)
103 107
104 for chg in changes: 108 for chg in changes:
105 print('%s' % chg) 109 out = str(chg)
110 if out:
111 print(out)
106 112
107 sys.exit(0) 113 sys.exit(0)
108 114