~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_interbranch/test_pull.py

(vila) Fix bzrlib.tests.test_gpg.TestVerify.test_verify_revoked_signature
 with recent versions of gpg. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for InterBranch.pull behaviour."""
18
18
 
19
 
import os
20
 
 
21
19
from bzrlib.branch import Branch
22
 
from bzrlib.bzrdir import BzrDir
 
20
from bzrlib.controldir import ControlDir
23
21
from bzrlib import errors
24
22
from bzrlib.memorytree import MemoryTree
25
23
from bzrlib.revision import NULL_REVISION
42
40
        parent.merge_from_branch(mine.branch)
43
41
        parent.commit('merge my change', rev_id='P2')
44
42
        mine.pull(parent.branch)
45
 
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
 
43
        self.assertEqual('P2', mine.branch.last_revision())
46
44
 
47
45
    def test_pull_merged_indirect(self):
48
46
        # it should be possible to do a pull from one branch into another
59
57
        parent.merge_from_branch(other.branch)
60
58
        parent.commit('merge other', rev_id='P2')
61
59
        mine.pull(parent.branch)
62
 
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
 
60
        self.assertEqual('P2', mine.branch.last_revision())
63
61
 
64
62
    def test_pull_updates_checkout_and_master(self):
65
63
        """Pulling into a checkout updates the checkout and the master branch"""
70
68
        rev2 = other.commit('other commit')
71
69
        # now pull, which should update both checkout and master.
72
70
        checkout.branch.pull(other.branch)
73
 
        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
74
 
        self.assertEqual([rev1, rev2], master_tree.branch.revision_history())
 
71
        self.assertEqual(rev2, checkout.branch.last_revision())
 
72
        self.assertEqual(rev2, master_tree.branch.last_revision())
75
73
 
76
74
    def test_pull_raises_specific_error_on_master_connection_error(self):
77
75
        master_tree = self.make_from_branch_and_tree('master')
79
77
        other = self.sprout_to(master_tree.branch.bzrdir, 'other').open_branch()
80
78
        # move the branch out of the way on disk to cause a connection
81
79
        # error.
82
 
        os.rename('master', 'master_gone')
 
80
        master_tree.branch.bzrdir.destroy_branch()
83
81
        # try to pull, which should raise a BoundBranchConnectionFailure.
84
82
        self.assertRaises(errors.BoundBranchConnectionFailure,
85
83
                checkout.branch.pull, other)
99
97
        self.assertEqual('P1', result.old_revid)
100
98
        self.assertEqual(2, result.new_revno)
101
99
        self.assertEqual('M1', result.new_revid)
102
 
        self.assertEqual(None, result.tag_conflicts)
 
100
        self.assertEqual([], result.tag_conflicts)
103
101
 
104
102
    def test_pull_overwrite(self):
105
103
        tree_a = self.make_from_branch_and_tree('tree_a')
112
110
                          tree_a.branch.pull, tree_b.branch,
113
111
                          overwrite=False, stop_revision='rev2b')
114
112
        # It should not have updated the branch tip, but it should have fetched
115
 
        # the revision
 
113
        # the revision if the repository supports "invisible" revisions.
116
114
        self.assertEqual('rev2a', tree_a.branch.last_revision())
117
 
        self.assertTrue(tree_a.branch.repository.has_revision('rev2b'))
 
115
        if tree_a.branch.repository._format.supports_unreferenced_revisions:
 
116
            self.assertTrue(tree_a.branch.repository.has_revision('rev2b'))
118
117
        tree_a.branch.pull(tree_b.branch, overwrite=True,
119
118
                           stop_revision='rev2b')
120
119
        self.assertEqual('rev2b', tree_a.branch.last_revision())
121
 
        self.assertEqual(tree_b.branch.revision_history(),
122
 
                         tree_a.branch.revision_history())
 
120
        self.assertEqual(tree_b.branch.last_revision(),
 
121
                         tree_a.branch.last_revision())
123
122
 
124
123
 
125
124
class TestPullHook(TestCaseWithInterBranch):
126
125
 
127
126
    def setUp(self):
128
127
        self.hook_calls = []
129
 
        TestCaseWithInterBranch.setUp(self)
 
128
        super(TestPullHook, self).setUp()
130
129
 
131
130
    def capture_post_pull_hook(self, result):
132
131
        """Capture post pull hook calls to self.hook_calls.
176
175
            # remotebranches can't be bound.  Let's instead make a new local
177
176
            # branch of the default type, which does allow binding.
178
177
            # See https://bugs.launchpad.net/bzr/+bug/112020
179
 
            local = BzrDir.create_branch_convenience('local2')
 
178
            local = ControlDir.create_branch_convenience('local2')
180
179
            local.bind(target)
181
180
        source = self.make_from_branch('source')
182
181
        Branch.hooks.install_named_hook('post_pull',