~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

  • Committer: Aaron Bentley
  • Date: 2005-12-25 00:38:48 UTC
  • mto: (1185.67.11 bzr.revision-storage)
  • mto: This revision was merged to the branch mainline in revision 1550.
  • Revision ID: aaron.bentley@utoronto.ca-20051225003848-111ac71170cb2605
Renamed Branch.storage to Branch.repository

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.storage.get_revision(rh[0])
 
62
        rev = b.repository.get_revision(rh[0])
63
63
        eq(rev.message, 'add hello')
64
64
 
65
 
        tree1 = b.storage.revision_tree(rh[0])
 
65
        tree1 = b.repository.revision_tree(rh[0])
66
66
        text = tree1.get_file_text(file_id)
67
67
        eq(text, 'hello world')
68
68
 
69
 
        tree2 = b.storage.revision_tree(rh[1])
 
69
        tree2 = b.repository.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.working_tree().commit('removed hello', rev_id='rev2')
81
81
 
82
 
        tree = b.storage.revision_tree('rev2')
 
82
        tree = b.repository.revision_tree('rev2')
83
83
        self.assertFalse(tree.has_id('hello-id'))
84
84
 
85
85
    def test_pointless_commit(self):
132
132
        eq = self.assertEquals
133
133
        eq(b.revno(), 3)
134
134
 
135
 
        tree2 = b.storage.revision_tree('test@rev-2')
 
135
        tree2 = b.repository.revision_tree('test@rev-2')
136
136
        self.assertTrue(tree2.has_filename('hello'))
137
137
        self.assertEquals(tree2.get_file_text('hello-id'), 'hello')
138
138
        self.assertEquals(tree2.get_file_text('buongia-id'), 'new text')
139
139
        
140
 
        tree3 = b.storage.revision_tree('test@rev-3')
 
140
        tree3 = b.repository.revision_tree('test@rev-3')
141
141
        self.assertFalse(tree3.has_filename('hello'))
142
142
        self.assertEquals(tree3.get_file_text('buongia-id'), 'new text')
143
143
 
154
154
        tree.commit(message='renamed', rev_id='test@rev-2', allow_pointless=False)
155
155
 
156
156
        eq = self.assertEquals
157
 
        tree1 = b.storage.revision_tree('test@rev-1')
 
157
        tree1 = b.repository.revision_tree('test@rev-1')
158
158
        eq(tree1.id2path('hello-id'), 'hello')
159
159
        eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
160
160
        self.assertFalse(tree1.has_filename('fruity'))
162
162
        ie = tree1.inventory['hello-id']
163
163
        eq(ie.revision, 'test@rev-1')
164
164
 
165
 
        tree2 = b.storage.revision_tree('test@rev-2')
 
165
        tree2 = b.repository.revision_tree('test@rev-2')
166
166
        eq(tree2.id2path('hello-id'), 'fruity')
167
167
        eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
168
168
        self.check_inventory_shape(tree2.inventory, ['fruity'])
198
198
        b.working_tree().commit('three', rev_id=r3, allow_pointless=False)
199
199
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
200
200
                                   ['a', 'a/hello', 'a/b'])
201
 
        self.check_inventory_shape(b.storage.get_revision_inventory(r3),
 
201
        self.check_inventory_shape(b.repository.get_revision_inventory(r3),
202
202
                                   ['a', 'a/hello', 'a/b'])
203
203
 
204
204
        b.working_tree().move([os.sep.join(['a', 'hello'])],
208
208
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
209
209
                                   ['a', 'a/b/hello', 'a/b'])
210
210
 
211
 
        inv = b.storage.get_revision_inventory(r4)
 
211
        inv = b.repository.get_revision_inventory(r4)
212
212
        eq(inv['hello-id'].revision, r4)
213
213
        eq(inv['a-id'].revision, r1)
214
214
        eq(inv['b-id'].revision, r3)
225
225
        wt.remove('hello')
226
226
        b.working_tree().commit('removed hello', rev_id='rev2')
227
227
 
228
 
        tree = b.storage.revision_tree('rev2')
 
228
        tree = b.repository.revision_tree('rev2')
229
229
        self.assertFalse(tree.has_id('hello-id'))
230
230
 
231
231
 
244
244
        eq = self.assertEquals
245
245
        eq(b.revision_history(), rev_ids)
246
246
        for i in range(4):
247
 
            anc = b.storage.get_ancestry(rev_ids[i])
 
247
            anc = b.repository.get_ancestry(rev_ids[i])
248
248
            eq(anc, [None] + rev_ids[:i+1])
249
249
 
250
250
    def test_commit_new_subdir_child_selective(self):
253
253
        b.working_tree().add(['dir', 'dir/file1', 'dir/file2'],
254
254
              ['dirid', 'file1id', 'file2id'])
255
255
        b.working_tree().commit('dir/file1', specific_files=['dir/file1'], rev_id='1')
256
 
        inv = b.storage.get_inventory('1')
 
256
        inv = b.repository.get_inventory('1')
257
257
        self.assertEqual('1', inv['dirid'].revision)
258
258
        self.assertEqual('1', inv['file1id'].revision)
259
259
        # FIXME: This should raise a KeyError I think, rbc20051006
300
300
        oldstrategy = bzrlib.gpg.GPGStrategy
301
301
        branch = Branch.initialize(u'.')
302
302
        branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
303
 
        self.failIf(branch.storage.revision_store.has_id('A', 'sig'))
 
303
        self.failIf(branch.repository.revision_store.has_id('A', 'sig'))
304
304
        try:
305
305
            from bzrlib.testament import Testament
306
306
            # monkey patch gpg signing mechanism
308
308
            commit.Commit(config=MustSignConfig(branch)).commit(branch, "base",
309
309
                                                      allow_pointless=True,
310
310
                                                      rev_id='B')
311
 
            self.assertEqual(Testament.from_revision(branch.storage,
 
311
            self.assertEqual(Testament.from_revision(branch.repository,
312
312
                             'B').as_short_text(),
313
 
                             branch.storage.revision_store.get('B', 
 
313
                             branch.repository.revision_store.get('B', 
314
314
                                                               'sig').read())
315
315
        finally:
316
316
            bzrlib.gpg.GPGStrategy = oldstrategy
321
321
        oldstrategy = bzrlib.gpg.GPGStrategy
322
322
        branch = Branch.initialize(u'.')
323
323
        branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
324
 
        self.failIf(branch.storage.revision_store.has_id('A', 'sig'))
 
324
        self.failIf(branch.repository.revision_store.has_id('A', 'sig'))
325
325
        try:
326
326
            from bzrlib.testament import Testament
327
327
            # monkey patch gpg signing mechanism
334
334
                              rev_id='B')
335
335
            branch = Branch.open(u'.')
336
336
            self.assertEqual(branch.revision_history(), ['A'])
337
 
            self.failIf(branch.storage.revision_store.has_id('B'))
 
337
            self.failIf(branch.repository.revision_store.has_id('B'))
338
338
        finally:
339
339
            bzrlib.gpg.GPGStrategy = oldstrategy
340
340