/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Vincent Ladeuil
  • Date: 2008-11-21 16:43:53 UTC
  • mto: (3855.1.1 bzr.integration)
  • mto: This revision was merged to the branch mainline in revision 3856.
  • Revision ID: v.ladeuil+lp@free.fr-20081121164353-8d07go33ycibzbwl
Better fix for bug #300055.

* bzrlib/tests/test_log.py:
(TestGetViewRevisions.make_tree_with_many_merges): Hijack the
helper to test for revisions touching file on a more significant
tree.
(TestGetViewRevisions.test_file_id_for_range): Better test to
highlight bug #300055: starting revision is a dotted revno and the
log should start right there, not at the mainline revision where
merging occured. But that uncovers yet another bug...
(TestGetRevisionsTouchingFileID.assertAllRevisionsForFileID):
_filter_revisions_touching_file_id doesn't have a 'direction'
parameter anymore.

* bzrlib/tests/blackbox/test_log.py:
(TestCaseWithoutPropsHandler): Fix line too long.
(TestLog.test_log_with_tags,
TestLogMerges.test_merges_partial_range): Fix whitespaces.

* bzrlib/log.py:
(calculate_view_revisions): Delete gratuitous split line. Push
direction handling closer to the needed point. Delete 'direction'
parameter when calling _filter_revisions_touching_file_id.
(_filter_revisions_touching_file_id): Delete 'direction'
parameter. This was used for calling reverse_by_depth which can't
handle an already reversed list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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')
 
751
 
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')
 
755
 
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')
 
759
 
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')
 
763
 
757
764
        wt.merge_from_branch(tree2.branch)
758
765
        wt.commit('four-b', rev_id='4b')
 
766
 
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 = {
850
858
                         revisions)
851
859
 
852
860
 
 
861
    def test_file_id_for_range(self):
 
862
        mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
 
863
        wt.lock_read()
 
864
        self.addCleanup(wt.unlock)
 
865
 
 
866
        def rev_from_rev_id(revid, branch):
 
867
            revspec = revisionspec.RevisionSpec.from_string('revid:%s' % revid)
 
868
            return revspec.in_history(branch)
 
869
 
 
870
        def view_revs(start_rev, end_rev, file_id, direction):
 
871
            revs = log.calculate_view_revisions(
 
872
                wt.branch,
 
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
 
879
                )
 
880
            return revs
 
881
 
 
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'))
 
892
 
 
893
 
853
894
class TestGetRevisionsTouchingFileID(tests.TestCaseWithTransport):
854
895
 
855
896
    def create_tree_with_single_merge(self):
906
947
        tree.commit('D', rev_id='D')
907
948
 
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
910
951
        tree.unlock()
911
952
        tree.lock_read()
912
953
        return tree
960
1001
        actual_revs = log._filter_revisions_touching_file_id(
961
1002
                            tree.branch,
962
1003
                            file_id,
963
 
                            list(view_revs_iter),
964
 
                            'reverse')
 
1004
                            list(view_revs_iter))
965
1005
        self.assertEqual(revisions, [r for r, revno, depth in actual_revs])
966
1006
 
967
1007
    def test_file_id_f1(self):