Sort comments in `be html`.
authorW. Trevor King <wking@drexel.edu>
Tue, 2 Feb 2010 19:11:14 +0000 (14:11 -0500)
committerW. Trevor King <wking@drexel.edu>
Tue, 2 Feb 2010 19:11:14 +0000 (14:11 -0500)
libbe/command/html.py
libbe/comment.py

index 47ee587b565d1d3eca3d566aa3a57f9804417fdb..ebf5034f69b22ee814c2be309297615664698b9c 100644 (file)
@@ -27,6 +27,7 @@ import xml.sax.saxutils
 import libbe
 import libbe.command
 import libbe.command.util
+import libbe.comment
 import libbe.util.encoding
 import libbe.util.id
 
@@ -212,6 +213,7 @@ class HTMLGen (object):
 
         stack = []
         comment_entries = []
+        bug.comment_root.sort(cmp=libbe.comment.cmp_time, reverse=True)
         for depth,comment in bug.comment_root.thread(flatten=False):
             while len(stack) > depth:
                 # pop non-parents off the stack
index a6a4ebdea305dd9008aa2ef568adce939c9ccb89..dd245de558bfa69f0002cbf42f20c7f6c17ed833 100644 (file)
@@ -523,14 +523,6 @@ class Comment (Tree, settings_object.SavedSettingsObject):
         Comment in the thread.  The method must take the arguments
         indent and shortname.
 
-        SIDE-EFFECT: if auto_name_map==True, calls comment_shortnames()
-        which will sort the tree by comment.time.  Avoid by calling
-          name_map = {}
-          for shortname,comment in comm.comment_shortnames(bug_shortname):
-              name_map[comment.uuid] = shortname
-          comm.sort(key=lambda c : c.author) # your sort
-          comm.string_thread(name_map=name_map)
-
         >>> a = Comment(bug=None, uuid="a", body="Insightful remarks")
         >>> a.time = utility.str_to_time("Thu, 20 Nov 2008 01:00:00 +0000")
         >>> b = a.new_reply("Critique original comment")