~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Vincent Ladeuil
  • Date: 2016-02-01 18:09:18 UTC
  • mfrom: (6614.1.3 assert)
  • mto: This revision was merged to the branch mainline in revision 6615.
  • Revision ID: v.ladeuil+lp@free.fr-20160201180918-jqtq8ol6gdbbbtpv
Fix deprecated assertions to unblock release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2011 Canonical Ltd
 
1
# Copyright (C) 2008-2012, 2016 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
321
321
        return super(DummyForeignVcsDir, self).create_workingtree()
322
322
 
323
323
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True,
324
 
            possible_transports=None):
 
324
                    possible_transports=None):
325
325
        if name is None:
326
326
            name = self._get_selected_branch()
327
327
        if name != "":
339
339
               recurse='down', possible_transports=None,
340
340
               accelerator_tree=None, hardlink=False, stacked=False,
341
341
               source_branch=None):
342
 
        # dirstate doesn't cope with accelerator_trees well 
 
342
        # dirstate doesn't cope with accelerator_trees well
343
343
        # that have a different control dir
344
 
        return super(DummyForeignVcsDir, self).sprout(url=url, 
345
 
                revision_id=revision_id, force_new_repo=force_new_repo, 
346
 
                recurse=recurse, possible_transports=possible_transports, 
347
 
                hardlink=hardlink, stacked=stacked, source_branch=source_branch)
 
344
        return super(DummyForeignVcsDir, self).sprout(
 
345
            url=url,
 
346
            revision_id=revision_id, force_new_repo=force_new_repo,
 
347
            recurse=recurse, possible_transports=possible_transports,
 
348
            hardlink=hardlink, stacked=stacked, source_branch=source_branch)
348
349
 
349
350
 
350
351
def register_dummy_foreign_for_test(testcase):
351
352
    controldir.ControlDirFormat.register_prober(DummyForeignProber)
352
353
    testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
353
 
        DummyForeignProber)
 
354
                        DummyForeignProber)
354
355
    repository.format_registry.register(DummyForeignVcsRepositoryFormat())
355
356
    testcase.addCleanup(repository.format_registry.remove,
356
 
            DummyForeignVcsRepositoryFormat())
 
357
                        DummyForeignVcsRepositoryFormat())
357
358
    branch.format_registry.register(DummyForeignVcsBranchFormat())
358
359
    testcase.addCleanup(branch.format_registry.remove,
359
 
            DummyForeignVcsBranchFormat())
 
360
                        DummyForeignVcsBranchFormat())
360
361
    # We need to register the optimiser to make the dummy appears really
361
362
    # different from a regular bzr repository.
362
363
    branch.InterBranch.register_optimiser(InterToDummyVcsBranch)
395
396
        reg = foreign.ForeignVcsRegistry()
396
397
        vcs = DummyForeignVcs()
397
398
        reg.register("dummy", vcs, "Dummy VCS")
398
 
        self.assertEquals((
 
399
        self.assertEqual((
399
400
            ("some", "foreign", "revid"), DummyForeignVcsMapping(vcs)),
400
401
            reg.parse_revision_id("dummy-v1:some-foreign-revid"))
401
402
 
407
408
        mapp = DummyForeignVcsMapping(DummyForeignVcs())
408
409
        rev = foreign.ForeignRevision(("a", "foreign", "revid"),
409
410
                                      mapp, "roundtripped-revid")
410
 
        self.assertEquals("", rev.inventory_sha1)
411
 
        self.assertEquals(("a", "foreign", "revid"), rev.foreign_revid)
412
 
        self.assertEquals(mapp, rev.mapping)
 
411
        self.assertEqual("", rev.inventory_sha1)
 
412
        self.assertEqual(("a", "foreign", "revid"), rev.foreign_revid)
 
413
        self.assertEqual(mapp, rev.mapping)
413
414
 
414
415
 
415
416
class WorkingTreeFileUpdateTests(tests.TestCaseWithTransport):
431
432
        foreign.update_workingtree_fileids(wt, target_basis)
432
433
        wt.lock_read()
433
434
        try:
434
 
            self.assertEquals(set([root_id, "bla-b"]), set(wt.all_file_ids()))
 
435
            self.assertEqual(set([root_id, "bla-b"]), set(wt.all_file_ids()))
435
436
        finally:
436
437
            wt.unlock()
437
438
 
447
448
        """Test we can create dummies."""
448
449
        self.make_branch_and_tree("d", format=DummyForeignVcsDirFormat())
449
450
        dir = controldir.ControlDir.open("d")
450
 
        self.assertEquals("A Dummy VCS Dir", dir._format.get_format_string())
 
451
        self.assertEqual("A Dummy VCS Dir", dir._format.get_format_string())
451
452
        dir.open_repository()
452
453
        dir.open_branch()
453
454
        dir.open_workingtree()
457
458
        self.make_branch_and_tree("d", format=DummyForeignVcsDirFormat())
458
459
        dir = controldir.ControlDir.open("d")
459
460
        newdir = dir.sprout("e")
460
 
        self.assertNotEquals("A Dummy VCS Dir",
461
 
                             newdir._format.get_format_string())
 
461
        self.assertNotEqual("A Dummy VCS Dir",
 
462
                            newdir._format.get_format_string())
462
463
 
463
464
    def test_push_not_supported(self):
464
465
        source_tree = self.make_branch_and_tree("source")
465
 
        target_tree = self.make_branch_and_tree("target", 
466
 
            format=DummyForeignVcsDirFormat())
467
 
        self.assertRaises(errors.NoRoundtrippingSupport, 
468
 
            source_tree.branch.push, target_tree.branch)
 
466
        target_tree = self.make_branch_and_tree(
 
467
            "target", format=DummyForeignVcsDirFormat())
 
468
        self.assertRaises(errors.NoRoundtrippingSupport,
 
469
                          source_tree.branch.push, target_tree.branch)
469
470
 
470
471
    def test_lossy_push_empty(self):
471
472
        source_tree = self.make_branch_and_tree("source")
472
 
        target_tree = self.make_branch_and_tree("target", 
473
 
            format=DummyForeignVcsDirFormat())
 
473
        target_tree = self.make_branch_and_tree(
 
474
            "target", format=DummyForeignVcsDirFormat())
474
475
        pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
475
 
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
476
 
        self.assertEquals(revision.NULL_REVISION, pushresult.new_revid)
477
 
        self.assertEquals({}, pushresult.revidmap)
 
476
        self.assertEqual(revision.NULL_REVISION, pushresult.old_revid)
 
477
        self.assertEqual(revision.NULL_REVISION, pushresult.new_revid)
 
478
        self.assertEqual({}, pushresult.revidmap)
478
479
 
479
480
    def test_lossy_push_simple(self):
480
481
        source_tree = self.make_branch_and_tree("source")
481
482
        self.build_tree(['source/a', 'source/b'])
482
483
        source_tree.add(['a', 'b'])
483
484
        revid1 = source_tree.commit("msg")
484
 
        target_tree = self.make_branch_and_tree("target", 
485
 
            format=DummyForeignVcsDirFormat())
 
485
        target_tree = self.make_branch_and_tree(
 
486
            "target", format=DummyForeignVcsDirFormat())
486
487
        target_tree.branch.lock_write()
487
488
        try:
488
489
            pushresult = source_tree.branch.push(
489
490
                target_tree.branch, lossy=True)
490
491
        finally:
491
492
            target_tree.branch.unlock()
492
 
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
493
 
        self.assertEquals({revid1:target_tree.branch.last_revision()}, 
494
 
                           pushresult.revidmap)
495
 
        self.assertEquals(pushresult.revidmap[revid1], pushresult.new_revid)
 
493
        self.assertEqual(revision.NULL_REVISION, pushresult.old_revid)
 
494
        self.assertEqual({revid1: target_tree.branch.last_revision()},
 
495
                         pushresult.revidmap)
 
496
        self.assertEqual(pushresult.revidmap[revid1], pushresult.new_revid)