diff hggit/git_handler.py @ 284:12cfa77a2ab0

sort heads by commit date in topological sort
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Wed, 24 Feb 2010 17:21:25 +0100
parents 90458271e374
children 5e5aee9b32d4
line wrap: on
line diff
--- a/hggit/git_handler.py	Wed Feb 24 17:21:23 2010 +0100
+++ b/hggit/git_handler.py	Wed Feb 24 17:21:25 2010 +0100
@@ -369,6 +369,13 @@
                         seenheads.add(sha)
                         todo.append(sha)
 
+        # sort by commit date
+        def commitdate(sha):
+            obj = self.git.get_object(sha)
+            return obj.commit_time-obj.commit_timezone
+
+        todo.sort(key=commitdate, reverse=True)
+
         # traverse the heads getting a list of all the unique commits
         commits = []
         seen = set(todo)