Rev 4401: Clean up the annotate code while using the new functionality. in http://bazaar.launchpad.net/~jameinel/bzr/1.16-better_heads
John Arbash Meinel
john at arbash-meinel.com
Thu Jun 11 21:35:05 BST 2009
At http://bazaar.launchpad.net/~jameinel/bzr/1.16-better_heads
------------------------------------------------------------
revno: 4401
revision-id: john at arbash-meinel.com-20090611203456-g3z9360rdd00tjs3
parent: john at arbash-meinel.com-20090611200247-zvx587wf8qyr2rg1
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: 1.16-better_heads
timestamp: Thu 2009-06-11 15:34:56 -0500
message:
Clean up the annotate code while using the new functionality.
-------------- next part --------------
=== modified file 'bzrlib/groupcompress.py'
--- a/bzrlib/groupcompress.py 2009-06-10 18:58:02 +0000
+++ b/bzrlib/groupcompress.py 2009-06-11 20:34:56 +0000
@@ -1028,10 +1028,9 @@
else:
keys = [key]
parent_map = {key:()}
- # So we used Graph(self) to load the parent_map, but now that we have
- # it, we can just query the parent map directly, so create a new Graph
- # object
- graph = _mod_graph.KnownGraph(parent_map)
+ # We used Graph(self) to load the parent_map, but now that we have it,
+ # we can just query the parent map directly, so create a KnownGraph
+ heads_provider = _mod_graph.KnownGraph(parent_map)
parent_cache = {}
reannotate = annotate.reannotate
for record in self.get_record_stream(keys, 'topological', True):
@@ -1039,7 +1038,7 @@
lines = osutils.chunks_to_lines(record.get_bytes_as('chunked'))
parent_lines = [parent_cache[parent] for parent in parent_map[key]]
parent_cache[key] = list(
- reannotate(parent_lines, lines, key, None, graph))
+ reannotate(parent_lines, lines, key, None, heads_provider))
return parent_cache[key]
def check(self, progress_bar=None):
=== modified file 'bzrlib/knit.py'
--- a/bzrlib/knit.py 2009-06-10 18:58:02 +0000
+++ b/bzrlib/knit.py 2009-06-11 20:34:56 +0000
@@ -3552,8 +3552,6 @@
"""Create a heads provider for resolving ancestry issues."""
if self._heads_provider is not None:
return self._heads_provider
- # graph_obj = _mod_graph.Graph(parent_provider)
- # head_cache = _mod_graph.FrozenHeadsCache(graph_obj)
self._heads_provider = _mod_graph.KnownGraph(self._revision_id_graph)
return self._heads_provider
@@ -3584,19 +3582,15 @@
being able to produce line deltas.
"""
# TODO: this code generates a parent maps of present ancestors; it
- # could be split out into a separate method, and probably should use
- # iter_ancestry instead. -- mbp and robertc 20080704
+ # could be split out into a separate method
+ # -- mbp and robertc 20080704
graph = _mod_graph.Graph(self._knit)
- head_cache = _mod_graph.FrozenHeadsCache(graph)
- search = graph._make_breadth_first_searcher([key])
- keys = set()
- while True:
- try:
- present, ghosts = search.next_with_ghosts()
- except StopIteration:
- break
- keys.update(present)
- parent_map = self._knit.get_parent_map(keys)
+ parent_map = dict((k, v) for k, v in graph.iter_ancestry([key])
+ if v is not None)
+ if not parent_map:
+ raise errors.RevisionNotPresent(key, self)
+ keys = parent_map.keys()
+ heads_provider = _mod_graph.KnownGraph(parent_map)
parent_cache = {}
reannotate = annotate.reannotate
for record in self._knit.get_record_stream(keys, 'topological', True):
@@ -3608,7 +3602,7 @@
else:
parent_lines = []
parent_cache[key] = list(
- reannotate(parent_lines, fulltext, key, None, head_cache))
+ reannotate(parent_lines, fulltext, key, None, heads_provider))
try:
return parent_cache[key]
except KeyError, e:
More information about the bazaar-commits
mailing list