15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
from bzrlib.tests import TestCaseWithMemoryTransport
18
19
from bzrlib.branchbuilder import BranchBuilder
19
from bzrlib.tests import TestCaseWithMemoryTransport
20
from bzrlib.tests.matchers import MatchesAncestry
23
22
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)
25
29
def test_straightline_ancestry(self):
26
30
"""Test ancestry file when just committing."""
27
31
builder = BranchBuilder(self.get_transport())
28
32
rev_id_one = builder.build_commit()
29
33
rev_id_two = builder.build_commit()
30
34
branch = builder.get_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))
35
self.assertAncestryEqual([None, rev_id_one, rev_id_two],
37
self.assertAncestryEqual([None, rev_id_one], rev_id_one, branch)
36
39
# TODO: check that ancestry is updated to include indirectly merged revisions