Rev 3482: _find_boundary should stop even if the node finds mainline first. in http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/lazy_revno
John Arbash Meinel
john at arbash-meinel.com
Mon Jun 16 23:31:04 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.6-dev/lazy_revno
------------------------------------------------------------
revno: 3482
revision-id: john at arbash-meinel.com-20080616223044-9b6g2so40tf0d70v
parent: john at arbash-meinel.com-20080616222146-h41zbinrrtkygznq
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: lazy_revno
timestamp: Mon 2008-06-16 17:30:44 -0500
message:
_find_boundary should stop even if the node finds mainline first.
-------------- next part --------------
=== modified file 'bzrlib/graph.py'
--- a/bzrlib/graph.py 2008-06-16 22:21:46 +0000
+++ b/bzrlib/graph.py 2008-06-16 22:30:44 +0000
@@ -1516,6 +1516,7 @@
next_parent_request.add(self._cur_mainline_node.revision_id)
next_parent_request.add(node.revision_id)
cur_node = node
+ node_ancestors = set([node.revision_id])
while cur_node is not None and next_parent_request:
parent_map = self.get_parent_map(next_parent_request)
self._update_known_children(parent_map)
@@ -1544,6 +1545,13 @@
# TODO: factor this into node.set_merged_into???
node.set_merged_into(revno)
self._cur_mainline_node = next_mainline_node
+ if next_mainline_tip in node_ancestors:
+ # We walked onto the mainline, which the node walker
+ # had already seen, we are done
+ # TODO: We could walk the nodes right here, and set the
+ # revnos for entries that we have already started
+ # processing.
+ break
cur_parent_ids = parent_map.get(cur_node.revision_id, None)
next_node = None
@@ -1560,6 +1568,7 @@
for p_id in cur_parent_ids[1:]:
node = self._get_node(p_id)
node.set_possible_merged_into(merged_into)
+ node_ancestors.add(next_rev_id)
else:
next_node = None
if cur_node.revno is not None:
=== modified file 'bzrlib/tests/test_graph.py'
--- a/bzrlib/tests/test_graph.py 2008-06-16 22:21:46 +0000
+++ b/bzrlib/tests/test_graph.py 2008-06-16 22:30:44 +0000
@@ -1379,3 +1379,10 @@
def test_mainline_revision(self):
mapper = self.make_mapper(ancestry_1, 'rev4', break_on=['rev1'])
self.assertEqual(3, mapper.get_dotted_revno('rev3'))
+
+ def test__find_boundary_revisions_stops(self):
+ """Ensure we stop iterating ancestry when we can."""
+ mapper = self.make_mapper(with_tail, 'i', break_on=['a', 'b'])
+ # The node walker should reach mainline before the mainline walker
+ # does. We should still be able to stop early
+ mapper._find_boundary_revisions(mapper._get_node('g'))
More information about the bazaar-commits
mailing list