diff options
author | W. Trevor King <wking@drexel.edu> | 2008-11-21 14:56:05 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2008-11-21 14:56:05 -0500 |
commit | 23179f50092d91dbeab97ad2b88cdaadb79b615f (patch) | |
tree | 4a5579d686c573d6d438214aa0d2100f01083bef /libbe/diff.py | |
parent | a2bdbab9ccd9ca24ce470d2beeea86afb7ede2ae (diff) | |
download | bugseverywhere-23179f50092d91dbeab97ad2b88cdaadb79b615f.tar.gz |
Another major rewrite. Now BugDir, Bug, and Comment are more distinct.
I pushed a lot of the little helper functions into the main classes,
which makes it easier for me to keep track of what's going on. I'm
now at the point where I can run through `python test.py` with each of
the backends (by changing the search order in rcs.py
_get_matching_rcs) without any unexpected errors for each backend
(except Arch). I can also run `test_usage.sh` without non-Arch errors
either.
However, don't consider this a stable commit yet. The bzr backend is
*really*slow*, and the other's aren't blazingly fast either. I think
I'm rewriting the entire database every time I save it :p. Still, it
passes the checks. and I don't like it when zounds of changes build up.
Diffstat (limited to 'libbe/diff.py')
-rw-r--r-- | libbe/diff.py | 33 |
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): |