~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_ancestry.py

  • Committer: Alexander Belchenko
  • Date: 2006-10-14 08:51:07 UTC
  • mto: (2080.1.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2081.
  • Revision ID: bialix@ukr.net-20061014085107-8dff865674eed30a
win32 installer: make short info page instead of full GPL license text

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2007 Canonical Ltd
 
1
# Copyright (C) 2005 by Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
 
22
22
from bzrlib.tests import TestCaseWithMemoryTransport
23
23
from bzrlib.branch import Branch
24
 
from bzrlib.branchbuilder import BranchBuilder
25
24
from bzrlib.revision import is_ancestor
26
 
from bzrlib.symbol_versioning import one_zero
27
25
 
28
26
 
29
27
class TestAncestry(TestCaseWithMemoryTransport):
35
33
 
36
34
    def test_straightline_ancestry(self):
37
35
        """Test ancestry file when just committing."""
38
 
        builder = BranchBuilder(self.get_transport())
39
 
        rev_id_one = builder.build_commit()
40
 
        rev_id_two = builder.build_commit()
41
 
        branch = builder.get_branch()
 
36
        tree = self.make_branch_and_memory_tree('.')
 
37
        branch = tree.branch
 
38
        rev_id_one = tree.commit('one')
 
39
        rev_id_two = tree.commit('two', allow_pointless=True)
 
40
 
42
41
        self.assertAncestryEqual([None, rev_id_one, rev_id_two],
43
42
            rev_id_two, branch)
44
43
        self.assertAncestryEqual([None, rev_id_one], rev_id_one, branch)
45
44
 
46
 
    def test_none_is_ancestor_empty_branch(self):
47
 
        branch = self.make_branch('.')
48
 
        self.assertTrue(self.applyDeprecated(one_zero,
49
 
                        is_ancestor, 'null:', 'null:', branch))
50
 
 
51
 
    def test_none_is_ancestor_non_empty_branch(self):
52
 
        builder = BranchBuilder(self.get_transport())
53
 
        rev_id = builder.build_commit()
54
 
        branch = builder.get_branch()
55
 
        branch.lock_read()
56
 
        self.addCleanup(branch.unlock)
57
 
        self.assertTrue(self.applyDeprecated(one_zero,
58
 
                        is_ancestor, 'null:', 'null:', branch))
59
 
        self.assertTrue(self.applyDeprecated(one_zero,
60
 
                        is_ancestor, rev_id, 'null:',  branch))
61
 
        self.assertFalse(self.applyDeprecated(one_zero,
62
 
                         is_ancestor, 'null:', rev_id, branch))
 
45
    def test_none_is_always_an_ancestor(self):
 
46
        tree = self.make_branch_and_memory_tree('.')
 
47
        # note this is tested before any commits are done.
 
48
        self.assertTrue(is_ancestor(None, None, tree.branch))
 
49
        rev_id = tree.commit('one')
 
50
        self.assertTrue(is_ancestor(None, None, tree.branch))
 
51
        self.assertTrue(is_ancestor(rev_id, None, tree.branch))
 
52
        self.assertFalse(is_ancestor(None, rev_id, tree.branch))
63
53
 
64
54
 
65
55
# TODO: check that ancestry is updated to include indirectly merged revisions