400
398
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
403
class TestGetRevisionsTouchingFileID(TestCaseWithTransport):
405
def create_tree_with_single_merge(self):
406
"""Create a branch with a moderate layout.
408
The revision graph looks like:
416
In this graph, A introduced files f1 and f2 and f3.
417
B modifies f1 and f3, and C modifies f2 and f3.
418
D merges the changes from B and C and resolves the conflict for f3.
420
# TODO: jam 20070218 This seems like it could really be done
421
# with make_branch_and_memory_tree() if we could just
422
# create the content of those files.
423
# TODO: jam 20070218 Another alternative is that we would really
424
# like to only create this tree 1 time for all tests that
425
# use it. Since 'log' only uses the tree in a readonly
426
# fashion, it seems a shame to regenerate an identical
427
# tree for each test.
428
tree = self.make_branch_and_tree('tree')
430
self.addCleanup(tree.unlock)
432
self.build_tree_contents([('tree/f1', 'A\n'),
436
tree.add(['f1', 'f2', 'f3'], ['f1-id', 'f2-id', 'f3-id'])
437
tree.commit('A', rev_id='A')
439
self.build_tree_contents([('tree/f2', 'A\nC\n'),
440
('tree/f3', 'A\nC\n'),
442
tree.commit('C', rev_id='C')
443
# Revert back to A to build the other history.
444
tree.set_last_revision('A')
445
tree.branch.set_last_revision_info(1, 'A')
446
self.build_tree_contents([('tree/f1', 'A\nB\n'),
448
('tree/f3', 'A\nB\n'),
450
tree.commit('B', rev_id='B')
451
tree.set_parent_ids(['B', 'C'])
452
self.build_tree_contents([('tree/f1', 'A\nB\n'),
453
('tree/f2', 'A\nC\n'),
454
('tree/f3', 'A\nB\nC\n'),
456
tree.commit('D', rev_id='D')
458
# Switch to a read lock for this tree.
459
# We still have addCleanup(unlock)
464
def test_tree_with_single_merge(self):
465
"""Make sure the tree layout is correct."""
466
tree = self.create_tree_with_single_merge()
467
rev_A_tree = tree.branch.repository.revision_tree('A')
468
rev_B_tree = tree.branch.repository.revision_tree('B')
470
f1_changed = (u'f1', 'f1-id', 'file', True, False)
471
f2_changed = (u'f2', 'f2-id', 'file', True, False)
472
f3_changed = (u'f3', 'f3-id', 'file', True, False)
474
delta = rev_B_tree.changes_from(rev_A_tree)
475
self.assertEqual([f1_changed, f3_changed], delta.modified)
476
self.assertEqual([], delta.renamed)
477
self.assertEqual([], delta.added)
478
self.assertEqual([], delta.removed)
480
rev_C_tree = tree.branch.repository.revision_tree('C')
481
delta = rev_C_tree.changes_from(rev_A_tree)
482
self.assertEqual([f2_changed, f3_changed], delta.modified)
483
self.assertEqual([], delta.renamed)
484
self.assertEqual([], delta.added)
485
self.assertEqual([], delta.removed)
487
rev_D_tree = tree.branch.repository.revision_tree('D')
488
delta = rev_D_tree.changes_from(rev_B_tree)
489
self.assertEqual([f2_changed, f3_changed], delta.modified)
490
self.assertEqual([], delta.renamed)
491
self.assertEqual([], delta.added)
492
self.assertEqual([], delta.removed)
494
delta = rev_D_tree.changes_from(rev_C_tree)
495
self.assertEqual([f1_changed, f3_changed], delta.modified)
496
self.assertEqual([], delta.renamed)
497
self.assertEqual([], delta.added)
498
self.assertEqual([], delta.removed)