~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Tarmac
  • Author(s): Vincent Ladeuil
  • Date: 2017-01-30 14:42:05 UTC
  • mfrom: (6620.1.1 trunk)
  • Revision ID: tarmac-20170130144205-r8fh2xpmiuxyozpv
Merge  2.7 into trunk including fix for bug #1657238 [r=vila]

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
"""Tests for InterBranch.pull behaviour."""
18
18
 
19
19
from bzrlib.branch import Branch
20
 
from bzrlib.bzrdir import BzrDir
 
20
from bzrlib.controldir import ControlDir
21
21
from bzrlib import errors
22
22
from bzrlib.memorytree import MemoryTree
23
23
from bzrlib.revision import NULL_REVISION
40
40
        parent.merge_from_branch(mine.branch)
41
41
        parent.commit('merge my change', rev_id='P2')
42
42
        mine.pull(parent.branch)
43
 
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
 
43
        self.assertEqual('P2', mine.branch.last_revision())
44
44
 
45
45
    def test_pull_merged_indirect(self):
46
46
        # it should be possible to do a pull from one branch into another
57
57
        parent.merge_from_branch(other.branch)
58
58
        parent.commit('merge other', rev_id='P2')
59
59
        mine.pull(parent.branch)
60
 
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
 
60
        self.assertEqual('P2', mine.branch.last_revision())
61
61
 
62
62
    def test_pull_updates_checkout_and_master(self):
63
63
        """Pulling into a checkout updates the checkout and the master branch"""
68
68
        rev2 = other.commit('other commit')
69
69
        # now pull, which should update both checkout and master.
70
70
        checkout.branch.pull(other.branch)
71
 
        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
72
 
        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())
73
73
 
74
74
    def test_pull_raises_specific_error_on_master_connection_error(self):
75
75
        master_tree = self.make_from_branch_and_tree('master')
110
110
                          tree_a.branch.pull, tree_b.branch,
111
111
                          overwrite=False, stop_revision='rev2b')
112
112
        # It should not have updated the branch tip, but it should have fetched
113
 
        # the revision
 
113
        # the revision if the repository supports "invisible" revisions.
114
114
        self.assertEqual('rev2a', tree_a.branch.last_revision())
115
 
        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'))
116
117
        tree_a.branch.pull(tree_b.branch, overwrite=True,
117
118
                           stop_revision='rev2b')
118
119
        self.assertEqual('rev2b', tree_a.branch.last_revision())
119
 
        self.assertEqual(tree_b.branch.revision_history(),
120
 
                         tree_a.branch.revision_history())
 
120
        self.assertEqual(tree_b.branch.last_revision(),
 
121
                         tree_a.branch.last_revision())
121
122
 
122
123
 
123
124
class TestPullHook(TestCaseWithInterBranch):
124
125
 
125
126
    def setUp(self):
126
127
        self.hook_calls = []
127
 
        TestCaseWithInterBranch.setUp(self)
 
128
        super(TestPullHook, self).setUp()
128
129
 
129
130
    def capture_post_pull_hook(self, result):
130
131
        """Capture post pull hook calls to self.hook_calls.
174
175
            # remotebranches can't be bound.  Let's instead make a new local
175
176
            # branch of the default type, which does allow binding.
176
177
            # See https://bugs.launchpad.net/bzr/+bug/112020
177
 
            local = BzrDir.create_branch_convenience('local2')
 
178
            local = ControlDir.create_branch_convenience('local2')
178
179
            local.bind(target)
179
180
        source = self.make_from_branch('source')
180
181
        Branch.hooks.install_named_hook('post_pull',