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')
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)
137
b.rename_one('hello', 'fruity')
138
b.commit(message='renamed', rev_id='test@rev-2', allow_pointless=False)
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')
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')
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,
165
allow_pointless=True)
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)
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)
178
b.move(['hello'], 'a')
180
b.commit('two', rev_id=r2, allow_pointless=False)
181
self.check_inventory_shape(b.inventory,
182
['a', 'a/hello', 'b'])
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'])
192
b.move([os.sep.join(['a', 'hello'])],
193
os.sep.join(['a', 'b']))
195
b.commit('four', rev_id=r4, allow_pointless=False)
196
self.check_inventory_shape(b.inventory,
197
['a', 'a/b/hello', 'a/b'])
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)
205
131
def test_removed_commit(self):
206
132
"""Test a commit with a removed file"""
207
133
b = Branch('.', init=True)