~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

first cut at merge from integration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
        eq = self.assertEquals
61
61
        eq(b.revno(), 2)
62
62
        rh = b.revision_history()
63
 
        rev = b.get_revision(rh[0])
 
63
        rev = b.repository.get_revision(rh[0])
64
64
        eq(rev.message, 'add hello')
65
65
 
66
 
        tree1 = b.revision_tree(rh[0])
 
66
        tree1 = b.repository.revision_tree(rh[0])
67
67
        text = tree1.get_file_text(file_id)
68
68
        eq(text, 'hello world')
69
69
 
70
 
        tree2 = b.revision_tree(rh[1])
 
70
        tree2 = b.repository.revision_tree(rh[1])
71
71
        eq(tree2.get_file_text(file_id), 'version 2')
72
72
 
73
73
    def test_delete_commit(self):
81
81
        os.remove('hello')
82
82
        wt.commit('removed hello', rev_id='rev2')
83
83
 
84
 
        tree = b.revision_tree('rev2')
 
84
        tree = b.repository.revision_tree('rev2')
85
85
        self.assertFalse(tree.has_id('hello-id'))
86
86
 
87
87
    def test_pointless_commit(self):
136
136
        eq = self.assertEquals
137
137
        eq(b.revno(), 3)
138
138
 
139
 
        tree2 = b.revision_tree('test@rev-2')
 
139
        tree2 = b.repository.revision_tree('test@rev-2')
140
140
        self.assertTrue(tree2.has_filename('hello'))
141
141
        self.assertEquals(tree2.get_file_text('hello-id'), 'hello')
142
142
        self.assertEquals(tree2.get_file_text('buongia-id'), 'new text')
143
143
        
144
 
        tree3 = b.revision_tree('test@rev-3')
 
144
        tree3 = b.repository.revision_tree('test@rev-3')
145
145
        self.assertFalse(tree3.has_filename('hello'))
146
146
        self.assertEquals(tree3.get_file_text('buongia-id'), 'new text')
147
147
 
157
157
        tree.commit(message='renamed', rev_id='test@rev-2', allow_pointless=False)
158
158
 
159
159
        eq = self.assertEquals
160
 
        tree1 = b.revision_tree('test@rev-1')
 
160
        tree1 = b.repository.revision_tree('test@rev-1')
161
161
        eq(tree1.id2path('hello-id'), 'hello')
162
162
        eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
163
163
        self.assertFalse(tree1.has_filename('fruity'))
165
165
        ie = tree1.inventory['hello-id']
166
166
        eq(ie.revision, 'test@rev-1')
167
167
 
168
 
        tree2 = b.revision_tree('test@rev-2')
 
168
        tree2 = b.repository.revision_tree('test@rev-2')
169
169
        eq(tree2.id2path('hello-id'), 'fruity')
170
170
        eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
171
171
        self.check_inventory_shape(tree2.inventory, ['fruity'])
203
203
        wt.commit('three', rev_id=r3, allow_pointless=False)
204
204
        self.check_inventory_shape(wt.read_working_inventory(),
205
205
                                   ['a', 'a/hello', 'a/b'])
206
 
        self.check_inventory_shape(b.get_revision_inventory(r3),
 
206
        self.check_inventory_shape(b.repository.get_revision_inventory(r3),
207
207
                                   ['a', 'a/hello', 'a/b'])
208
208
 
209
209
        wt.move(['a/hello'], 'a/b')
212
212
        self.check_inventory_shape(wt.read_working_inventory(),
213
213
                                   ['a', 'a/b/hello', 'a/b'])
214
214
 
215
 
        inv = b.get_revision_inventory(r4)
 
215
        inv = b.repository.get_revision_inventory(r4)
216
216
        eq(inv['hello-id'].revision, r4)
217
217
        eq(inv['a-id'].revision, r1)
218
218
        eq(inv['b-id'].revision, r3)
227
227
        wt.remove('hello')
228
228
        wt.commit('removed hello', rev_id='rev2')
229
229
 
230
 
        tree = b.revision_tree('rev2')
 
230
        tree = b.repository.revision_tree('rev2')
231
231
        self.assertFalse(tree.has_id('hello-id'))
232
232
 
233
233
    def test_committed_ancestry(self):
246
246
        eq = self.assertEquals
247
247
        eq(b.revision_history(), rev_ids)
248
248
        for i in range(4):
249
 
            anc = b.get_ancestry(rev_ids[i])
 
249
            anc = b.repository.get_ancestry(rev_ids[i])
250
250
            eq(anc, [None] + rev_ids[:i+1])
251
251
 
252
252
    def test_commit_new_subdir_child_selective(self):
256
256
        wt.add(['dir', 'dir/file1', 'dir/file2'],
257
257
              ['dirid', 'file1id', 'file2id'])
258
258
        wt.commit('dir/file1', specific_files=['dir/file1'], rev_id='1')
259
 
        inv = b.get_inventory('1')
 
259
        inv = b.repository.get_inventory('1')
260
260
        self.assertEqual('1', inv['dirid'].revision)
261
261
        self.assertEqual('1', inv['file1id'].revision)
262
262
        # FIXME: This should raise a KeyError I think, rbc20051006
308
308
        wt = self.make_branch_and_tree('.')
309
309
        branch = wt.branch
310
310
        wt.commit("base", allow_pointless=True, rev_id='A')
311
 
        self.failIf(branch.revision_store.has_id('A', 'sig'))
 
311
        self.failIf(branch.repository.revision_store.has_id('A', 'sig'))
312
312
        try:
313
313
            from bzrlib.testament import Testament
314
314
            # monkey patch gpg signing mechanism
317
317
                                                      allow_pointless=True,
318
318
                                                      rev_id='B',
319
319
                                                      working_tree=wt)
320
 
            self.assertEqual(Testament.from_revision(branch,'B').as_short_text(),
321
 
                             branch.revision_store.get('B', 'sig').read())
 
320
            self.assertEqual(Testament.from_revision(branch.repository,
 
321
                             'B').as_short_text(),
 
322
                             branch.repository.revision_store.get('B', 
 
323
                                                               'sig').read())
322
324
        finally:
323
325
            bzrlib.gpg.GPGStrategy = oldstrategy
324
326
 
329
331
        wt = self.make_branch_and_tree('.')
330
332
        branch = wt.branch
331
333
        wt.commit("base", allow_pointless=True, rev_id='A')
332
 
        self.failIf(branch.revision_store.has_id('A', 'sig'))
 
334
        self.failIf(branch.repository.revision_store.has_id('A', 'sig'))
333
335
        try:
334
336
            from bzrlib.testament import Testament
335
337
            # monkey patch gpg signing mechanism
342
344
                              rev_id='B')
343
345
            branch = Branch.open(self.get_url('.'))
344
346
            self.assertEqual(branch.revision_history(), ['A'])
345
 
            self.failIf(branch.revision_store.has_id('B'))
 
347
            self.failIf(branch.repository.revision_store.has_id('B'))
346
348
        finally:
347
349
            bzrlib.gpg.GPGStrategy = oldstrategy
348
350