~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_last_revision_info.py

  • Committer: John Arbash Meinel
  • Date: 2011-05-11 11:35:28 UTC
  • mto: This revision was merged to the branch mainline in revision 5851.
  • Revision ID: john@arbash-meinel.com-20110511113528-qepibuwxicjrbb2h
Break compatibility with python <2.6.

This includes auditing the code for places where we were doing
explicit 'sys.version' checks and removing them as appropriate.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for branch.last_revision_info."""
18
18
 
19
19
from bzrlib.revision import NULL_REVISION
 
20
from bzrlib.symbol_versioning import deprecated_in
20
21
from bzrlib.tests import TestCaseWithTransport
21
22
 
22
23
 
34
35
        revid = tree.commit('2st post', allow_pointless=True)
35
36
        self.assertEqual((2, revid), tree.branch.last_revision_info())
36
37
 
 
38
    def test_import_deprecated(self):
 
39
        # importing and setting last revision
 
40
        tree1 = self.make_branch_and_tree('branch1')
 
41
        tree1.commit('1st post')
 
42
        revid = tree1.commit('2st post', allow_pointless=True)
 
43
        branch2 = self.make_branch('branch2')
 
44
        self.applyDeprecated(deprecated_in((2, 4, 0)),
 
45
            branch2.import_last_revision_info, tree1.branch.repository, 2, revid)
 
46
        self.assertEqual((2, revid), branch2.last_revision_info())
 
47
        self.assertTrue(branch2.repository.has_revision(revid))
 
48
 
 
49
    def test_same_repo_deprecated(self):
 
50
        # importing and setting last revision within the same repo
 
51
        tree = self.make_branch_and_tree('branch1')
 
52
        tree.commit('1st post')
 
53
        revid = tree.commit('2st post', allow_pointless=True)
 
54
        tree.branch.set_last_revision_info(0, NULL_REVISION)
 
55
        self.applyDeprecated(deprecated_in((2, 4, 0)),
 
56
            tree.branch.import_last_revision_info, tree.branch.repository, 2, revid)
 
57
        self.assertEqual((2, revid), tree.branch.last_revision_info())
 
58
 
37
59
    def test_import(self):
38
60
        # importing and setting last revision
39
61
        tree1 = self.make_branch_and_tree('branch1')
40
62
        tree1.commit('1st post')
41
63
        revid = tree1.commit('2st post', allow_pointless=True)
42
64
        branch2 = self.make_branch('branch2')
43
 
        branch2.import_last_revision_info(tree1.branch.repository, 2, revid)
 
65
        self.assertEquals((2, revid),
 
66
            branch2.import_last_revision_info_and_tags(tree1.branch, 2, revid))
44
67
        self.assertEqual((2, revid), branch2.last_revision_info())
45
68
        self.assertTrue(branch2.repository.has_revision(revid))
46
69
 
 
70
    def test_import_lossy(self):
 
71
        # importing with lossy=True works
 
72
        tree1 = self.make_branch_and_tree('branch1')
 
73
        tree1.commit('1st post')
 
74
        revid = tree1.commit('2st post', allow_pointless=True)
 
75
        branch2 = self.make_branch('branch2')
 
76
        ret = branch2.import_last_revision_info_and_tags(tree1.branch, 2,
 
77
            revid, lossy=True)
 
78
        self.assertIsInstance(ret, tuple)
 
79
        self.assertIsInstance(ret[0], int)
 
80
        self.assertIsInstance(ret[1], str)
 
81
 
47
82
    def test_same_repo(self):
48
83
        # importing and setting last revision within the same repo
49
84
        tree = self.make_branch_and_tree('branch1')
50
85
        tree.commit('1st post')
51
86
        revid = tree.commit('2st post', allow_pointless=True)
52
87
        tree.branch.set_last_revision_info(0, NULL_REVISION)
53
 
        tree.branch.import_last_revision_info(tree.branch.repository, 2, revid)
 
88
        tree.branch.import_last_revision_info_and_tags(tree.branch, 2, revid)
54
89
        self.assertEqual((2, revid), tree.branch.last_revision_info())