148
148
if has_symlinks():
149
149
os.unlink('symlink')
150
150
os.symlink('target2', 'symlink')
151
self.tree_1 = self.branch.storage.revision_tree('1')
152
self.inv_1 = self.branch.storage.get_inventory('1')
151
self.tree_1 = self.branch.repository.revision_tree('1')
152
self.inv_1 = self.branch.repository.get_inventory('1')
153
153
self.file_1 = self.inv_1['fileid']
154
154
self.tree_2 = self.branch.working_tree()
155
155
self.inv_2 = self.tree_2.read_working_inventory()
248
248
self.wt = self.branch.working_tree()
249
249
self.wt.commit('message_1', rev_id = '1')
250
self.tree_1 = self.branch.storage.revision_tree('1')
251
self.inv_1 = self.branch.storage.get_inventory('1')
250
self.tree_1 = self.branch.repository.revision_tree('1')
251
self.inv_1 = self.branch.repository.get_inventory('1')
252
252
self.file_1 = self.inv_1['fileid']
253
253
self.work_tree = self.branch.working_tree()
254
254
self.file_active = self.work_tree.inventory['fileid']
257
257
# This tests that a simple commit with no parents makes a new
258
258
# revision value in the inventory entry
259
259
self.file_active.snapshot('2', 'subdir/file', {}, self.work_tree,
260
self.branch.storage.weave_store,
260
self.branch.repository.weave_store,
261
261
self.branch.get_transaction())
262
262
# expected outcome - file_1 has a revision id of '2', and we can get
263
263
# its text of 'file contents' out of the weave.
264
264
self.assertEqual(self.file_1.revision, '1')
265
265
self.assertEqual(self.file_active.revision, '2')
266
266
# this should be a separate test probably, but lets check it once..
267
lines = self.branch.storage.weave_store.get_lines('fileid','2',
267
lines = self.branch.repository.weave_store.get_lines('fileid','2',
268
268
self.branch.get_transaction())
269
269
self.assertEqual(lines, ['contents of subdir/file\n'])
273
273
# an unchanged inventory entry
274
274
self.file_active.snapshot('2', 'subdir/file', {'1':self.file_1},
276
self.branch.storage.weave_store,
276
self.branch.repository.weave_store,
277
277
self.branch.get_transaction())
278
278
self.assertEqual(self.file_1.revision, '1')
279
279
self.assertEqual(self.file_active.revision, '1')
280
280
self.assertRaises(errors.WeaveError,
281
self.branch.storage.weave_store.get_lines, 'fileid',
282
'2', self.branch.get_transaction())
281
self.branch.repository.weave_store.get_lines,
282
'fileid', '2', self.branch.get_transaction())
284
284
def test_snapshot_merge_identical_different_revid(self):
285
285
# This tests that a commit with two identical parents, one of which has
293
293
self.assertEqual(self.file_1, other_ie)
294
294
other_ie.revision = 'other'
295
295
self.assertNotEqual(self.file_1, other_ie)
296
self.branch.storage.weave_store.add_identical_text('fileid', '1',
296
self.branch.repository.weave_store.add_identical_text('fileid', '1',
297
297
'other', ['1'], self.branch.get_transaction())
298
298
self.file_active.snapshot('2', 'subdir/file',
299
299
{'1':self.file_1, 'other':other_ie},
301
self.branch.storage.weave_store,
301
self.branch.repository.weave_store,
302
302
self.branch.get_transaction())
303
303
self.assertEqual(self.file_active.revision, '2')
309
309
rename('subdir/file', 'subdir/newname')
310
310
self.file_active.snapshot('2', 'subdir/newname', {'1':self.file_1},
312
self.branch.storage.weave_store,
312
self.branch.repository.weave_store,
313
313
self.branch.get_transaction())
314
314
# expected outcome - file_1 has a revision id of '2'
315
315
self.assertEqual(self.file_active.revision, '2')
331
331
self.branch = Branch.initialize(u'.')
332
332
self.wt = self.branch.working_tree()
333
333
self.wt.commit('new branch', allow_pointless=True, rev_id='A')
334
self.inv_A = self.branch.storage.get_inventory('A')
334
self.inv_A = self.branch.repository.get_inventory('A')
335
335
self.wt.add(['file'], ['fileid'])
336
336
self.wt.commit('add file', rev_id='B')
337
self.inv_B = self.branch.storage.get_inventory('B')
337
self.inv_B = self.branch.repository.get_inventory('B')
338
338
self.branch.control_files.put_utf8('revision-history', 'A\n')
339
339
self.assertEqual(self.branch.revision_history(), ['A'])
340
340
self.wt.commit('another add of file', rev_id='C')
341
self.inv_C = self.branch.storage.get_inventory('C')
341
self.inv_C = self.branch.repository.get_inventory('C')
342
342
self.wt.add_pending_merge('B')
343
343
self.wt.commit('merge in B', rev_id='D')
344
self.inv_D = self.branch.storage.get_inventory('D')
344
self.inv_D = self.branch.repository.get_inventory('D')
345
345
self.file_active = self.branch.working_tree().inventory['fileid']
346
self.weave = self.branch.storage.weave_store.get_weave('fileid',
346
self.weave = self.branch.repository.weave_store.get_weave('fileid',
347
347
self.branch.get_transaction())
349
349
def get_previous_heads(self, inventories):