744
744
def make_tree_with_many_merges(self):
745
745
"""Create a tree with well-known revision ids"""
746
746
wt = self.make_branch_and_tree('tree1')
747
self.build_tree_contents([('tree1/f', '1\n')])
748
wt.add(['f'], ['f-id'])
747
749
wt.commit('commit one', rev_id='1')
748
750
wt.commit('commit two', rev_id='2')
749
752
tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
753
self.build_tree_contents([('tree3/f', '1\n2\n3a\n')])
750
754
tree3.commit('commit three a', rev_id='3a')
751
756
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
752
757
tree2.merge_from_branch(tree3.branch)
753
758
tree2.commit('commit three b', rev_id='3b')
754
760
wt.merge_from_branch(tree2.branch)
755
761
wt.commit('commit three c', rev_id='3c')
756
762
tree2.commit('four-a', rev_id='4a')
757
764
wt.merge_from_branch(tree2.branch)
758
765
wt.commit('four-b', rev_id='4b')
759
767
mainline_revs = [None, '1', '2', '3c', '4b']
760
768
rev_nos = {'1':1, '2':2, '3c': 3, '4b':4}
761
769
full_rev_nos_for_reference = {
861
def test_file_id_for_range(self):
862
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
864
self.addCleanup(wt.unlock)
866
def rev_from_rev_id(revid, branch):
867
revspec = revisionspec.RevisionSpec.from_string('revid:%s' % revid)
868
return revspec.in_history(branch)
870
def view_revs(start_rev, end_rev, file_id, direction):
871
revs = log.calculate_view_revisions(
873
start_rev, # start_revision
874
end_rev, # end_revision
875
direction, # direction
876
file_id, # specific_fileid
877
True, # generate_merge_revisions
878
True, # allow_single_merge_revision
882
rev_3a = rev_from_rev_id('3a', wt.branch)
883
rev_4b = rev_from_rev_id('4b', wt.branch)
884
self.assertEquals([('3c', '3', 0), ('3a', '2.1.1', 1)],
885
view_revs(rev_3a, rev_4b, 'f-id', 'reverse'))
886
# Note that the depth is 0 for 3a because depths are normalized, but
887
# there is still a bug somewhere... most probably in
888
# _filter_revision_range and/or get_view_revisions still around a bad
889
# use of reverse_by_depth
890
self.assertEquals([('3a', '2.1.1', 0)],
891
view_revs(rev_3a, rev_4b, 'f-id', 'forward'))
853
894
class TestGetRevisionsTouchingFileID(tests.TestCaseWithTransport):
855
896
def create_tree_with_single_merge(self):
906
947
tree.commit('D', rev_id='D')
908
949
# Switch to a read lock for this tree.
909
# We still have an addCleanup(unlock) pending
950
# We still have an addCleanup(tree.unlock) pending
960
1001
actual_revs = log._filter_revisions_touching_file_id(
963
list(view_revs_iter),
1004
list(view_revs_iter))
965
1005
self.assertEqual(revisions, [r for r, revno, depth in actual_revs])
967
1007
def test_file_id_f1(self):