aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/diff.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-27 07:18:13 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-27 07:18:13 -0400
commit159dc9303e10cef81388fb686f79312cc1018c65 (patch)
tree4924ec024c891631077f37ef1d8c853f17a53c66 /libbe/diff.py
parent3711c5080619b0decf0ae040a9d244bf3b902c41 (diff)
downloadbugseverywhere-159dc9303e10cef81388fb686f79312cc1018c65.tar.gz
Added cmp functions to libbe.comment, and fleshed them out in libbe.bug.
Previous comment comparison had just been the default Tree.__cmp__. Fleshed out so A == B ensures no meaningful differences between A and B. Also added first line of comments to new comment output in libbe.diff, and added a comment/"settings" node and .comment_mod_string() (to mirror bugdir and bug).
Diffstat (limited to 'libbe/diff.py')
-rw-r--r--libbe/diff.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/libbe/diff.py b/libbe/diff.py
index decbcf5..4164e94 100644
--- a/libbe/diff.py
+++ b/libbe/diff.py
@@ -216,13 +216,13 @@ class Diff (object):
if not self.new_bugdir.has_bug(uuid):
old_bug = self.old_bugdir.bug_from_uuid(uuid)
removed.append(old_bug)
- added.sort(bug.cmp_severity)
- removed.sort(bug.cmp_severity)
+ added.sort()
+ removed.sort()
modified.sort(self._bug_modified_cmp)
self.__changed_bugs = (added, modified, removed)
return self.__changed_bugs
def _bug_modified_cmp(self, left, right):
- return bug.cmp_severity(left[1], right[1])
+ return cmp(left[1], right[1])
def _changed_comments(self, old, new):
"""
Search for differences in all loaded comments between the bugs
@@ -348,9 +348,12 @@ class Diff (object):
crem.append(c)
cmod = diff_tree("mod","Modified comments:",requires_children=True)
for o,n in m:
- c = diff_tree(n.uuid, self._comment_attribute_changes(o, n),
- self.comment_attribute_change_string)
+ c = diff_tree(n.uuid, (o,n), self.comment_mod_string)
cmod.append(c)
+ comm_attribute_changes = self._comment_attribute_changes(o, n)
+ if len(comm_attribute_changes) > 0:
+ cset = diff_tree("settings", comm_attribute_changes,
+ self.comment_attribute_change_string)
if o.body != n.body:
data = (o.body, n.body)
cbody = diff_tree("cbody", data,
@@ -391,9 +394,14 @@ class Diff (object):
def _comment_summary_string(self, comment):
return "from %s on %s" % (comment.author, time_to_str(comment.time))
def comment_add_string(self, comment):
- return self._comment_summary_string(comment)
+ summary = self._comment_summary_string(comment)
+ first_line = comment.body.splitlines()[0]
+ return "%s\n %s..." % (summary, first_line)
def comment_rem_string(self, comment):
return self._comment_summary_string(comment)
+ def comment_mod_string(self, comments):
+ old_comment,new_comment = comments
+ return self._comment_summary_string(new_comment)
def comment_body_change_string(self, bodies):
old_body,new_body = bodies
return difflib.unified_diff(old_body, new_body)