diff options
author | Ed Bartosh <ed.bartosh@linux.intel.com> | 2017-06-13 16:12:18 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-23 11:44:12 +0100 |
commit | d72227fd2ba8eca6dbe7ba3af7b1edc19608cb7b (patch) | |
tree | 861a8a66082b69f5454835126ef56b6d3504c26f /meta/lib | |
parent | 43ceb87454f49707750833b3130c15290b12ccfd (diff) | |
download | poky-d72227fd2ba8eca6dbe7ba3af7b1edc19608cb7b.tar.gz |
buildhistory-diff: exclude paths from the output
Implemented -e/--exclude-path command line option to
exclude paths from buildhistory-diff output.
[YOCTO #11459]
(From OE-Core rev: 86393230e0ce33bf7d6d69d3019113e704081d30)
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r-- | meta/lib/oe/buildhistory_analysis.py | 51 |
1 files changed, 34 insertions, 17 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 | ||
174 | class FileChange: | 177 | class 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 | ||
511 | def process_changes(repopath, revision1, revision2='HEAD', report_all=False, report_ver=False, sigs=False, sigsdiff=False): | 514 | def 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: |