~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: John Arbash Meinel
  • Date: 2012-09-19 07:58:27 UTC
  • mfrom: (6437.63.9 2.5)
  • mto: This revision was merged to the branch mainline in revision 6563.
  • Revision ID: john@arbash-meinel.com-20120919075827-36b2b042kiaps0d3
Merge bzr-2.5.2 into trunk to get the fixes for ConnectionReset.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2008-2011 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(
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)
 
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)
349
348
 
350
349
 
351
350
def register_dummy_foreign_for_test(testcase):
352
351
    controldir.ControlDirFormat.register_prober(DummyForeignProber)
353
352
    testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
354
 
                        DummyForeignProber)
 
353
        DummyForeignProber)
355
354
    repository.format_registry.register(DummyForeignVcsRepositoryFormat())
356
355
    testcase.addCleanup(repository.format_registry.remove,
357
 
                        DummyForeignVcsRepositoryFormat())
 
356
            DummyForeignVcsRepositoryFormat())
358
357
    branch.format_registry.register(DummyForeignVcsBranchFormat())
359
358
    testcase.addCleanup(branch.format_registry.remove,
360
 
                        DummyForeignVcsBranchFormat())
 
359
            DummyForeignVcsBranchFormat())
361
360
    # We need to register the optimiser to make the dummy appears really
362
361
    # different from a regular bzr repository.
363
362
    branch.InterBranch.register_optimiser(InterToDummyVcsBranch)
396
395
        reg = foreign.ForeignVcsRegistry()
397
396
        vcs = DummyForeignVcs()
398
397
        reg.register("dummy", vcs, "Dummy VCS")
399
 
        self.assertEqual((
 
398
        self.assertEquals((
400
399
            ("some", "foreign", "revid"), DummyForeignVcsMapping(vcs)),
401
400
            reg.parse_revision_id("dummy-v1:some-foreign-revid"))
402
401
 
408
407
        mapp = DummyForeignVcsMapping(DummyForeignVcs())
409
408
        rev = foreign.ForeignRevision(("a", "foreign", "revid"),
410
409
                                      mapp, "roundtripped-revid")
411
 
        self.assertEqual("", rev.inventory_sha1)
412
 
        self.assertEqual(("a", "foreign", "revid"), rev.foreign_revid)
413
 
        self.assertEqual(mapp, rev.mapping)
 
410
        self.assertEquals("", rev.inventory_sha1)
 
411
        self.assertEquals(("a", "foreign", "revid"), rev.foreign_revid)
 
412
        self.assertEquals(mapp, rev.mapping)
414
413
 
415
414
 
416
415
class WorkingTreeFileUpdateTests(tests.TestCaseWithTransport):
432
431
        foreign.update_workingtree_fileids(wt, target_basis)
433
432
        wt.lock_read()
434
433
        try:
435
 
            self.assertEqual(set([root_id, "bla-b"]), set(wt.all_file_ids()))
 
434
            self.assertEquals(set([root_id, "bla-b"]), set(wt.all_file_ids()))
436
435
        finally:
437
436
            wt.unlock()
438
437
 
448
447
        """Test we can create dummies."""
449
448
        self.make_branch_and_tree("d", format=DummyForeignVcsDirFormat())
450
449
        dir = controldir.ControlDir.open("d")
451
 
        self.assertEqual("A Dummy VCS Dir", dir._format.get_format_string())
 
450
        self.assertEquals("A Dummy VCS Dir", dir._format.get_format_string())
452
451
        dir.open_repository()
453
452
        dir.open_branch()
454
453
        dir.open_workingtree()
458
457
        self.make_branch_and_tree("d", format=DummyForeignVcsDirFormat())
459
458
        dir = controldir.ControlDir.open("d")
460
459
        newdir = dir.sprout("e")
461
 
        self.assertNotEqual("A Dummy VCS Dir",
462
 
                            newdir._format.get_format_string())
 
460
        self.assertNotEquals("A Dummy VCS Dir",
 
461
                             newdir._format.get_format_string())
463
462
 
464
463
    def test_push_not_supported(self):
465
464
        source_tree = self.make_branch_and_tree("source")
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)
 
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)
470
469
 
471
470
    def test_lossy_push_empty(self):
472
471
        source_tree = self.make_branch_and_tree("source")
473
 
        target_tree = self.make_branch_and_tree(
474
 
            "target", format=DummyForeignVcsDirFormat())
 
472
        target_tree = self.make_branch_and_tree("target", 
 
473
            format=DummyForeignVcsDirFormat())
475
474
        pushresult = source_tree.branch.push(target_tree.branch, lossy=True)
476
 
        self.assertEqual(revision.NULL_REVISION, pushresult.old_revid)
477
 
        self.assertEqual(revision.NULL_REVISION, pushresult.new_revid)
478
 
        self.assertEqual({}, pushresult.revidmap)
 
475
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
 
476
        self.assertEquals(revision.NULL_REVISION, pushresult.new_revid)
 
477
        self.assertEquals({}, pushresult.revidmap)
479
478
 
480
479
    def test_lossy_push_simple(self):
481
480
        source_tree = self.make_branch_and_tree("source")
482
481
        self.build_tree(['source/a', 'source/b'])
483
482
        source_tree.add(['a', 'b'])
484
483
        revid1 = source_tree.commit("msg")
485
 
        target_tree = self.make_branch_and_tree(
486
 
            "target", format=DummyForeignVcsDirFormat())
 
484
        target_tree = self.make_branch_and_tree("target", 
 
485
            format=DummyForeignVcsDirFormat())
487
486
        target_tree.branch.lock_write()
488
487
        try:
489
488
            pushresult = source_tree.branch.push(
490
489
                target_tree.branch, lossy=True)
491
490
        finally:
492
491
            target_tree.branch.unlock()
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)
 
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)