136
136
tree.commit('foo', rev_id='foo', local=True)
137
137
self.failIf(master.repository.has_revision('foo'))
138
138
self.assertEqual(None, master.last_revision())
140
def test_record_initial_ghost(self):
141
"""The working tree needs to record ghosts during commit."""
142
wt = self.make_branch_and_tree('.')
143
wt.set_parent_ids(['non:existent@rev--ision--0--2'],
144
allow_leftmost_as_ghost=True)
145
rev_id = wt.commit('commit against a ghost first parent.')
146
rev = wt.branch.repository.get_revision(rev_id)
147
self.assertEqual(rev.parent_ids, ['non:existent@rev--ision--0--2'])
148
# parent_sha1s is not populated now, WTF. rbc 20051003
149
self.assertEqual(len(rev.parent_sha1s), 0)
151
def test_record_two_ghosts(self):
152
"""The working tree should preserve all the parents during commit."""
153
wt = self.make_branch_and_tree('.')
155
'foo@azkhazan-123123-abcabc',
156
'wibble@fofof--20050401--1928390812',
158
allow_leftmost_as_ghost=True)
159
rev_id = wt.commit("commit from ghost base with one merge")
160
# the revision should have been committed with two parents
161
rev = wt.branch.repository.get_revision(rev_id)
162
self.assertEqual(['foo@azkhazan-123123-abcabc',
163
'wibble@fofof--20050401--1928390812'],
166
def test_commit_deleted_subtree_and_files_updates_workingtree(self):
167
"""The working trees inventory may be adjusted by commit."""
168
wt = self.make_branch_and_tree('.')
170
self.build_tree(['a', 'b/', 'b/c', 'd'])
171
wt.add(['a', 'b', 'b/c', 'd'], ['a-id', 'b-id', 'c-id', 'd-id'])
172
this_dir = self.get_transport()
173
this_dir.delete_tree('b')
175
# now we have a tree with a through d in the inventory, but only
176
# a present on disk. After commit b-id, c-id and d-id should be
177
# missing from the inventory, within the same tree transaction.
178
wt.commit('commit stuff')
179
self.assertTrue(wt.has_id('a-id'))
180
self.assertFalse(wt.has_or_had_id('b-id'))
181
self.assertFalse(wt.has_or_had_id('c-id'))
182
self.assertFalse(wt.has_or_had_id('d-id'))
183
self.assertTrue(wt.has_filename('a'))
184
self.assertFalse(wt.has_filename('b'))
185
self.assertFalse(wt.has_filename('b/c'))
186
self.assertFalse(wt.has_filename('d'))
188
# the changes should have persisted to disk - reopen the workingtree
190
wt = wt.bzrdir.open_workingtree()
192
self.assertTrue(wt.has_id('a-id'))
193
self.assertFalse(wt.has_or_had_id('b-id'))
194
self.assertFalse(wt.has_or_had_id('c-id'))
195
self.assertFalse(wt.has_or_had_id('d-id'))
196
self.assertTrue(wt.has_filename('a'))
197
self.assertFalse(wt.has_filename('b'))
198
self.assertFalse(wt.has_filename('b/c'))
199
self.assertFalse(wt.has_filename('d'))
141
203
class TestCommitProgress(TestCaseWithWorkingTree):