/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/test_branchbuilder.py

  • Committer: John Arbash Meinel
  • Date: 2008-07-22 17:03:55 UTC
  • mto: (3514.4.6 merge_lca_multi)
  • mto: This revision was merged to the branch mainline in revision 3590.
  • Revision ID: john@arbash-meinel.com-20080722170355-00mcj4j1a8pdsout
Initial work to have BranchBuilder allow us to do tree-shape work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
class TestBranchBuilder(tests.TestCaseWithMemoryTransport):
28
28
    
 
29
    def assertTreeShape(self, entries, tree):
 
30
        """Check that the tree shape matches expectations."""
 
31
 
29
32
    def test_create(self):
30
33
        """Test the constructor api."""
31
34
        builder = BranchBuilder(self.get_transport().clone('foo'))
71
74
        self.assertEqual(
72
75
            [rev_id1],
73
76
            branch.repository.get_revision(branch.last_revision()).parent_ids)
 
77
 
 
78
    def test_build_snapshot(self):
 
79
        builder = BranchBuilder(self.get_transport().clone('foo'))
 
80
        rev_id1 = builder.build_snapshot(None, 'A-id',
 
81
            [('add', ('', 'a-root-id', 'directory', None)),
 
82
             ('add', ('a', 'a-id', 'file', 'contents'))])
 
83
        self.assertEqual('A-id', rev_id1)
 
84
        branch = builder.get_branch()
 
85
        self.assertEqual((1, rev_id1), branch.last_revision_info())
 
86
        rev_tree = branch.repository.revision_tree(rev_id1)
 
87
        rev_tree.lock_read()
 
88
        self.addCleanup(rev_tree.unlock)
 
89
        entries = [(path, ie.file_id, ie.kind)
 
90
                   for path, ie in rev_tree.iter_entries_by_dir()]
 
91
        self.assertEqual([(u'', 'a-root-id', 'directory'),
 
92
                          (u'a', 'a-id', 'file')], entries)
 
93
        self.assertEqual('contents', rev_tree.get_file_text('a-id'))