~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

  • Committer: Robert Collins
  • Date: 2005-09-27 07:24:40 UTC
  • mfrom: (1185.1.41)
  • Revision ID: robertc@robertcollins.net-20050927072440-1bf4d99c3e1db5b3
pair programming worx... merge integration and weave

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
# TODO: Test commit with some added, and added-but-missing files
27
27
 
28
28
class TestCommit(TestCaseInTempDir):
 
29
 
29
30
    def test_simple_commit(self):
30
31
        """Commit and check two versions of a single file."""
31
 
        b = Branch('.', init=True)
 
32
        b = Branch.initialize('.')
32
33
        file('hello', 'w').write('hello world')
33
34
        b.add('hello')
34
35
        b.commit(message='add hello')
53
54
 
54
55
    def test_delete_commit(self):
55
56
        """Test a commit with a deleted file"""
56
 
        b = Branch('.', init=True)
 
57
        b = Branch.initialize('.')
57
58
        file('hello', 'w').write('hello world')
58
59
        b.add(['hello'], ['hello-id'])
59
60
        b.commit(message='add hello')
67
68
 
68
69
    def test_pointless_commit(self):
69
70
        """Commit refuses unless there are changes or it's forced."""
70
 
        b = Branch('.', init=True)
 
71
        b = Branch.initialize('.')
71
72
        file('hello', 'w').write('hello')
72
73
        b.add(['hello'])
73
74
        b.commit(message='add hello')
82
83
 
83
84
    def test_commit_empty(self):
84
85
        """Commiting an empty tree works."""
85
 
        b = Branch('.', init=True)
 
86
        b = Branch.initialize('.')
86
87
        b.commit(message='empty tree', allow_pointless=True)
87
88
        self.assertRaises(PointlessCommit,
88
89
                          b.commit,
94
95
 
95
96
    def test_selective_delete(self):
96
97
        """Selective commit in tree with deletions"""
97
 
        b = Branch('.', init=True)
 
98
        b = Branch.initialize('.')
98
99
        file('hello', 'w').write('hello')
99
100
        file('buongia', 'w').write('buongia')
100
101
        b.add(['hello', 'buongia'],
129
130
 
130
131
    def test_commit_rename(self):
131
132
        """Test commit of a revision where a file is renamed."""
132
 
        b = Branch('.', init=True)
 
133
        b = Branch.initialize('.')
133
134
        self.build_tree(['hello'])
134
135
        b.add(['hello'], ['hello-id'])
135
136
        b.commit(message='one', rev_id='test@rev-1', allow_pointless=False)
156
157
 
157
158
    def test_reused_rev_id(self):
158
159
        """Test that a revision id cannot be reused in a branch"""
159
 
        b = Branch('.', init=True)
 
160
        b = Branch.initialize('.')
160
161
        b.commit('initial', rev_id='test@rev-1', allow_pointless=True)
161
162
        self.assertRaises(Exception,
162
163
                          b.commit,
169
170
    def test_commit_move(self):
170
171
        """Test commit of revisions with moved files and directories"""
171
172
        eq = self.assertEquals
172
 
        b = Branch('.', init=True)
 
173
        b = Branch.initialize('.')
173
174
        r1 = 'test@rev-1'
174
175
        self.build_tree(['hello', 'a/', 'b/'])
175
176
        b.add(['hello', 'a', 'b'], ['hello-id', 'a-id', 'b-id'])
204
205
        
205
206
    def test_removed_commit(self):
206
207
        """Test a commit with a removed file"""
207
 
        b = Branch('.', init=True)
 
208
        b = Branch.initialize('.')
208
209
        file('hello', 'w').write('hello world')
209
210
        b.add(['hello'], ['hello-id'])
210
211
        b.commit(message='add hello')
218
219
 
219
220
    def test_committed_ancestry(self):
220
221
        """Test commit appends revisions to ancestry."""
221
 
        b = Branch('.', init=True)
 
222
        b = Branch.initialize('.')
222
223
        rev_ids = []
223
224
        for i in range(4):
224
225
            file('hello', 'w').write((str(i) * 4) + '\n')
232
233
        eq(b.revision_history(), rev_ids)
233
234
        for i in range(4):
234
235
            anc = b.get_ancestry(rev_ids[i])
235
 
            eq(anc, rev_ids[:i+1])
236
 
            
237
 
        
238
 
 
239
 
 
240
 
if __name__ == '__main__':
241
 
    import unittest
242
 
    unittest.main()
243
 
    
 
236
            eq(anc, [None] + rev_ids[:i+1])