aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bug.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-23 09:59:14 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-23 09:59:14 -0400
commit0cdbb498a29d32b5d2d0a182079ed6cd5ddb7641 (patch)
tree842cf6124be99d095ddad6bc04755d858d1c8540 /libbe/bug.py
parent1ebad91e41ec011e734ccc555bcbe90b4c907d1a (diff)
downloadbugseverywhere-0cdbb498a29d32b5d2d0a182079ed6cd5ddb7641.tar.gz
Added libbe.bug.cmp_comments(), and added that to default bug comparison.
Diffstat (limited to 'libbe/bug.py')
-rw-r--r--libbe/bug.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/libbe/bug.py b/libbe/bug.py
index f3448e2..c1e5481 100644
--- a/libbe/bug.py
+++ b/libbe/bug.py
@@ -494,8 +494,25 @@ cmp_assigned = lambda bug_1, bug_2 : cmp_attr(bug_1, bug_2, "assigned")
# chronological rankings (newer < older)
cmp_time = lambda bug_1, bug_2 : cmp_attr(bug_1, bug_2, "time", invert=True)
+def cmp_comments(bug_1, bug_2):
+ """
+ Compare two bugs' comments lists. Doesn't load any new comments,
+ so you should call each bug's .load_comments() first if you want a
+ full comparison.
+ """
+ comms_1 = sorted(bug_1.comments(), key = lambda comm : comm.uuid)
+ comms_2 = sorted(bug_2.comments(), key = lambda comm : comm.uuid)
+ result = cmp(len(comms_1), len(comms_2))
+ if result != 0:
+ return result
+ for c_1,c_2 in zip(comms_1, comms_2):
+ result = cmp(c_1, c_2)
+ if result != 0:
+ return result
+ return 0
+
DEFAULT_CMP_FULL_CMP_LIST = \
- (cmp_status,cmp_severity,cmp_assigned,cmp_time,cmp_creator)
+ (cmp_status,cmp_severity,cmp_assigned,cmp_time,cmp_creator,cmp_comments)
class BugCompoundComparator (object):
def __init__(self, cmp_list=DEFAULT_CMP_FULL_CMP_LIST):