21
from bzrlib import errors
21
22
from bzrlib.tests.workingtree_implementations import TestCaseWithWorkingTree
22
from bzrlib.branch import Branch
23
from bzrlib.revision import Revision
24
23
from bzrlib.uncommit import uncommit
28
26
class TestParents(TestCaseWithWorkingTree):
47
45
t.set_parent_trees([])
48
46
self.assertConsistentParents([], t)
50
def test_set_one_ghost_parent(self):
51
t = self.make_branch_and_tree('.')
52
t.set_parent_trees([('missing-revision-id', None)])
48
def test_set_one_ghost_parent_rejects(self):
49
t = self.make_branch_and_tree('.')
50
self.assertRaises(errors.GhostRevisionUnusableHere,
51
t.set_parent_trees, [('missing-revision-id', None)])
53
def test_set_one_ghost_parent_force(self):
54
t = self.make_branch_and_tree('.')
55
t.set_parent_trees([('missing-revision-id', None)],
56
allow_leftmost_as_ghost=True)
53
57
self.assertConsistentParents(['missing-revision-id'], t)
55
59
def test_set_two_parents_one_ghost(self):
88
92
t.set_parent_ids([])
89
93
self.assertConsistentParents([], t)
91
def test_set_one_ghost_parent_ids(self):
92
t = self.make_branch_and_tree('.')
93
t.set_parent_ids(['missing-revision-id'])
95
def test_set_one_ghost_parent_ids_rejects(self):
96
t = self.make_branch_and_tree('.')
97
self.assertRaises(errors.GhostRevisionUnusableHere,
98
t.set_parent_ids, ['missing-revision-id'])
100
def test_set_one_ghost_parent_ids_force(self):
101
t = self.make_branch_and_tree('.')
102
t.set_parent_ids(['missing-revision-id'],
103
allow_leftmost_as_ghost=True)
94
104
self.assertConsistentParents(['missing-revision-id'], t)
96
106
def test_set_two_parents_one_ghost_ids(self):
128
138
tree.add_parent_tree_id(first_revision)
129
139
self.assertConsistentParents([first_revision], tree)
131
def test_add_first_parent_id_ghost(self):
132
"""Test adding the first parent id - as a ghost"""
133
tree = self.make_branch_and_tree('.')
134
tree.add_parent_tree_id('first-revision')
141
def test_add_first_parent_id_ghost_rejects(self):
142
"""Test adding the first parent id - as a ghost"""
143
tree = self.make_branch_and_tree('.')
144
self.assertRaises(errors.GhostRevisionUnusableHere,
145
tree.add_parent_tree_id, 'first-revision')
147
def test_add_first_parent_id_ghost_force(self):
148
"""Test adding the first parent id - as a ghost"""
149
tree = self.make_branch_and_tree('.')
150
tree.add_parent_tree_id('first-revision', allow_leftmost_as_ghost=True)
135
151
self.assertConsistentParents(['first-revision'], tree)
153
def test_add_second_parent_id_with_ghost_first(self):
154
"""Test adding the second parent when the first is a ghost."""
155
tree = self.make_branch_and_tree('.')
156
tree.add_parent_tree_id('first-revision', allow_leftmost_as_ghost=True)
157
tree.add_parent_tree_id('second')
158
self.assertConsistentParents(['first-revision', 'second'], tree)
137
160
def test_add_second_parent_id(self):
138
161
"""Test adding the second parent id"""
159
182
tree.branch.repository.revision_tree(first_revision)))
160
183
self.assertConsistentParents([first_revision], tree)
162
def test_add_first_parent_tree_ghost(self):
163
"""Test adding the first parent id - as a ghost"""
164
tree = self.make_branch_and_tree('.')
165
tree.add_parent_tree(('first-revision', None))
185
def test_add_first_parent_tree_ghost_rejects(self):
186
"""Test adding the first parent id - as a ghost"""
187
tree = self.make_branch_and_tree('.')
188
self.assertRaises(errors.GhostRevisionUnusableHere,
189
tree.add_parent_tree, ('first-revision', None))
191
def test_add_first_parent_tree_ghost_force(self):
192
"""Test adding the first parent id - as a ghost"""
193
tree = self.make_branch_and_tree('.')
194
tree.add_parent_tree(('first-revision', None),
195
allow_leftmost_as_ghost=True)
166
196
self.assertConsistentParents(['first-revision'], tree)
168
198
def test_add_second_parent_tree(self):