/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/selftest/testbranch.py

Refactored out ControlFiles and RevisionStore from _Branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        eq(f.count_copied, 1)
60
60
        eq(f.last_revision, 'revision-1')
61
61
 
62
 
        rev = b2.get_revision('revision-1')
63
 
        tree = b2.revision_tree('revision-1')
 
62
        rev = b2.storage.get_revision('revision-1')
 
63
        tree = b2.storage.revision_tree('revision-1')
64
64
        eq(tree.get_file_text('foo-id'), 'hello')
65
65
 
66
66
    def test_revision_tree(self):
67
67
        b1 = Branch.initialize('.')
68
68
        b1.commit('lala!', rev_id='revision-1', allow_pointless=True)
69
 
        tree = b1.revision_tree('revision-1')
70
 
        tree = b1.revision_tree(None)
 
69
        tree = b1.storage.revision_tree('revision-1')
 
70
        tree = b1.storage.revision_tree(None)
71
71
        self.assertEqual(len(tree.list_files()), 0)
72
 
        tree = b1.revision_tree(NULL_REVISION)
 
72
        tree = b1.storage.revision_tree(NULL_REVISION)
73
73
        self.assertEqual(len(tree.list_files()), 0)
74
74
 
75
75
    def get_unbalanced_branch_pair(self):
93
93
        """Copy the stores from one branch to another"""
94
94
        br_a, br_b = self.get_unbalanced_branch_pair()
95
95
        # ensure the revision is missing.
96
 
        self.assertRaises(NoSuchRevision, br_b.get_revision, 
 
96
        self.assertRaises(NoSuchRevision, br_b.storage.get_revision, 
97
97
                          br_a.revision_history()[0])
98
98
        br_a.push_stores(br_b)
99
99
        # check that b now has all the data from a's first commit.
100
 
        rev = br_b.get_revision(br_a.revision_history()[0])
101
 
        tree = br_b.revision_tree(br_a.revision_history()[0])
 
100
        rev = br_b.storage.get_revision(br_a.revision_history()[0])
 
101
        tree = br_b.storage.revision_tree(br_a.revision_history()[0])
102
102
        for file_id in tree:
103
103
            if tree.inventory[file_id].kind == "file":
104
104
                tree.get_file(file_id).read()
131
131
        branch = Branch.initialize('.')
132
132
        branch.add_pending_merge('non:existent@rev--ision--0--2')
133
133
        branch.commit('pretend to merge nonexistent-revision', rev_id='first')
134
 
        rev = branch.get_revision(branch.last_revision())
 
134
        rev = branch.storage.get_revision(branch.last_revision())
135
135
        self.assertEqual(len(rev.parent_ids), 1)
136
136
        # parent_sha1s is not populated now, WTF. rbc 20051003
137
137
        self.assertEqual(len(rev.parent_sha1s), 0)
139
139
 
140
140
    def test_bad_revision(self):
141
141
        branch = Branch.initialize('.')
142
 
        self.assertRaises(errors.InvalidRevisionId, branch.get_revision, None)
 
142
        self.assertRaises(errors.InvalidRevisionId, 
 
143
                          branch.storage.get_revision, None)
143
144
 
144
145
# TODO 20051003 RBC:
145
146
# compare the gpg-to-sign info for a commit with a ghost and 
160
161
                          ['foo@azkhazan-123123-abcabc',
161
162
                           'wibble@fofof--20050401--1928390812'])
162
163
        b.commit("commit from base with two merges")
163
 
        rev = b.get_revision(b.revision_history()[0])
 
164
        rev = b.storage.get_revision(b.revision_history()[0])
164
165
        self.assertEquals(len(rev.parent_ids), 2)
165
166
        self.assertEquals(rev.parent_ids[0],
166
167
                          'foo@azkhazan-123123-abcabc')
173
174
        branch = Branch.initialize('.')
174
175
        branch.commit("base", allow_pointless=True, rev_id='A')
175
176
        from bzrlib.testament import Testament
176
 
        branch.sign_revision('A', bzrlib.gpg.LoopbackGPGStrategy(None))
177
 
        self.assertEqual(Testament.from_revision(branch, 'A').as_short_text(),
178
 
                         branch.revision_store.get('A', 'sig').read())
 
177
        branch.storage.sign_revision('A', bzrlib.gpg.LoopbackGPGStrategy(None))
 
178
        self.assertEqual(Testament.from_revision(branch.storage, 
 
179
                         'A').as_short_text(),
 
180
                         branch.storage.revision_store.get('A', 'sig').read())
179
181
 
180
182
    def test_store_signature(self):
181
183
        branch = Branch.initialize('.')
182
 
        branch.store_revision_signature(bzrlib.gpg.LoopbackGPGStrategy(None),
183
 
                                        'FOO', 'A')
184
 
        self.assertEqual('FOO', branch.revision_store.get('A', 'sig').read())
 
184
        branch.storage.store_revision_signature(
 
185
            bzrlib.gpg.LoopbackGPGStrategy(None), 'FOO', 'A')
 
186
        self.assertEqual('FOO', 
 
187
                         branch.storage.revision_store.get('A', 'sig').read())
185
188
 
186
189
    def test__relcontrolfilename(self):
187
190
        branch = Branch.initialize('.')
215
218
        branch = Branch.initialize('bzr.dev')
216
219
        branch.nick = "My happy branch"
217
220
        branch.commit('My commit respect da nick.')
218
 
        committed = branch.get_revision(branch.last_revision())
 
221
        committed = branch.storage.get_revision(branch.last_revision())
219
222
        self.assertEqual(committed.properties["branch-nick"], 
220
223
                         "My happy branch")
221
224