From: Aaron Bentley Date: Mon, 9 May 2005 20:11:08 +0000 (+0000) Subject: Implemented bug tree diff X-Git-Tag: 1.0.0~297 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f72535d9a4d1e8143b0ae68e097adef2dabc73bf;p=be.git Implemented bug tree diff Modified bug reports: f5c: Implement bug tree diff status: open -> closed --- diff --git a/.be/bugs/f5c06914-dc64-4658-8ec7-32a026a53f55/values b/.be/bugs/f5c06914-dc64-4658-8ec7-32a026a53f55/values index 0d27be1..233e336 100644 --- a/.be/bugs/f5c06914-dc64-4658-8ec7-32a026a53f55/values +++ b/.be/bugs/f5c06914-dc64-4658-8ec7-32a026a53f55/values @@ -15,7 +15,7 @@ severity=minor -status=open +status=closed diff --git a/libbe/diff.py b/libbe/diff.py index 3c348a0..70bda69 100644 --- a/libbe/diff.py +++ b/libbe/diff.py @@ -38,15 +38,40 @@ def diff_report(diff_data, bug_dir): for bug in added: print cmdutil.bug_summary(bug, bugs, no_target=True) - if len(modified) > 0 and False: - print "modified bug reports:" - for old_bug, new_bug in modified: - print cmdutil.bug_summary(new_bug, bugs, no_target=True) + if len(modified) > 0: + printed = False + for old_bug, new_bug in modified: + change_str = bug_changes(old_bug, new_bug, bugs) + if change_str is None: + continue + if not printed: + printed = True + print "Modified bug reports:" + print change_str if len(removed) > 0: print "Removed bug reports:" for bug in removed: print cmdutil.bug_summary(bug, bugs, no_target=True) +def change_lines(old, new, attributes): + change_list = [] + for attr in attributes: + old_attr = getattr(old, attr) + new_attr = getattr(new, attr) + if old_attr != new_attr: + change_list.append("%s: %s -> %s" % (attr, old_attr, new_attr)) + if len(change_list) >= 0: + return change_list + else: + return None + +def bug_changes(old, new, bugs): + change_list = change_lines(old, new, ("time", "creator", "severity", + "target", "summary", "status", "assigned")) + if len(change_list) == 0: + return None + return "%s%s\n" % (cmdutil.bug_summary(new, bugs, shortlist=True), + "\n".join(change_list))