~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_foreign.py

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

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
205
205
                        rev.timezone, rev.committer, rev.properties,
206
206
                        new_revid)
207
207
                try:
208
 
                    parent_tree = self.target.repository.revision_tree(
209
 
                        parent_revid)
210
 
                    for path, ie in tree.iter_entries_by_dir():
 
208
                    for path, ie in tree.inventory.iter_entries():
211
209
                        new_ie = ie.copy()
212
210
                        new_ie.revision = None
213
211
                        builder.record_entry_contents(new_ie, 
214
 
                            [parent_tree.root_inventory],
 
212
                            [self.target.repository.revision_tree(parent_revid).inventory],
215
213
                            path, tree, 
216
214
                            (ie.kind, ie.text_size, ie.executable, ie.text_sha1))
217
215
                    builder.finish_inventory()
321
319
        return super(DummyForeignVcsDir, self).create_workingtree()
322
320
 
323
321
    def open_branch(self, name=None, unsupported=False, ignore_fallbacks=True,
324
 
                    possible_transports=None):
 
322
            possible_transports=None):
325
323
        if name is None:
326
324
            name = self._get_selected_branch()
327
325
        if name != "":
330
328
 
331
329
    def cloning_metadir(self, stacked=False):
332
330
        """Produce a metadir suitable for cloning with."""
333
 
        return controldir.format_registry.make_bzrdir("default")
 
331
        return bzrdir.format_registry.make_bzrdir("default")
334
332
 
335
333
    def checkout_metadir(self):
336
334
        return self.cloning_metadir()
339
337
               recurse='down', possible_transports=None,
340
338
               accelerator_tree=None, hardlink=False, stacked=False,
341
339
               source_branch=None):
342
 
        # dirstate doesn't cope with accelerator_trees well
 
340
        # dirstate doesn't cope with accelerator_trees well 
343
341
        # 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)
 
342
        return super(DummyForeignVcsDir, self).sprout(url=url, 
 
343
                revision_id=revision_id, force_new_repo=force_new_repo, 
 
344
                recurse=recurse, possible_transports=possible_transports, 
 
345
                hardlink=hardlink, stacked=stacked, source_branch=source_branch)
349
346
 
350
347
 
351
348
def register_dummy_foreign_for_test(testcase):
352
349
    controldir.ControlDirFormat.register_prober(DummyForeignProber)
353
350
    testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
354
 
                        DummyForeignProber)
 
351
        DummyForeignProber)
355
352
    repository.format_registry.register(DummyForeignVcsRepositoryFormat())
356
353
    testcase.addCleanup(repository.format_registry.remove,
357
 
                        DummyForeignVcsRepositoryFormat())
 
354
            DummyForeignVcsRepositoryFormat())
358
355
    branch.format_registry.register(DummyForeignVcsBranchFormat())
359
356
    testcase.addCleanup(branch.format_registry.remove,
360
 
                        DummyForeignVcsBranchFormat())
 
357
            DummyForeignVcsBranchFormat())
361
358
    # We need to register the optimiser to make the dummy appears really
362
359
    # different from a regular bzr repository.
363
360
    branch.InterBranch.register_optimiser(InterToDummyVcsBranch)
396
393
        reg = foreign.ForeignVcsRegistry()
397
394
        vcs = DummyForeignVcs()
398
395
        reg.register("dummy", vcs, "Dummy VCS")
399
 
        self.assertEqual((
 
396
        self.assertEquals((
400
397
            ("some", "foreign", "revid"), DummyForeignVcsMapping(vcs)),
401
398
            reg.parse_revision_id("dummy-v1:some-foreign-revid"))
402
399
 
408
405
        mapp = DummyForeignVcsMapping(DummyForeignVcs())
409
406
        rev = foreign.ForeignRevision(("a", "foreign", "revid"),
410
407
                                      mapp, "roundtripped-revid")
411
 
        self.assertEqual("", rev.inventory_sha1)
412
 
        self.assertEqual(("a", "foreign", "revid"), rev.foreign_revid)
413
 
        self.assertEqual(mapp, rev.mapping)
 
408
        self.assertEquals("", rev.inventory_sha1)
 
409
        self.assertEquals(("a", "foreign", "revid"), rev.foreign_revid)
 
410
        self.assertEquals(mapp, rev.mapping)
414
411
 
415
412
 
416
413
class WorkingTreeFileUpdateTests(tests.TestCaseWithTransport):
432
429
        foreign.update_workingtree_fileids(wt, target_basis)
433
430
        wt.lock_read()
434
431
        try:
435
 
            self.assertEqual(set([root_id, "bla-b"]), set(wt.all_file_ids()))
 
432
            self.assertEquals(set([root_id, "bla-b"]), set(wt.inventory))
436
433
        finally:
437
434
            wt.unlock()
438
435
 
447
444
    def test_create(self):
448
445
        """Test we can create dummies."""
449
446
        self.make_branch_and_tree("d", format=DummyForeignVcsDirFormat())
450
 
        dir = controldir.ControlDir.open("d")
451
 
        self.assertEqual("A Dummy VCS Dir", dir._format.get_format_string())
 
447
        dir = bzrdir.BzrDir.open("d")
 
448
        self.assertEquals("A Dummy VCS Dir", dir._format.get_format_string())
452
449
        dir.open_repository()
453
450
        dir.open_branch()
454
451
        dir.open_workingtree()
456
453
    def test_sprout(self):
457
454
        """Test we can clone dummies and that the format is not preserved."""
458
455
        self.make_branch_and_tree("d", format=DummyForeignVcsDirFormat())
459
 
        dir = controldir.ControlDir.open("d")
 
456
        dir = bzrdir.BzrDir.open("d")
460
457
        newdir = dir.sprout("e")
461
 
        self.assertNotEqual("A Dummy VCS Dir",
462
 
                            newdir._format.get_format_string())
 
458
        self.assertNotEquals("A Dummy VCS Dir",
 
459
                             newdir._format.get_format_string())
463
460
 
464
461
    def test_push_not_supported(self):
465
462
        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)
 
463
        target_tree = self.make_branch_and_tree("target", 
 
464
            format=DummyForeignVcsDirFormat())
 
465
        self.assertRaises(errors.NoRoundtrippingSupport, 
 
466
            source_tree.branch.push, target_tree.branch)
470
467
 
471
468
    def test_lossy_push_empty(self):
472
469
        source_tree = self.make_branch_and_tree("source")
473
 
        target_tree = self.make_branch_and_tree(
474
 
            "target", format=DummyForeignVcsDirFormat())
 
470
        target_tree = self.make_branch_and_tree("target", 
 
471
            format=DummyForeignVcsDirFormat())
475
472
        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)
 
473
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
 
474
        self.assertEquals(revision.NULL_REVISION, pushresult.new_revid)
 
475
        self.assertEquals({}, pushresult.revidmap)
479
476
 
480
477
    def test_lossy_push_simple(self):
481
478
        source_tree = self.make_branch_and_tree("source")
482
479
        self.build_tree(['source/a', 'source/b'])
483
480
        source_tree.add(['a', 'b'])
484
481
        revid1 = source_tree.commit("msg")
485
 
        target_tree = self.make_branch_and_tree(
486
 
            "target", format=DummyForeignVcsDirFormat())
 
482
        target_tree = self.make_branch_and_tree("target", 
 
483
            format=DummyForeignVcsDirFormat())
487
484
        target_tree.branch.lock_write()
488
485
        try:
489
486
            pushresult = source_tree.branch.push(
490
487
                target_tree.branch, lossy=True)
491
488
        finally:
492
489
            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)
 
490
        self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
 
491
        self.assertEquals({revid1:target_tree.branch.last_revision()}, 
 
492
                           pushresult.revidmap)
 
493
        self.assertEquals(pushresult.revidmap[revid1], pushresult.new_revid)