~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir/test_controldir.py

resolve conflicts against trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
            bzrdir.destroy_workingtree()
123
123
        except errors.UnsupportedOperation:
124
124
            raise TestSkipped('Format does not support destroying tree')
125
 
        self.failIfExists('tree/file')
 
125
        self.assertPathDoesNotExist('tree/file')
126
126
        self.assertRaises(errors.NoWorkingTree, bzrdir.open_workingtree)
127
127
        bzrdir.create_workingtree()
128
 
        self.failUnlessExists('tree/file')
 
128
        self.assertPathExists('tree/file')
129
129
        bzrdir.destroy_workingtree_metadata()
130
 
        self.failUnlessExists('tree/file')
 
130
        self.assertPathExists('tree/file')
131
131
        self.assertRaises(errors.NoWorkingTree, bzrdir.open_workingtree)
132
132
 
133
133
    def test_destroy_branch(self):
194
194
        self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
195
195
        tree.add('foo')
196
196
        tree.commit('revision 1', rev_id='1')
197
 
        tree.bzrdir.open_branch().set_revision_history([])
 
197
        tree.bzrdir.open_branch().generate_revision_history(
 
198
            bzrlib.revision.NULL_REVISION)
198
199
        tree.set_parent_trees([])
199
200
        tree.commit('revision 2', rev_id='2')
200
201
        # Copy the content (i.e. revisions) from the 'commit_tree' branch's
222
223
        self.build_tree(['commit_tree/foo'])
223
224
        tree.add('foo')
224
225
        tree.commit('revision 1', rev_id='1')
225
 
        tree.branch.bzrdir.open_branch().set_revision_history([])
 
226
        tree.branch.bzrdir.open_branch().generate_revision_history(
 
227
            bzrlib.revision.NULL_REVISION)
226
228
        tree.set_parent_trees([])
227
229
        tree.commit('revision 2', rev_id='2')
228
230
        tree.branch.repository.copy_content_into(shared_repo)
249
251
        self.build_tree(['commit_tree/foo'])
250
252
        tree.add('foo')
251
253
        tree.commit('revision 1', rev_id='1')
252
 
        tree.branch.bzrdir.open_branch().set_revision_history([])
 
254
        tree.branch.bzrdir.open_branch().generate_revision_history(
 
255
            bzrlib.revision.NULL_REVISION)
253
256
        tree.set_parent_trees([])
254
257
        tree.commit('revision 2', rev_id='2')
255
258
        source = self.make_repository('source')
447
450
        self.build_tree(['commit_tree/foo'])
448
451
        tree.add('foo')
449
452
        tree.commit('revision 1', rev_id='1')
450
 
        tree.bzrdir.open_branch().set_revision_history([])
 
453
        tree.bzrdir.open_branch().generate_revision_history(
 
454
            bzrlib.revision.NULL_REVISION)
451
455
        tree.set_parent_trees([])
452
456
        tree.commit('revision 2', rev_id='2')
453
457
        source = self.make_repository('source')
470
474
        self.build_tree(['commit_tree/foo'])
471
475
        tree.add('foo')
472
476
        tree.commit('revision 1', rev_id='1')
473
 
        tree.bzrdir.open_branch().set_revision_history([])
 
477
        tree.bzrdir.open_branch().generate_revision_history(
 
478
            bzrlib.revision.NULL_REVISION)
474
479
        tree.set_parent_trees([])
475
480
        tree.commit('revision 2', rev_id='2')
476
481
        tree.branch.repository.copy_content_into(shared_repo)
490
495
        self.build_tree(['commit_tree/foo'])
491
496
        tree.add('foo')
492
497
        tree.commit('revision 1', rev_id='1')
493
 
        tree.bzrdir.open_branch().set_revision_history([])
 
498
        tree.bzrdir.open_branch().generate_revision_history(
 
499
            bzrlib.revision.NULL_REVISION)
494
500
        tree.set_parent_trees([])
495
501
        tree.commit('revision 2', rev_id='2')
496
502
        tree.branch.repository.copy_content_into(shared_repo)
517
523
        self.build_tree(['commit_tree/foo'])
518
524
        tree.add('foo')
519
525
        tree.commit('revision 1', rev_id='1')
520
 
        tree.bzrdir.open_branch().set_revision_history([])
 
526
        tree.bzrdir.open_branch().generate_revision_history(
 
527
            bzrlib.revision.NULL_REVISION)
521
528
        tree.set_parent_trees([])
522
529
        tree.commit('revision 2', rev_id='2')
523
530
        source = self.make_repository('source')
540
547
        self.build_tree(['commit_tree/foo'])
541
548
        tree.add('foo')
542
549
        tree.commit('revision 1', rev_id='1')
543
 
        tree.bzrdir.open_branch().set_revision_history([])
 
550
        br = tree.bzrdir.open_branch()
 
551
        br.set_last_revision_info(0, bzrlib.revision.NULL_REVISION)
544
552
        tree.set_parent_trees([])
545
553
        tree.commit('revision 2', rev_id='2')
546
554
        source = self.make_repository('source')
860
868
                create_tree_if_local=False)
861
869
        except errors.MustHaveWorkingTree:
862
870
            raise TestNotApplicable("control dir format requires working tree")
863
 
        self.failIfExists('target/foo')
 
871
        self.assertPathDoesNotExist('target/foo')
864
872
        self.assertEqual(tree.branch.last_revision(),
865
873
                         target.open_branch().last_revision())
866
874
 
905
913
        t = self.get_transport()
906
914
        readonly_t = self.get_readonly_transport()
907
915
        made_control = self.bzrdir_format.initialize(t.base)
908
 
        self.failUnless(isinstance(made_control, controldir.ControlDir))
 
916
        self.assertIsInstance(made_control, controldir.ControlDir)
909
917
        if isinstance(self.bzrdir_format, RemoteBzrDirFormat):
910
918
            return
911
919
        self.assertEqual(self.bzrdir_format,
916
924
                         opened_dir._format)
917
925
        self.assertEqual(direct_opened_dir._format,
918
926
                         opened_dir._format)
919
 
        self.failUnless(isinstance(opened_dir, controldir.ControlDir))
 
927
        self.assertIsInstance(opened_dir, controldir.ControlDir)
920
928
 
921
929
    def test_format_initialize_on_transport_ex(self):
922
930
        t = self.get_transport('dir')
1122
1130
        made_control = self.bzrdir_format.initialize(t.base)
1123
1131
        made_repo = made_control.create_repository()
1124
1132
        made_branch = made_control.create_branch()
1125
 
        self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
 
1133
        self.assertIsInstance(made_branch, bzrlib.branch.Branch)
1126
1134
        self.assertEqual(made_control, made_branch.bzrdir)
1127
1135
 
1128
1136
    def test_open_branch(self):
1137
1145
        made_branch = made_control.create_branch()
1138
1146
        opened_branch = made_control.open_branch()
1139
1147
        self.assertEqual(made_control, opened_branch.bzrdir)
1140
 
        self.failUnless(isinstance(opened_branch, made_branch.__class__))
1141
 
        self.failUnless(isinstance(opened_branch._format, made_branch._format.__class__))
 
1148
        self.assertIsInstance(opened_branch, made_branch.__class__)
 
1149
        self.assertIsInstance(opened_branch._format, made_branch._format.__class__)
1142
1150
 
1143
1151
    def test_list_branches(self):
1144
1152
        if not self.bzrdir_format.is_supported():
1215
1223
        made_repo = made_control.create_repository()
1216
1224
        opened_repo = made_control.open_repository()
1217
1225
        self.assertEqual(made_control, opened_repo.bzrdir)
1218
 
        self.failUnless(isinstance(opened_repo, made_repo.__class__))
1219
 
        self.failUnless(isinstance(opened_repo._format, made_repo._format.__class__))
 
1226
        self.assertIsInstance(opened_repo, made_repo.__class__)
 
1227
        self.assertIsInstance(opened_repo._format, made_repo._format.__class__)
1220
1228
 
1221
1229
    def test_create_workingtree(self):
1222
1230
        # a bzrdir can construct a working tree for itself.
1230
1238
        made_repo = made_control.create_repository()
1231
1239
        made_branch = made_control.create_branch()
1232
1240
        made_tree = self.createWorkingTreeOrSkip(made_control)
1233
 
        self.failUnless(isinstance(made_tree, workingtree.WorkingTree))
 
1241
        self.assertIsInstance(made_tree, workingtree.WorkingTree)
1234
1242
        self.assertEqual(made_control, made_tree.bzrdir)
1235
1243
 
1236
1244
    def test_create_workingtree_revision(self):
1269
1277
                              % (self.bzrdir_format, t))
1270
1278
        opened_tree = made_control.open_workingtree()
1271
1279
        self.assertEqual(made_control, opened_tree.bzrdir)
1272
 
        self.failUnless(isinstance(opened_tree, made_tree.__class__))
1273
 
        self.failUnless(isinstance(opened_tree._format, made_tree._format.__class__))
 
1280
        self.assertIsInstance(opened_tree, made_tree.__class__)
 
1281
        self.assertIsInstance(opened_tree._format, made_tree._format.__class__)
1274
1282
 
1275
1283
    def test_root_transport(self):
1276
1284
        dir = self.make_bzrdir('.')
1409
1417
        old_url, new_url = tree.bzrdir.backup_bzrdir()
1410
1418
        old_path = urlutils.local_path_from_url(old_url)
1411
1419
        new_path = urlutils.local_path_from_url(new_url)
1412
 
        self.failUnlessExists(old_path)
1413
 
        self.failUnlessExists(new_path)
 
1420
        self.assertPathExists(old_path)
 
1421
        self.assertPathExists(new_path)
1414
1422
        for (((dir_relpath1, _), entries1),
1415
1423
             ((dir_relpath2, _), entries2)) in izip(
1416
1424
                osutils.walkdirs(old_path),
1444
1452
    def test_format_description(self):
1445
1453
        dir = self.make_bzrdir('.')
1446
1454
        text = dir._format.get_format_description()
1447
 
        self.failUnless(len(text))
 
1455
        self.assertTrue(len(text))
1448
1456
 
1449
1457
 
1450
1458
class TestBreakLock(TestCaseWithControlDir):