diff options
| -rw-r--r-- | meta/lib/oe/buildhistory_analysis.py | 30 | ||||
| -rwxr-xr-x | scripts/buildhistory-diff | 9 |
2 files changed, 32 insertions, 7 deletions
diff --git a/meta/lib/oe/buildhistory_analysis.py b/meta/lib/oe/buildhistory_analysis.py index 3e86a46a3f..c05841b804 100644 --- a/meta/lib/oe/buildhistory_analysis.py +++ b/meta/lib/oe/buildhistory_analysis.py | |||
| @@ -40,6 +40,26 @@ related_fields['PKGSIZE'] = ['FILELIST'] | |||
| 40 | related_fields['files-in-image.txt'] = ['installed-package-names.txt', 'USER_CLASSES', 'IMAGE_CLASSES', 'ROOTFS_POSTPROCESS_COMMAND', 'IMAGE_POSTPROCESS_COMMAND'] | 40 | related_fields['files-in-image.txt'] = ['installed-package-names.txt', 'USER_CLASSES', 'IMAGE_CLASSES', 'ROOTFS_POSTPROCESS_COMMAND', 'IMAGE_POSTPROCESS_COMMAND'] |
| 41 | related_fields['installed-package-names.txt'] = ['IMAGE_FEATURES', 'IMAGE_LINGUAS', 'IMAGE_INSTALL', 'BAD_RECOMMENDATIONS', 'NO_RECOMMENDATIONS', 'PACKAGE_EXCLUDE'] | 41 | related_fields['installed-package-names.txt'] = ['IMAGE_FEATURES', 'IMAGE_LINGUAS', 'IMAGE_INSTALL', 'BAD_RECOMMENDATIONS', 'NO_RECOMMENDATIONS', 'PACKAGE_EXCLUDE'] |
| 42 | 42 | ||
| 43 | colours = { | ||
| 44 | 'colour_default': '', | ||
| 45 | 'colour_add': '', | ||
| 46 | 'colour_remove': '', | ||
| 47 | } | ||
| 48 | |||
| 49 | def init_colours(use_colours): | ||
| 50 | global colours | ||
| 51 | if use_colours: | ||
| 52 | colours = { | ||
| 53 | 'colour_default': '\033[0m', | ||
| 54 | 'colour_add': '\033[1;32m', | ||
| 55 | 'colour_remove': '\033[1;31m', | ||
| 56 | } | ||
| 57 | else: | ||
| 58 | colours = { | ||
| 59 | 'colour_default': '', | ||
| 60 | 'colour_add': '', | ||
| 61 | 'colour_remove': '', | ||
| 62 | } | ||
| 43 | 63 | ||
| 44 | class ChangeRecord: | 64 | class ChangeRecord: |
| 45 | def __init__(self, path, fieldname, oldvalue, newvalue, monitored): | 65 | def __init__(self, path, fieldname, oldvalue, newvalue, monitored): |
| @@ -110,9 +130,9 @@ class ChangeRecord: | |||
| 110 | lines.append('removed all items "%s"' % ' '.join(removed)) | 130 | lines.append('removed all items "%s"' % ' '.join(removed)) |
| 111 | else: | 131 | else: |
| 112 | if removed: | 132 | if removed: |
| 113 | lines.append('removed "%s"' % ' '.join(removed)) | 133 | lines.append('removed "{colour_remove}{value}{colour_default}"'.format(value=' '.join(removed), **colours)) |
| 114 | if added: | 134 | if added: |
| 115 | lines.append('added "%s"' % ' '.join(added)) | 135 | lines.append('added "{colour_add}{value}{colour_default}"'.format(value=' '.join(added), **colours)) |
| 116 | else: | 136 | else: |
| 117 | lines.append('changed order') | 137 | lines.append('changed order') |
| 118 | 138 | ||
| @@ -125,9 +145,9 @@ class ChangeRecord: | |||
| 125 | percentchg = ((bval - aval) / float(aval)) * 100 | 145 | percentchg = ((bval - aval) / float(aval)) * 100 |
| 126 | else: | 146 | else: |
| 127 | percentchg = 100 | 147 | percentchg = 100 |
| 128 | out = '%s changed from %s to %s (%s%d%%)' % (self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg) | 148 | out = '{} changed from {colour_remove}{}{colour_default} to {colour_add}{}{colour_default} ({}{:.0f}%)'.format(self.fieldname, self.oldvalue or "''", self.newvalue or "''", '+' if percentchg > 0 else '', percentchg, **colours) |
| 129 | elif self.fieldname in defaultval_map: | 149 | elif self.fieldname in defaultval_map: |
| 130 | out = '%s changed from %s to %s' % (self.fieldname, self.oldvalue, self.newvalue) | 150 | out = '{} changed from {colour_remove}{}{colour_default} to {colour_add}{}{colour_default}'.format(self.fieldname, self.oldvalue, self.newvalue, **colours) |
| 131 | if self.fieldname == 'PKG' and '[default]' in self.newvalue: | 151 | if self.fieldname == 'PKG' and '[default]' in self.newvalue: |
| 132 | out += ' - may indicate debian renaming failure' | 152 | out += ' - may indicate debian renaming failure' |
| 133 | elif self.fieldname in ['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']: | 153 | elif self.fieldname in ['pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm']: |
| @@ -163,7 +183,7 @@ class ChangeRecord: | |||
| 163 | else: | 183 | else: |
| 164 | out = '' | 184 | out = '' |
| 165 | else: | 185 | else: |
| 166 | out = '%s changed from "%s" to "%s"' % (self.fieldname, self.oldvalue, self.newvalue) | 186 | out = '{} changed from "{colour_remove}{}{colour_default}" to "{colour_add}{}{colour_default}"'.format(self.fieldname, self.oldvalue, self.newvalue, **colours) |
| 167 | 187 | ||
| 168 | if self.related: | 188 | if self.related: |
| 169 | for chg in self.related: | 189 | for chg in self.related: |
diff --git a/scripts/buildhistory-diff b/scripts/buildhistory-diff index e79cb7ac8d..27974072fc 100755 --- a/scripts/buildhistory-diff +++ b/scripts/buildhistory-diff | |||
| @@ -53,6 +53,10 @@ def get_args_parser(): | |||
| 53 | parser.add_argument('-e', '--exclude-path', | 53 | parser.add_argument('-e', '--exclude-path', |
| 54 | action='append', | 54 | action='append', |
| 55 | help="Exclude path from the output") | 55 | help="Exclude path from the output") |
| 56 | parser.add_argument('-c', '--colour', | ||
| 57 | choices=('yes', 'no', 'auto'), | ||
| 58 | default="auto", | ||
| 59 | help="Whether to colourise (defaults to auto)") | ||
| 56 | parser.add_argument('revisions', | 60 | parser.add_argument('revisions', |
| 57 | default = ['build-minus-1', 'HEAD'], | 61 | default = ['build-minus-1', 'HEAD'], |
| 58 | nargs='*', | 62 | nargs='*', |
| @@ -107,10 +111,11 @@ def main(): | |||
| 107 | elif len(args.revisions) == 2: | 111 | elif len(args.revisions) == 2: |
| 108 | fromrev, torev = args.revisions | 112 | fromrev, torev = args.revisions |
| 109 | 113 | ||
| 110 | from oe.buildhistory_analysis import process_changes | 114 | from oe.buildhistory_analysis import init_colours, process_changes |
| 111 | |||
| 112 | import gitdb | 115 | import gitdb |
| 113 | 116 | ||
| 117 | init_colours({"yes": True, "no": False, "auto": sys.stdout.isatty()}[args.colour]) | ||
| 118 | |||
| 114 | try: | 119 | try: |
| 115 | changes = process_changes(args.buildhistory_dir, fromrev, torev, | 120 | changes = process_changes(args.buildhistory_dir, fromrev, torev, |
| 116 | args.report_all, args.report_ver, args.sigs, | 121 | args.report_all, args.report_ver, args.sigs, |
