aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/template
diff options
context:
space:
mode:
authorAaron Bentley <abentley@panoramicfeedback.com>2005-04-14 18:07:49 +0000
committerAaron Bentley <abentley@panoramicfeedback.com>2005-04-14 18:07:49 +0000
commit16a391aaf9d3934f7297b7a8fb87184cf555882f (patch)
treeb016864fd16dcbaaba1ab09ec0a6668dddcaa60b /libbe/template
parent82c1e85e1845d33b8e552c9f832f91d032466036 (diff)
downloadbugseverywhere-16a391aaf9d3934f7297b7a8fb87184cf555882f.tar.gz
Added preliminary tree-diffing support
Diffstat (limited to 'libbe/template')
-rw-r--r--libbe/template48
1 files changed, 48 insertions, 0 deletions
diff --git a/libbe/template b/libbe/template
new file mode 100644
index 0000000..467eee4
--- /dev/null
+++ b/libbe/template
@@ -0,0 +1,48 @@
+"""Compare two bug trees"""
+from bugdir import cmdutil
+
+def diff(old_tree, new_tree):
+ old_bug_map = old_tree.bug_map()
+ new_bug_map = new_tree.bug_map()
+ added = []
+ removed = []
+ modified = []
+ for old_bug in old_bug_map.itervalues():
+ new_bug = new_bug_map.get(bug.uuid)
+ if new_bug is None :
+ removed.append(old_bug)
+ else:
+ if old_bug != new_bug:
+ modified.append((old_bug, new_bug))
+ for new_bug in new_bug_map.itervalues():
+ if not old_bug_map.haskey(new_bug.id):
+ added.append(new_bug)
+ return (removed, modified, added)
+
+
+def reference_diff(bugdir, spec=None):
+ return diff(bugdir.reference_bugdir(), bugdir)
+
+def diff_report(diff_data, bugdir)
+ (removed, modified, added) = diff_data
+ def modified_cmp(left, right):
+ return cmp_severity(left[1], right[1])
+
+ added.sort(bugdir.cmp_severity)
+ removed.sort(bugdir.cmp_severity)
+ modified.sort(modified_cmp)
+
+ print "New bug reports:"
+ for bug in added:
+ cmdutil.bug_summary(bug, bugdir, no_target=True)
+
+ print "modified bug reports:"
+ for old_bug, new_bug in modified:
+ cmdutil.bug_summary(new_bug, bugdir, no_target=True)
+
+ print "Removed bug reports:"
+ for bug in removed:
+ cmdutil.bug_summary(bug, bugdir, no_target=True)
+
+
+