/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/workingtree_implementations/test_parents.py

  • Committer: Robert Collins
  • Date: 2006-08-09 10:56:48 UTC
  • mto: (1908.6.2 use set_parent_trees.)
  • mto: This revision was merged to the branch mainline in revision 1972.
  • Revision ID: robertc@robertcollins.net-20060809105648-6507e2184fdbb0d3
Rename the tree.set_parents tests to tree.parents - preparing to add related function tests. Also remove duplication within the tests by factoring out a helper assert.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
"""Tests of the parent related functions of WorkingTrees."""
 
18
 
17
19
import os
18
20
 
19
21
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
23
25
import bzrlib.xml5
24
26
 
25
27
 
26
 
class TestSetParents(TestCaseWithWorkingTree):
 
28
class TestParents(TestCaseWithWorkingTree):
 
29
 
 
30
    def assertConsistentParents(self, expected, tree):
 
31
        self.assertEqual(expected, tree.get_parent_ids())
 
32
        if expected == []:
 
33
            self.assertEqual(None, tree.last_revision())
 
34
        else:
 
35
            self.assertEqual(expected[0], tree.last_revision())
 
36
        self.assertEqual(expected[1:], tree.pending_merges())
 
37
 
 
38
 
 
39
class TestSetParents(TestParents):
27
40
 
28
41
    def test_set_no_parents(self):
29
42
        t = self.make_branch_and_tree('.')
32
45
        # now give it a real parent, and then set it to no parents again.
33
46
        t.commit('first post')
34
47
        t.set_parent_trees([])
35
 
        self.assertEqual([], t.get_parent_ids())
36
 
        self.assertEqual(None, t.last_revision())
37
 
        self.assertEqual([], t.pending_merges())
 
48
        self.assertConsistentParents([], t)
38
49
 
39
50
    def test_set_one_ghost_parent(self):
40
51
        t = self.make_branch_and_tree('.')
41
52
        t.set_parent_trees([('missing-revision-id', None)])
42
 
        self.assertEqual(['missing-revision-id'], t.get_parent_ids())
43
 
        self.assertEqual('missing-revision-id', t.last_revision())
44
 
        self.assertEqual([], t.pending_merges())
 
53
        self.assertConsistentParents(['missing-revision-id'], t)
45
54
 
46
55
    def test_set_two_parents_one_ghost(self):
47
56
        t = self.make_branch_and_tree('.')
51
60
        rev_tree = t.branch.repository.revision_tree(revision_in_repo)
52
61
        t.set_parent_trees([(revision_in_repo, rev_tree),
53
62
            ('another-missing', None)])
54
 
        self.assertEqual([revision_in_repo, 'another-missing'],
55
 
            t.get_parent_ids())
56
 
        self.assertEqual(revision_in_repo, t.last_revision())
57
 
        self.assertEqual(['another-missing'], t.pending_merges())
 
63
        self.assertConsistentParents([revision_in_repo, 'another-missing'], t)
58
64
 
59
65
    def test_set_three_parents(self):
60
66
        t = self.make_branch_and_tree('.')
70
76
        t.set_parent_trees([(first_revision, rev_tree1),
71
77
            (second_revision, rev_tree2),
72
78
            (third_revision, rev_tree3)])
73
 
        self.assertEqual([first_revision, second_revision, third_revision],
74
 
            t.get_parent_ids())
75
 
        self.assertEqual(first_revision, t.last_revision())
76
 
        self.assertEqual([second_revision, third_revision], t.pending_merges())
 
79
        self.assertConsistentParents(
 
80
            [first_revision, second_revision, third_revision], t)