/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/interrepository_implementations/test_interrepository.py

  • Committer: Robert Collins
  • Date: 2007-09-13 03:22:29 UTC
  • mfrom: (2817 +trunk)
  • mto: (2592.3.141 repository)
  • mto: This revision was merged to the branch mainline in revision 2879.
  • Revision ID: robertc@robertcollins.net-20070913032229-vdojubs6akxlk4ao
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 (
 
36
    TestCase,
 
37
    TestCaseWithTransport,
 
38
    TestNotApplicable,
 
39
    TestSkipped,
 
40
    )
36
41
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
37
42
from bzrlib.transport import get_transport
38
43
 
289
294
        # repository.
290
295
 
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,
297
 
                                       timezone=None,
298
 
                                       committer="Foo Bar <foo@example.com>",
299
 
                                       message="Message",
300
 
                                       inventory_sha1=sha1,
301
 
                                       revision_id='ghost')
302
 
        rev.parent_ids = []
303
 
        repo.add_revision('ghost', rev)
 
298
        repo.lock_write()
 
299
        builder = repo.get_commit_builder(None, [], None,
 
300
            committer="Foo Bar <foo@example.com>",
 
301
            revision_id='ghost')
 
302
        ie = bzrlib.inventory.InventoryDirectory('TREE_ROOT', '', None)
 
303
        builder.record_entry_contents(ie, [], '', None)
 
304
        builder.finish_inventory()
 
305
        builder.commit("Message")
 
306
        repo.unlock()
304
307
         
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'))
 
331
 
 
332
 
 
333
class TestFetchDependentData(TestCaseWithInterRepository):
 
334
 
 
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
 
348
        # for subrev 1
 
349
        to_repo.fetch(from_tree.branch.repository, tree_rev)
 
350
        # to_repo should have a file_graph for from_tree.path2id('subtree') and
 
351
        # revid tree_rev.
 
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]))