~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Aaron Bentley
  • Date: 2006-12-22 03:28:50 UTC
  • mto: (2255.6.1 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: aaron.bentley@utoronto.ca-20061222032850-nfiemdjr81urpbm3
Test workingtree4 format, prevent use with old repos

Show diffs side-by-side

added added

removed removed

Lines of Context:
220
220
        self.assertEqual([], tree.get_parent_ids())
221
221
 
222
222
 
 
223
class TestWorkingTreeFormat4(TestCaseWithTransport):
 
224
    """Tests specific to WorkingTreeFormat3."""
 
225
 
 
226
    def test_disk_layout(self):
 
227
        tree = self.make_branch_and_tree('.', format=bzrdir.get_knit3_format())
 
228
        control = tree.bzrdir
 
229
        # we want:
 
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'
 
240
                              '</inventory>\n',
 
241
                             )
 
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'
 
254
            '</inventory>\n')
 
255
    
 
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)
 
261
 
 
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)
 
270
 
 
271
 
223
272
class TestFormat2WorkingTree(TestCaseWithTransport):
224
273
    """Tests that are specific to format 2 trees."""
225
274