220
220
self.assertEqual([], tree.get_parent_ids())
223
class TestWorkingTreeFormat4(TestCaseWithTransport):
224
"""Tests specific to WorkingTreeFormat3."""
226
def test_disk_layout(self):
227
tree = self.make_branch_and_tree('.', format=bzrdir.get_knit3_format())
228
control = tree.bzrdir
230
# format 'Bazaar-NG Working Tree format 4'
231
# inventory = 1 entry for root
232
# pending-merges = ''
233
# no inventory.basis yet
234
t = control.get_workingtree_transport(None)
235
self.assertEqualDiff('Bazaar-NG Working Tree format 4',
236
t.get('format').read())
237
self.assertContainsRe(t.get('inventory').read(),
238
'<inventory format="7">\n'
239
'<directory file_id="[^"]*" name="" />\n'
242
self.assertEqualDiff('### bzr hashcache v5\n',
243
t.get('stat-cache').read())
244
self.assertFalse(t.has('basis-inventory-cache'))
245
# no last-revision file means 'None' or 'NULLREVISION'
246
self.assertFalse(t.has('last-revision'))
247
tree.set_root_id('my-root-id')
248
tree.commit('test', rev_id='revision-1')
249
self.assertTrue(t.has('basis-inventory-cache'))
250
self.assertTrue(t.has('last-revision'))
251
self.assertEqualDiff(t.get('basis-inventory-cache').read(),
252
'<inventory format="7" revision_id="revision-1">\n'
253
'<directory file_id="my-root-id" name="" revision="revision-1" />\n'
256
def test_incompatible_repo(self):
257
control = bzrdir.get_knit1_format()
258
control.workingtree_format = workingtree.WorkingTreeFormat4()
259
tree = self.make_branch_and_tree('.', format=control)
260
self.assertRaises(errors.RootNotRich, tree.commit)
262
def test_compatible_repo(self):
263
tree = self.make_branch_and_tree('.', format=bzrdir.get_knit3_format())
264
tree.set_root_id('my-root-id')
265
tree.commit('test', rev_id='revision-1')
266
tree.commit('test', rev_id='revision-2')
267
revision_tree = tree.branch.repository.revision_tree('revision-2')
268
self.assertEqual('revision-1',
269
revision_tree.inventory['my-root-id'].revision)
223
272
class TestFormat2WorkingTree(TestCaseWithTransport):
224
273
"""Tests that are specific to format 2 trees."""