From 60163698839aaac434dbda848a92326fab7cdf6c Mon Sep 17 00:00:00 2001 From: Aaron Bentley Date: Fri, 31 Mar 2006 17:53:50 -0500 Subject: Implemented basic comment diff --- .../37650981-1908-4c39-bae2-48e69c771120/body | 1 + .../37650981-1908-4c39-bae2-48e69c771120/values | 14 ++++++++++++++ libbe/diff.py | 21 +++++++++++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 .be/bugs/9a942b1d-a3b5-441d-8aef-b844700e1efa/comments/37650981-1908-4c39-bae2-48e69c771120/body create mode 100644 .be/bugs/9a942b1d-a3b5-441d-8aef-b844700e1efa/comments/37650981-1908-4c39-bae2-48e69c771120/values diff --git a/.be/bugs/9a942b1d-a3b5-441d-8aef-b844700e1efa/comments/37650981-1908-4c39-bae2-48e69c771120/body b/.be/bugs/9a942b1d-a3b5-441d-8aef-b844700e1efa/comments/37650981-1908-4c39-bae2-48e69c771120/body new file mode 100644 index 0000000..a27ff59 --- /dev/null +++ b/.be/bugs/9a942b1d-a3b5-441d-8aef-b844700e1efa/comments/37650981-1908-4c39-bae2-48e69c771120/body @@ -0,0 +1 @@ +Hmm. This is already done... diff --git a/.be/bugs/9a942b1d-a3b5-441d-8aef-b844700e1efa/comments/37650981-1908-4c39-bae2-48e69c771120/values b/.be/bugs/9a942b1d-a3b5-441d-8aef-b844700e1efa/comments/37650981-1908-4c39-bae2-48e69c771120/values new file mode 100644 index 0000000..a282359 --- /dev/null +++ b/.be/bugs/9a942b1d-a3b5-441d-8aef-b844700e1efa/comments/37650981-1908-4c39-bae2-48e69c771120/values @@ -0,0 +1,14 @@ + + + +Date=Fri, 31 Mar 2006 22:15:09 +0000 + + + + + + +From=abentley + + + diff --git a/libbe/diff.py b/libbe/diff.py index 82dc219..c1dc429 100644 --- a/libbe/diff.py +++ b/libbe/diff.py @@ -16,6 +16,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Compare two bug trees""" from libbe import cmdutil, bugdir +from libbe.utility import time_to_str def diff(old_tree, new_tree): old_bug_map = old_tree.bug_map() @@ -85,9 +86,25 @@ def change_lines(old, new, attributes): def bug_changes(old, new, bugs): change_list = change_lines(old, new, ("time", "creator", "severity", "target", "summary", "status", "assigned")) - if len(change_list) == 0: + + old_comment_ids = list(old.iter_comment_ids()) + new_comment_ids = list(new.iter_comment_ids()) + 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: + summary = comment_summary(new.get_comment(comment_id), "new") + change_strings.append(summary) + for comment_id in old_comment_ids: + if comment_id not in new_comment_ids: + summary = comment_summary(new.get_comment(comment_id), "removed") + change_strings.append(summary) + + if len(change_strings) == 0: return None return "%s%s\n" % (cmdutil.bug_summary(new, bugs, shortlist=True), - "\n".join(["%s: %s -> %s" % f for f in change_list])) + "\n".join(change_strings)) +def comment_summary(comment, status): + return "%8s comment from %s on %s" % (status, comment.From, + time_to_str(comment.date)) -- cgit