1080
1080
search = graph._make_breadth_first_searcher(['head'])
1082
1082
# NULL_REVISION and ghost1 have not been returned
1083
(set(['head']), (set(['head']), set(['child', 'ghost1']), 1),
1084
(set(['head']), set(['child', NULL_REVISION, 'ghost1']), 1),
1084
1085
['head'], None, [NULL_REVISION, 'ghost1']),
1085
1086
# ghost1 has been returned, NULL_REVISION is to be returned in the
1086
1087
# next iteration.
1524
1525
# 2 and 3 cannot be removed because 1 has 2 parents
1525
1526
d = {1:[2, 3], 2:[4], 4:[6], 3:[5], 5:[6], 6:[7], 7:[]}
1526
1527
self.assertCollapsed(d, d)
1530
class TestPendingAncestryResult(TestCaseWithMemoryTransport):
1531
"""Tests for bzrlib.graph.PendingAncestryResult."""
1533
def test_get_keys(self):
1534
builder = self.make_branch_builder('b')
1535
builder.start_series()
1536
builder.build_snapshot('rev-1', None, [
1537
('add', ('', 'root-id', 'directory', ''))])
1538
builder.build_snapshot('rev-2', ['rev-1'], [])
1539
builder.finish_series()
1540
repo = builder.get_branch().repository
1542
self.addCleanup(repo.unlock)
1543
par = _mod_graph.PendingAncestryResult(['rev-2'], repo)
1544
self.assertEqual(set(['rev-1', 'rev-2']), set(par.get_keys()))
1546
def test_get_keys_excludes_null(self):
1547
# Make a 'graph' with an iter_ancestry that returns NULL_REVISION
1548
# somewhere other than the last element, which can happen in real
1550
class StubGraph(object):
1551
def iter_ancestry(self, keys):
1552
return [(NULL_REVISION, ()), ('foo', (NULL_REVISION,))]
1553
par = _mod_graph.PendingAncestryResult(['rev-3'], None)
1554
par_keys = par._get_keys(StubGraph())
1555
# Only the non-null keys from the ancestry appear.
1556
self.assertEqual(set(['foo']), set(par_keys))