aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/bug.py
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-22 16:27:46 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-22 16:27:46 -0400
commit4e5dc3888699076e46bdc1d94f901ca889b88b05 (patch)
tree752955efc584d113261c5e5c865faf51113703d8 /libbe/bug.py
parent0f6e647f18a2d6165c0333cb7d123fc781c8e4e1 (diff)
downloadbugseverywhere-4e5dc3888699076e46bdc1d94f901ca889b88b05.tar.gz
Added `be list --sort *` for user-selectable sorting.
Also added libbe.bug.cmp_last_modified, which handles part of 9ce2f015-8ea0-43a5-a03d-fc36f6d202fe. To do better we could extend the RCS framework. I also transcribed a few emails from the be-devel list onto their relavent bugs and closed a few bugs. Finally, I removed some left over InvalidValue cruft.
Diffstat (limited to 'libbe/bug.py')
-rw-r--r--libbe/bug.py50
1 files changed, 34 insertions, 16 deletions
diff --git a/libbe/bug.py b/libbe/bug.py
index 8c095c5..43974dd 100644
--- a/libbe/bug.py
+++ b/libbe/bug.py
@@ -276,8 +276,8 @@ class Bug(settings_object.SavedSettingsObject):
else:
shortname = self.bugdir.bug_shortname(self)
if shortlist == False:
- if self.time_string == "":
- timestring = self.time_string
+ if self.time == None:
+ timestring = ""
else:
htime = utility.handy_time(self.time)
timestring = "%s (%s)" % (htime, self.time_string)
@@ -466,19 +466,37 @@ 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_full(bug_1, bug_2, cmp_list=(cmp_status,cmp_severity,cmp_assigned,
- cmp_time,cmp_creator)):
- for comparison in cmp_list :
- val = comparison(bug_1, bug_2)
- if val != 0 :
- return val
- return 0
-
-class InvalidValue(ValueError):
- def __init__(self, name, value):
- msg = "Cannot assign value %s to %s" % (value, name)
- Exception.__init__(self, msg)
- self.name = name
- self.value = value
+DEFAULT_CMP_FULL_CMP_LIST = \
+ (cmp_status,cmp_severity,cmp_assigned,cmp_time,cmp_creator)
+
+class BugCompoundComparator (object):
+ def __init__(self, cmp_list=DEFAULT_CMP_FULL_CMP_LIST):
+ self.cmp_list = cmp_list
+ def __call__(self, bug_1, bug_2):
+ for comparison in self.cmp_list :
+ val = comparison(bug_1, bug_2)
+ if val != 0 :
+ return val
+ return 0
+
+cmp_full = BugCompoundComparator()
+
+
+# define some bonus cmp_* functions
+def cmp_last_modified(bug_1, bug_2):
+ """
+ Like cmp_time(), but use most recent comment instead of bug
+ creation for the timestamp.
+ """
+ def last_modified(bug):
+ time = bug.time
+ for comment in bug.comment_root.traverse():
+ if comment.time > time:
+ time = comment.time
+ return time
+ val_1 = last_modified(bug_1)
+ val_2 = last_modified(bug_2)
+ return -cmp(val_1, val_2)
+
suite = doctest.DocTestSuite()