~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/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:
16
16
 
17
17
"""Tests for branch.pull behaviour."""
18
18
 
19
 
import os
20
 
 
21
19
from bzrlib import (
22
20
    branch,
23
 
    bzrdir,
 
21
    controldir,
24
22
    errors,
25
23
    memorytree,
26
24
    revision,
44
42
        parent.merge_from_branch(mine.branch)
45
43
        parent.commit('merge my change', rev_id='P2')
46
44
        mine.pull(parent.branch)
47
 
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
 
45
        self.assertEqual('P2', mine.branch.last_revision())
48
46
 
49
47
    def test_pull_merged_indirect(self):
50
48
        # it should be possible to do a pull from one branch into another
61
59
        parent.merge_from_branch(other.branch)
62
60
        parent.commit('merge other', rev_id='P2')
63
61
        mine.pull(parent.branch)
64
 
        self.assertEqual(['P1', 'P2'], mine.branch.revision_history())
 
62
        self.assertEqual('P2', mine.branch.last_revision())
65
63
 
66
64
    def test_pull_updates_checkout_and_master(self):
67
65
        """Pulling into a checkout updates the checkout and the master branch"""
73
71
        rev2 = other.commit('other commit')
74
72
        # now pull, which should update both checkout and master.
75
73
        checkout.branch.pull(other.branch)
76
 
        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
77
 
        self.assertEqual([rev1, rev2], master_tree.branch.revision_history())
 
74
        self.assertEqual(rev2, checkout.branch.last_revision())
 
75
        self.assertEqual(rev2, master_tree.branch.last_revision())
78
76
 
79
77
    def test_pull_local_updates_checkout_only(self):
80
78
        """Pulling --local into a checkout updates the checkout and not the
87
85
        rev2 = other.commit('other commit')
88
86
        # now pull local, which should update checkout but not master.
89
87
        checkout.branch.pull(other.branch, local = True)
90
 
        self.assertEqual([rev1, rev2], checkout.branch.revision_history())
91
 
        self.assertEqual([rev1], master_tree.branch.revision_history())
 
88
        self.assertEqual(rev2, checkout.branch.last_revision())
 
89
        self.assertEqual(rev1, master_tree.branch.last_revision())
92
90
 
93
91
    def test_pull_local_raises_LocalRequiresBoundBranch_on_unbound(self):
94
92
        """Pulling --local into a branch that is not bound should fail."""
100
98
        # now pull --local, which should raise LocalRequiresBoundBranch error.
101
99
        self.assertRaises(errors.LocalRequiresBoundBranch,
102
100
                          master_tree.branch.pull, other.branch, local = True)
103
 
        self.assertEqual([rev1], master_tree.branch.revision_history())
 
101
        self.assertEqual(rev1, master_tree.branch.last_revision())
104
102
 
105
103
    def test_pull_returns_result(self):
106
104
        parent = self.make_branch_and_tree('parent')
117
115
        self.assertEqual('P1', result.old_revid)
118
116
        self.assertEqual(2, result.new_revno)
119
117
        self.assertEqual('M1', result.new_revid)
120
 
        self.assertEqual(None, result.tag_conflicts)
 
118
        self.assertEqual([], result.tag_conflicts)
121
119
 
122
120
    def test_pull_overwrite(self):
123
121
        tree_a = self.make_branch_and_tree('tree_a')
130
128
                          tree_a.branch.pull, tree_b.branch,
131
129
                          overwrite=False, stop_revision='rev2b')
132
130
        # It should not have updated the branch tip, but it should have fetched
133
 
        # the revision
 
131
        # the revision if the repository supports "invisible" revisions
134
132
        self.assertEqual('rev2a', tree_a.branch.last_revision())
135
 
        self.assertTrue(tree_a.branch.repository.has_revision('rev2b'))
 
133
        if tree_a.branch.repository._format.supports_unreferenced_revisions:
 
134
            self.assertTrue(tree_a.branch.repository.has_revision('rev2b'))
136
135
        tree_a.branch.pull(tree_b.branch, overwrite=True,
137
136
                           stop_revision='rev2b')
138
137
        self.assertEqual('rev2b', tree_a.branch.last_revision())
139
 
        self.assertEqual(tree_b.branch.revision_history(),
140
 
                         tree_a.branch.revision_history())
 
138
        self.assertEqual(tree_b.branch.last_revision(),
 
139
                         tree_a.branch.last_revision())
141
140
 
142
141
    def test_pull_merges_and_fetches_tags(self):
143
142
        """Tags are updated by br.pull(source), and revisions named in those
156
155
        except errors.TagsNotSupported:
157
156
            raise TestNotApplicable('format does not support tags.')
158
157
        source.tags.set_tag('tag-a', 'rev-2')
 
158
        source.get_config_stack().set('branch.fetch_tags', True)
159
159
        target.pull(source)
160
160
        # The tag is present, and so is its revision.
161
161
        self.assertEqual('rev-2', target.tags.lookup_tag('tag-a'))
177
177
            source.tags.set_tag('tag-a', 'rev-2')
178
178
        except errors.TagsNotSupported:
179
179
            raise TestNotApplicable('format does not support tags.')
 
180
        source.get_config_stack().set('branch.fetch_tags', True)
180
181
        target.pull(source, 'rev-2-again')
181
182
        # The tag is present, and so is its revision.
182
183
        self.assertEqual('rev-2', target.tags.lookup_tag('tag-a'))
237
238
            # remotebranches can't be bound.  Let's instead make a new local
238
239
            # branch of the default type, which does allow binding.
239
240
            # See https://bugs.launchpad.net/bzr/+bug/112020
240
 
            local = bzrdir.BzrDir.create_branch_convenience('local2')
 
241
            local = controldir.ControlDir.create_branch_convenience('local2')
241
242
            local.bind(target)
242
243
        source = self.make_branch('source')
243
244
        branch.Branch.hooks.install_named_hook(