15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
from bzrlib.branchbuilder import BranchBuilder
18
19
from bzrlib.tests import TestCaseWithMemoryTransport
19
from bzrlib.branchbuilder import BranchBuilder
20
from bzrlib.tests.matchers import MatchesAncestry
22
23
class TestAncestry(TestCaseWithMemoryTransport):
24
def assertAncestryEqual(self, expected, revision_id, branch):
25
"""Assert that the ancestry of revision_id in branch is as expected."""
26
ancestry = branch.repository.get_ancestry(revision_id)
27
self.assertEqual(expected, ancestry)
29
25
def test_straightline_ancestry(self):
30
26
"""Test ancestry file when just committing."""
31
27
builder = BranchBuilder(self.get_transport())
32
28
rev_id_one = builder.build_commit()
33
29
rev_id_two = builder.build_commit()
34
30
branch = builder.get_branch()
35
self.assertAncestryEqual([None, rev_id_one, rev_id_two],
37
self.assertAncestryEqual([None, rev_id_one], rev_id_one, branch)
31
self.assertThat([rev_id_one, rev_id_two],
32
MatchesAncestry(branch.repository, rev_id_two))
33
self.assertThat([rev_id_one],
34
MatchesAncestry(branch.repository, rev_id_one))
39
36
# TODO: check that ancestry is updated to include indirectly merged revisions