Rev 4606: Hack in a quick change to expose the new functionality to the higher levels. in http://bazaar.launchpad.net/~jameinel/bzr/1.18-faster-iter-ancestry

John Arbash Meinel john at arbash-meinel.com
Thu Aug 13 21:05:54 BST 2009


At http://bazaar.launchpad.net/~jameinel/bzr/1.18-faster-iter-ancestry

------------------------------------------------------------
revno: 4606
revision-id: john at arbash-meinel.com-20090813200547-xk9jthbsxnp9hgs4
parent: john at arbash-meinel.com-20090813195626-tlsu5cexc1q8lzmr
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.18-faster-iter-ancestry
timestamp: Thu 2009-08-13 15:05:47 -0500
message:
  Hack in a quick change to expose the new functionality to the higher levels.
  
  This changes 'time bzr log -n0 -r -10..-1' on bzr.dev from 2.7s down to 1.4s
  \o/
-------------- next part --------------
=== modified file 'bzrlib/branch.py'
--- a/bzrlib/branch.py	2009-08-04 04:36:34 +0000
+++ b/bzrlib/branch.py	2009-08-13 20:05:47 +0000
@@ -446,10 +446,18 @@
         # start_revision_id.
         if self._merge_sorted_revisions_cache is None:
             last_revision = self.last_revision()
-            graph = self.repository.get_graph()
-            parent_map = dict(((key, value) for key, value in
-                     graph.iter_ancestry([last_revision]) if value is not None))
-            revision_graph = repository._strip_NULL_ghosts(parent_map)
+            last_rev_key = (last_revision,)
+            # TODO: we need to expose this on Repository
+            find_ancestry = self.repository.revisions._index._graph_index.find_ancestry
+            parent_map, missing_keys = find_ancestry([last_rev_key], 0)
+            # We now have the graph of keys, and a list of ghosts
+            # remove ghosts because they aren't handled by merge_sort, and
+            # convert back to simple revision_ids
+            # TODO: Is it faster to do "p in parent_map" or is it faster to do
+            # "p not in missing_keys"?
+            revision_graph = dict(
+                (r[-1], [p[-1] for p in parent_ids if p in parent_map])
+                for r, parent_ids in parent_map.iteritems())
             revs = tsort.merge_sort(revision_graph, last_revision, None,
                 generate_revno=True)
             # Drop the sequence # before caching



More information about the bazaar-commits mailing list