~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_commit.py

  • Committer: Martin Pool
  • Date: 2006-01-30 06:23:50 UTC
  • mfrom: (1534.1.17 integration)
  • Revision ID: mbp@sourcefrog.net-20060130062350-d6f25277ddcdfd79
[merge] robert's integration of much recent work

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