/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/repository_implementations/test_commit_builder.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
 
33
33
    def record_root(self, builder, tree):
34
34
        if builder.record_root_entry is True:
35
 
            ie = tree.inventory.root
 
35
            tree.lock_read()
 
36
            try:
 
37
                ie = tree.inventory.root
 
38
            finally:
 
39
                tree.unlock()
36
40
            parent_tree = tree.branch.repository.revision_tree(None)
37
41
            parent_invs = []
38
42
            builder.record_entry_contents(ie, parent_invs, '', tree)
86
90
            raise tests.TestSkipped('Format requires root')
87
91
        self.build_tree(['foo'])
88
92
        tree.add('foo', 'foo-id')
89
 
        entry = tree.inventory['foo-id']
90
 
        builder = tree.branch.get_commit_builder([])
91
 
        self.callDeprecated(['Root entry should be supplied to'
92
 
            ' record_entry_contents, as of bzr 0.10.'],
93
 
            builder.record_entry_contents, entry, [], 'foo', tree)
94
 
        builder.finish_inventory()
95
 
        rev_id = builder.commit('foo bar')
 
93
        tree.lock_write()
 
94
        try:
 
95
            entry = tree.inventory['foo-id']
 
96
            builder = tree.branch.get_commit_builder([])
 
97
            self.callDeprecated(['Root entry should be supplied to'
 
98
                ' record_entry_contents, as of bzr 0.10.'],
 
99
                builder.record_entry_contents, entry, [], 'foo', tree)
 
100
            builder.finish_inventory()
 
101
            rev_id = builder.commit('foo bar')
 
102
        finally:
 
103
            tree.unlock()
96
104
 
97
105
    def test_commit(self):
98
106
        tree = self.make_branch_and_tree(".")
118
126
        # the RevisionTree api.
119
127
        self.assertEqual(rev_id, rev_tree.get_revision_id())
120
128
        self.assertEqual([], rev_tree.get_parent_ids())
 
129
 
 
130
    def test_root_entry_has_revision(self):
 
131
        # test the root revision created and put in the basis
 
132
        # has the right rev id.
 
133
        tree = self.make_branch_and_tree('.')
 
134
        rev_id = tree.commit('message')
 
135
        basis_tree = tree.basis_tree()
 
136
        basis_tree.lock_read()
 
137
        self.addCleanup(basis_tree.unlock)
 
138
        self.assertEqual(rev_id, basis_tree.inventory.root.revision)
 
139