~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

MergeĀ fromĀ jam-integration

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.repository.get_revision(rh[0])
63
63
        eq(rev.message, 'add hello')
64
64
 
65
 
        tree1 = b.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.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.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.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.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.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.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.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
 
        b.working_tree().move([os.sep.join(['a', 'hello'])],
205
 
               os.sep.join(['a', 'b']))
 
204
        b.working_tree().move(['a/hello'], 'a/b')
206
205
        r4 = 'test@rev-4'
207
206
        b.working_tree().commit('four', rev_id=r4, allow_pointless=False)
208
207
        self.check_inventory_shape(b.working_tree().read_working_inventory(),
209
208
                                   ['a', 'a/b/hello', 'a/b'])
210
209
 
211
 
        inv = b.get_revision_inventory(r4)
 
210
        inv = b.repository.get_revision_inventory(r4)
212
211
        eq(inv['hello-id'].revision, r4)
213
212
        eq(inv['a-id'].revision, r1)
214
213
        eq(inv['b-id'].revision, r3)
225
224
        wt.remove('hello')
226
225
        b.working_tree().commit('removed hello', rev_id='rev2')
227
226
 
228
 
        tree = b.revision_tree('rev2')
 
227
        tree = b.repository.revision_tree('rev2')
229
228
        self.assertFalse(tree.has_id('hello-id'))
230
229
 
231
230
 
244
243
        eq = self.assertEquals
245
244
        eq(b.revision_history(), rev_ids)
246
245
        for i in range(4):
247
 
            anc = b.get_ancestry(rev_ids[i])
 
246
            anc = b.repository.get_ancestry(rev_ids[i])
248
247
            eq(anc, [None] + rev_ids[:i+1])
249
248
 
250
249
    def test_commit_new_subdir_child_selective(self):
253
252
        b.working_tree().add(['dir', 'dir/file1', 'dir/file2'],
254
253
              ['dirid', 'file1id', 'file2id'])
255
254
        b.working_tree().commit('dir/file1', specific_files=['dir/file1'], rev_id='1')
256
 
        inv = b.get_inventory('1')
 
255
        inv = b.repository.get_inventory('1')
257
256
        self.assertEqual('1', inv['dirid'].revision)
258
257
        self.assertEqual('1', inv['file1id'].revision)
259
258
        # FIXME: This should raise a KeyError I think, rbc20051006
300
299
        oldstrategy = bzrlib.gpg.GPGStrategy
301
300
        branch = Branch.initialize(u'.')
302
301
        branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
303
 
        self.failIf(branch.revision_store.has_id('A', 'sig'))
 
302
        self.failIf(branch.repository.revision_store.has_id('A', 'sig'))
304
303
        try:
305
304
            from bzrlib.testament import Testament
306
305
            # monkey patch gpg signing mechanism
308
307
            commit.Commit(config=MustSignConfig(branch)).commit(branch, "base",
309
308
                                                      allow_pointless=True,
310
309
                                                      rev_id='B')
311
 
            self.assertEqual(Testament.from_revision(branch,'B').as_short_text(),
312
 
                             branch.revision_store.get('B', 'sig').read())
 
310
            self.assertEqual(Testament.from_revision(branch.repository,
 
311
                             'B').as_short_text(),
 
312
                             branch.repository.revision_store.get('B', 
 
313
                                                               'sig').read())
313
314
        finally:
314
315
            bzrlib.gpg.GPGStrategy = oldstrategy
315
316
 
319
320
        oldstrategy = bzrlib.gpg.GPGStrategy
320
321
        branch = Branch.initialize(u'.')
321
322
        branch.working_tree().commit("base", allow_pointless=True, rev_id='A')
322
 
        self.failIf(branch.revision_store.has_id('A', 'sig'))
 
323
        self.failIf(branch.repository.revision_store.has_id('A', 'sig'))
323
324
        try:
324
325
            from bzrlib.testament import Testament
325
326
            # monkey patch gpg signing mechanism
332
333
                              rev_id='B')
333
334
            branch = Branch.open(u'.')
334
335
            self.assertEqual(branch.revision_history(), ['A'])
335
 
            self.failIf(branch.revision_store.has_id('B'))
 
336
            self.failIf(branch.repository.revision_store.has_id('B'))
336
337
        finally:
337
338
            bzrlib.gpg.GPGStrategy = oldstrategy
338
339