aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/diff.py
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/diff.py')
-rw-r--r--libbe/diff.py33
1 files changed, 12 insertions, 21 deletions
diff --git a/libbe/diff.py b/libbe/diff.py
index 9fa3816..95d5607 100644
--- a/libbe/diff.py
+++ b/libbe/diff.py
@@ -20,33 +20,24 @@ from libbe.utility import time_to_str
from libbe.bug import cmp_severity
import doctest
-def diff(old_tree, new_tree):
- old_bug_map = old_tree.bug_map()
- new_bug_map = new_tree.bug_map()
+def diff(old_bugdir, new_bugdir):
added = []
removed = []
modified = []
- for old_bug in old_bug_map.itervalues():
- new_bug = new_bug_map.get(old_bug.uuid)
+ for old_bug in old_bugdir:
+ new_bug = new_bugdir.bug_map.get(old_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.has_key(new_bug.uuid):
+ for new_bug in new_bugdir:
+ if not old_bugdir.bug_map.has_key(new_bug.uuid):
added.append(new_bug)
return (removed, modified, added)
-
-def reference_diff(bugdir, revision=None):
- d = diff(bugdir.duplicate_bugdir(revision), bugdir)
- bugdir.remove_duplicate_bugdir()
- return d
-
def diff_report(diff_data, bug_dir):
(removed, modified, added) = diff_data
- bugs = list(bug_dir.list())
def modified_cmp(left, right):
return cmp_severity(left[1], right[1])
@@ -54,7 +45,7 @@ def diff_report(diff_data, bug_dir):
removed.sort(cmp_severity)
modified.sort(modified_cmp)
- if len(added) > 0:
+ if len(added) > 0:
print "New bug reports:"
for bug in added:
print bug.string(shortlist=True)
@@ -62,7 +53,7 @@ def diff_report(diff_data, bug_dir):
if len(modified) > 0:
printed = False
for old_bug, new_bug in modified:
- change_str = bug_changes(old_bug, new_bug, bugs)
+ change_str = bug_changes(old_bug, new_bug, bug_dir)
if change_str is None:
continue
if not printed:
@@ -73,7 +64,7 @@ def diff_report(diff_data, bug_dir):
if len(removed) > 0:
print "Removed bug reports:"
for bug in removed:
- print bug.string(bugs, shortlist=True)
+ print bug.string(shortlist=True)
def change_lines(old, new, attributes):
change_list = []
@@ -91,8 +82,8 @@ def bug_changes(old, new, bugs):
change_list = change_lines(old, new, ("time", "creator", "severity",
"target", "summary", "status", "assigned"))
- old_comment_ids = list(old.iter_comment_ids())
- new_comment_ids = list(new.iter_comment_ids())
+ old_comment_ids = [c.uuid for c in old.comment_root.traverse()]
+ new_comment_ids = [c.uuid for c in new.comment_root.traverse()]
change_strings = ["%s: %s -> %s" % f for f in change_list]
for comment_id in new_comment_ids:
if comment_id not in old_comment_ids:
@@ -105,8 +96,8 @@ def bug_changes(old, new, bugs):
if len(change_strings) == 0:
return None
- return "%s%s\n" % (new.string(bugs, shortlist=True),
- "\n".join(change_strings))
+ return "%s\n %s" % (new.string(shortlist=True),
+ " \n".join(change_strings))
def comment_summary(comment, status):