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(
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)
351
350
def register_dummy_foreign_for_test(testcase):
352
351
controldir.ControlDirFormat.register_prober(DummyForeignProber)
353
352
testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
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)
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)
416
415
class WorkingTreeFileUpdateTests(tests.TestCaseWithTransport):
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())
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)
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)
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()
489
488
pushresult = source_tree.branch.push(
490
489
target_tree.branch, lossy=True)
492
491
target_tree.branch.unlock()
493
self.assertEqual(revision.NULL_REVISION, pushresult.old_revid)
494
self.assertEqual({revid1: target_tree.branch.last_revision()},
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()},
495
self.assertEquals(pushresult.revidmap[revid1], pushresult.new_revid)