205
205
rev.timezone, rev.committer, rev.properties,
208
parent_tree = self.target.repository.revision_tree(
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],
216
214
(ie.kind, ie.text_size, ie.executable, ie.text_sha1))
217
215
builder.finish_inventory()
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(
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)
351
348
def register_dummy_foreign_for_test(testcase):
352
349
controldir.ControlDirFormat.register_prober(DummyForeignProber)
353
350
testcase.addCleanup(controldir.ControlDirFormat.unregister_prober,
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)
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)
416
413
class WorkingTreeFileUpdateTests(tests.TestCaseWithTransport):
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())
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)
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)
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()
489
486
pushresult = source_tree.branch.push(
490
487
target_tree.branch, lossy=True)
492
489
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)
490
self.assertEquals(revision.NULL_REVISION, pushresult.old_revid)
491
self.assertEquals({revid1:target_tree.branch.last_revision()},
493
self.assertEquals(pushresult.revidmap[revid1], pushresult.new_revid)