Rev 4495: Cache the heads provider as long as we know that the parent_map hasn't changed. in http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate
John Arbash Meinel
john at arbash-meinel.com
Tue Jun 23 20:58:56 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/1.17-rework-annotate
------------------------------------------------------------
revno: 4495
revision-id: john at arbash-meinel.com-20090623195852-y7qc5ps9yprfytzi
parent: john at arbash-meinel.com-20090623195509-droznp814bg3um3r
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.17-rework-annotate
timestamp: Tue 2009-06-23 14:58:52 -0500
message:
Cache the heads provider as long as we know that the parent_map hasn't changed.
-------------- next part --------------
=== modified file 'bzrlib/_annotator_py.py'
--- a/bzrlib/_annotator_py.py 2009-06-23 19:55:09 +0000
+++ b/bzrlib/_annotator_py.py 2009-06-23 19:58:52 +0000
@@ -40,6 +40,7 @@
# Map from key => number of nexts that will be built from this key
self._num_needed_children = {}
self._annotations_cache = {}
+ self._heads_provider = None
def _get_needed_keys(self, key):
graph = _mod_graph.Graph(self._vf)
@@ -57,6 +58,9 @@
else:
self._num_needed_children[parent_key] = 1
self._parent_map.update(parent_map)
+ # _heads_provider does some graph caching, so it is only valid while
+ # self._parent_map hasn't changed
+ self._heads_provider = None
keys = parent_map.keys()
return keys
@@ -197,6 +201,11 @@
raise errors.RevisionNotPresent(key, self._vf)
return annotations, self._text_cache[key]
+ def _get_heads_provider(self):
+ if self._heads_provider is None:
+ self._heads_provider = _mod_graph.KnownGraph(self._parent_map)
+ return self._heads_provider
+
def annotate_flat(self, key):
"""Determine the single-best-revision to source for each line.
@@ -205,8 +214,7 @@
annotations, lines = self.annotate(key)
assert len(annotations) == len(lines)
out = []
- graph = _mod_graph.KnownGraph(self._parent_map)
- heads = graph.heads
+ heads = self._get_heads_provider().heads
append = out.append
for annotation, line in zip(annotations, lines):
if len(annotation) == 1:
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2009-06-23 19:39:42 +0000
+++ b/bzrlib/knit.py 2009-06-23 19:58:52 +0000
@@ -3391,6 +3391,7 @@
(index_memo, compression_parent, parent_keys,
record_details) = details
self._parent_map[key] = parent_keys
+ self._heads_provider = None
records.append((key, index_memo))
# Do we actually need to check _annotated_lines?
pending.update(p for p in parent_keys
More information about the bazaar-commits
mailing list