~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_commit.py

  • Committer: Martin Pool
  • Date: 2005-09-15 06:35:58 UTC
  • Revision ID: mbp@sourcefrog.net-20050915063558-f3b5bae25543c922
- add assertion

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib.selftest import TestCaseInTempDir
21
21
from bzrlib.branch import Branch
22
22
from bzrlib.commit import Commit
23
 
from bzrlib.errors import PointlessCommit, BzrError
 
23
from bzrlib.errors import PointlessCommit
24
24
 
25
25
 
26
26
# TODO: Test commit with some added, and added-but-missing files
125
125
        tree3 = b.revision_tree('test@rev-3')
126
126
        self.assertFalse(tree3.has_filename('hello'))
127
127
        self.assertEquals(tree3.get_file_text('buongia-id'), 'new text')
128
 
 
129
 
 
130
 
    def test_commit_rename(self):
131
 
        """Test commit of a revision where a file is renamed."""
132
 
        b = Branch('.', init=True)
133
 
        self.build_tree(['hello'])
134
 
        b.add(['hello'], ['hello-id'])
135
 
        b.commit(message='one', rev_id='test@rev-1', allow_pointless=False)
136
 
 
137
 
        b.rename_one('hello', 'fruity')
138
 
        b.commit(message='renamed', rev_id='test@rev-2', allow_pointless=False)
139
 
 
140
 
        eq = self.assertEquals
141
 
        tree1 = b.revision_tree('test@rev-1')
142
 
        eq(tree1.id2path('hello-id'), 'hello')
143
 
        eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
144
 
        self.assertFalse(tree1.has_filename('fruity'))
145
 
        self.check_inventory_shape(tree1.inventory, ['hello'])
146
 
        ie = tree1.inventory['hello-id']
147
 
        eq(ie.name_version, 'test@rev-1')
148
 
 
149
 
        tree2 = b.revision_tree('test@rev-2')
150
 
        eq(tree2.id2path('hello-id'), 'fruity')
151
 
        eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
152
 
        self.check_inventory_shape(tree2.inventory, ['fruity'])
153
 
        ie = tree2.inventory['hello-id']
154
 
        eq(ie.name_version, 'test@rev-2')
155
 
 
156
 
 
157
 
    def test_reused_rev_id(self):
158
 
        """Test that a revision id cannot be reused in a branch"""
159
 
        b = Branch('.', init=True)
160
 
        b.commit('initial', rev_id='test@rev-1', allow_pointless=True)
161
 
        self.assertRaises(Exception,
162
 
                          b.commit,
163
 
                          message='reused id',
164
 
                          rev_id='test@rev-1',
165
 
                          allow_pointless=True)
166
 
                          
167
 
 
168
 
 
169
 
    def test_commit_move(self):
170
 
        """Test commit of revisions with moved files and directories"""
171
 
        eq = self.assertEquals
172
 
        b = Branch('.', init=True)
173
 
        r1 = 'test@rev-1'
174
 
        self.build_tree(['hello', 'a/', 'b/'])
175
 
        b.add(['hello', 'a', 'b'], ['hello-id', 'a-id', 'b-id'])
176
 
        b.commit('initial', rev_id=r1, allow_pointless=False)
177
 
 
178
 
        b.move(['hello'], 'a')
179
 
        r2 = 'test@rev-2'
180
 
        b.commit('two', rev_id=r2, allow_pointless=False)
181
 
        self.check_inventory_shape(b.inventory,
182
 
                                   ['a', 'a/hello', 'b'])
183
 
 
184
 
        b.move(['b'], 'a')
185
 
        r3 = 'test@rev-3'
186
 
        b.commit('three', rev_id=r3, allow_pointless=False)
187
 
        self.check_inventory_shape(b.inventory,
188
 
                                   ['a', 'a/hello', 'a/b'])
189
 
        self.check_inventory_shape(b.get_revision_inventory(r3),
190
 
                                   ['a', 'a/hello', 'a/b'])
191
 
 
192
 
        b.move([os.sep.join(['a', 'hello'])],
193
 
               os.sep.join(['a', 'b']))
194
 
        r4 = 'test@rev-4'
195
 
        b.commit('four', rev_id=r4, allow_pointless=False)
196
 
        self.check_inventory_shape(b.inventory,
197
 
                                   ['a', 'a/b/hello', 'a/b'])
198
 
 
199
 
        inv = b.get_revision_inventory(r4)
200
 
        eq(inv['hello-id'].name_version, r4)
201
 
        eq(inv['a-id'].name_version, r1)
202
 
        eq(inv['b-id'].name_version, r3)
203
 
 
204
128
        
 
129
 
 
130
 
205
131
    def test_removed_commit(self):
206
132
        """Test a commit with a removed file"""
207
133
        b = Branch('.', init=True)