32
32
import bzrlib.repofmt.weaverepo as weaverepo
33
33
import bzrlib.repository as repository
34
34
from bzrlib.revision import NULL_REVISION, Revision
35
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
35
from bzrlib.tests import (
37
TestCaseWithTransport,
36
41
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
37
42
from bzrlib.transport import get_transport
291
296
# 'ghost' is a ghost in missing_ghost and not in with_ghost_rev
292
inv = Inventory(revision_id='ghost')
293
inv.root.revision = 'ghost'
294
297
repo = self.make_repository('with_ghost_rev')
295
sha1 = repo.add_inventory('ghost', inv, [])
296
rev = bzrlib.revision.Revision(timestamp=0,
298
committer="Foo Bar <foo@example.com>",
303
repo.add_revision('ghost', rev)
299
builder = repo.get_commit_builder(None, [], None,
300
committer="Foo Bar <foo@example.com>",
302
ie = bzrlib.inventory.InventoryDirectory('TREE_ROOT', '', None)
303
builder.record_entry_contents(ie, [], '', None)
304
builder.finish_inventory()
305
builder.commit("Message")
305
308
repo = self.make_to_repository('missing_ghost')
306
309
inv = Inventory(revision_id='with_ghost')
325
328
# rev must not be corrupt now
326
329
rev = repo.get_revision('with_ghost')
327
330
self.assertEqual([None, 'ghost', 'with_ghost'], repo.get_ancestry('with_ghost'))
333
class TestFetchDependentData(TestCaseWithInterRepository):
335
def test_reference(self):
336
from_tree = self.make_branch_and_tree('tree')
337
to_repo = self.make_to_repository('to')
338
if (not from_tree.supports_tree_reference() or
339
not from_tree.branch.repository._format.supports_tree_reference or
340
not to_repo._format.supports_tree_reference):
341
raise TestNotApplicable("Need subtree support.")
342
subtree = self.make_branch_and_tree('tree/subtree')
343
subtree.commit('subrev 1')
344
from_tree.add_reference(subtree)
345
tree_rev = from_tree.commit('foo')
346
# now from_tree has a last-modified of subtree of the rev id of the
347
# commit for foo, and a reference revision of the rev id of the commit
349
to_repo.fetch(from_tree.branch.repository, tree_rev)
350
# to_repo should have a file_graph for from_tree.path2id('subtree') and
352
file_vf = to_repo.weave_store.get_weave(
353
from_tree.path2id('subtree'), to_repo.get_transaction())
354
self.assertEqual([tree_rev], file_vf.get_ancestry([tree_rev]))