~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

Refactored out ControlFiles and RevisionStore from _Branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
        eq = self.assertEquals
60
60
        eq(b.revno(), 2)
61
61
        rh = b.revision_history()
62
 
        rev = b.get_revision(rh[0])
 
62
        rev = b.storage.get_revision(rh[0])
63
63
        eq(rev.message, 'add hello')
64
64
 
65
 
        tree1 = b.revision_tree(rh[0])
 
65
        tree1 = b.storage.revision_tree(rh[0])
66
66
        text = tree1.get_file_text(file_id)
67
67
        eq(text, 'hello world')
68
68
 
69
 
        tree2 = b.revision_tree(rh[1])
 
69
        tree2 = b.storage.revision_tree(rh[1])
70
70
        eq(tree2.get_file_text(file_id), 'version 2')
71
71
 
72
72
    def test_delete_commit(self):
79
79
        os.remove('hello')
80
80
        b.commit('removed hello', rev_id='rev2')
81
81
 
82
 
        tree = b.revision_tree('rev2')
 
82
        tree = b.storage.revision_tree('rev2')
83
83
        self.assertFalse(tree.has_id('hello-id'))
84
84
 
85
85
 
135
135
        eq = self.assertEquals
136
136
        eq(b.revno(), 3)
137
137
 
138
 
        tree2 = b.revision_tree('test@rev-2')
 
138
        tree2 = b.storage.revision_tree('test@rev-2')
139
139
        self.assertTrue(tree2.has_filename('hello'))
140
140
        self.assertEquals(tree2.get_file_text('hello-id'), 'hello')
141
141
        self.assertEquals(tree2.get_file_text('buongia-id'), 'new text')
142
142
        
143
 
        tree3 = b.revision_tree('test@rev-3')
 
143
        tree3 = b.storage.revision_tree('test@rev-3')
144
144
        self.assertFalse(tree3.has_filename('hello'))
145
145
        self.assertEquals(tree3.get_file_text('buongia-id'), 'new text')
146
146
 
156
156
        b.commit(message='renamed', rev_id='test@rev-2', allow_pointless=False)
157
157
 
158
158
        eq = self.assertEquals
159
 
        tree1 = b.revision_tree('test@rev-1')
 
159
        tree1 = b.storage.revision_tree('test@rev-1')
160
160
        eq(tree1.id2path('hello-id'), 'hello')
161
161
        eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
162
162
        self.assertFalse(tree1.has_filename('fruity'))
164
164
        ie = tree1.inventory['hello-id']
165
165
        eq(ie.revision, 'test@rev-1')
166
166
 
167
 
        tree2 = b.revision_tree('test@rev-2')
 
167
        tree2 = b.storage.revision_tree('test@rev-2')
168
168
        eq(tree2.id2path('hello-id'), 'fruity')
169
169
        eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
170
170
        self.check_inventory_shape(tree2.inventory, ['fruity'])
204
204
        b.commit('three', rev_id=r3, allow_pointless=False)
205
205
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
206
206
                                   ['a', 'a/hello', 'a/b'])
207
 
        self.check_inventory_shape(b.get_revision_inventory(r3),
 
207
        self.check_inventory_shape(b.storage.get_revision_inventory(r3),
208
208
                                   ['a', 'a/hello', 'a/b'])
209
209
 
210
210
        b.move([os.sep.join(['a', 'hello'])],
214
214
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
215
215
                                   ['a', 'a/b/hello', 'a/b'])
216
216
 
217
 
        inv = b.get_revision_inventory(r4)
 
217
        inv = b.storage.get_revision_inventory(r4)
218
218
        eq(inv['hello-id'].revision, r4)
219
219
        eq(inv['a-id'].revision, r1)
220
220
        eq(inv['b-id'].revision, r3)
232
232
        wt.remove('hello')
233
233
        b.commit('removed hello', rev_id='rev2')
234
234
 
235
 
        tree = b.revision_tree('rev2')
 
235
        tree = b.storage.revision_tree('rev2')
236
236
        self.assertFalse(tree.has_id('hello-id'))
237
237
 
238
238
 
260
260
        b.add(['dir', 'dir/file1', 'dir/file2'],
261
261
              ['dirid', 'file1id', 'file2id'])
262
262
        b.commit('dir/file1', specific_files=['dir/file1'], rev_id='1')
263
 
        inv = b.get_inventory('1')
 
263
        inv = b.storage.get_inventory('1')
264
264
        self.assertEqual('1', inv['dirid'].revision)
265
265
        self.assertEqual('1', inv['file1id'].revision)
266
266
        # FIXME: This should raise a KeyError I think, rbc20051006
307
307
        oldstrategy = bzrlib.gpg.GPGStrategy
308
308
        branch = Branch.initialize('.')
309
309
        branch.commit("base", allow_pointless=True, rev_id='A')
310
 
        self.failIf(branch.revision_store.has_id('A', 'sig'))
 
310
        self.failIf(branch.storage.revision_store.has_id('A', 'sig'))
311
311
        try:
312
312
            from bzrlib.testament import Testament
313
313
            # monkey patch gpg signing mechanism
315
315
            commit.Commit(config=MustSignConfig(branch)).commit(branch, "base",
316
316
                                                      allow_pointless=True,
317
317
                                                      rev_id='B')
318
 
            self.assertEqual(Testament.from_revision(branch,'B').as_short_text(),
319
 
                             branch.revision_store.get('B', 'sig').read())
 
318
            self.assertEqual(Testament.from_revision(branch.storage,
 
319
                             'B').as_short_text(),
 
320
                             branch.storage.revision_store.get('B', 
 
321
                                                               'sig').read())
320
322
        finally:
321
323
            bzrlib.gpg.GPGStrategy = oldstrategy
322
324
 
326
328
        oldstrategy = bzrlib.gpg.GPGStrategy
327
329
        branch = Branch.initialize('.')
328
330
        branch.commit("base", allow_pointless=True, rev_id='A')
329
 
        self.failIf(branch.revision_store.has_id('A', 'sig'))
 
331
        self.failIf(branch.storage.revision_store.has_id('A', 'sig'))
330
332
        try:
331
333
            from bzrlib.testament import Testament
332
334
            # monkey patch gpg signing mechanism
339
341
                              rev_id='B')
340
342
            branch = Branch.open('.')
341
343
            self.assertEqual(branch.revision_history(), ['A'])
342
 
            self.failIf(branch.revision_store.has_id('B'))
 
344
            self.failIf(branch.storage.revision_store.has_id('B'))
343
345
        finally:
344
346
            bzrlib.gpg.GPGStrategy = oldstrategy
345
347