/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 breezy/tests/per_branch/test_pull.py

  • Committer: Jelmer Vernooij
  • Date: 2019-03-04 00:16:27 UTC
  • mfrom: (7293 work)
  • mto: This revision was merged to the branch mainline in revision 7318.
  • Revision ID: jelmer@jelmer.uk-20190304001627-v6u7o6pf97tukhek
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        rev1 = master_tree.commit('master')
68
68
        checkout = master_tree.branch.create_checkout('checkout')
69
69
 
70
 
        other = master_tree.branch.controldir.sprout('other').open_workingtree()
 
70
        other = master_tree.branch.controldir.sprout(
 
71
            'other').open_workingtree()
71
72
        rev2 = other.commit('other commit')
72
73
        # now pull, which should update both checkout and master.
73
74
        checkout.branch.pull(other.branch)
81
82
        rev1 = master_tree.commit('master')
82
83
        checkout = master_tree.branch.create_checkout('checkout')
83
84
 
84
 
        other = master_tree.branch.controldir.sprout('other').open_workingtree()
 
85
        other = master_tree.branch.controldir.sprout(
 
86
            'other').open_workingtree()
85
87
        rev2 = other.commit('other commit')
86
88
        # now pull local, which should update checkout but not master.
87
 
        checkout.branch.pull(other.branch, local = True)
 
89
        checkout.branch.pull(other.branch, local=True)
88
90
        self.assertEqual(rev2, checkout.branch.last_revision())
89
91
        self.assertEqual(rev1, master_tree.branch.last_revision())
90
92
 
93
95
        master_tree = self.make_branch_and_tree('branch')
94
96
        rev1 = master_tree.commit('master')
95
97
 
96
 
        other = master_tree.branch.controldir.sprout('other').open_workingtree()
 
98
        other = master_tree.branch.controldir.sprout(
 
99
            'other').open_workingtree()
97
100
        rev2 = other.commit('other commit')
98
101
        # now pull --local, which should raise LocalRequiresBoundBranch error.
99
102
        self.assertRaises(errors.LocalRequiresBoundBranch,
100
 
                          master_tree.branch.pull, other.branch, local = True)
 
103
                          master_tree.branch.pull, other.branch, local=True)
101
104
        self.assertEqual(rev1, master_tree.branch.last_revision())
102
105
 
103
106
    def test_pull_returns_result(self):
138
141
        self.assertEqual(tree_b.branch.last_revision(),
139
142
                         tree_a.branch.last_revision())
140
143
 
 
144
    def test_pull_overwrite_set(self):
 
145
        tree_a = self.make_branch_and_tree('tree_a')
 
146
        rev1 = tree_a.commit('message 1')
 
147
 
 
148
        tree_b = tree_a.controldir.sprout('tree_b').open_workingtree()
 
149
        rev2a = tree_a.commit('message 2a')
 
150
        rev2b = tree_b.commit('message 2b')
 
151
        self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
 
152
        self.assertRaises(errors.DivergedBranches,
 
153
                          tree_a.branch.pull, tree_b.branch,
 
154
                          overwrite=set(), stop_revision=rev2b)
 
155
        # It should not have updated the branch tip, but it should have fetched
 
156
        # the revision if the repository supports "invisible" revisions
 
157
        self.assertEqual(rev2a, tree_a.branch.last_revision())
 
158
        if tree_a.branch.repository._format.supports_unreferenced_revisions:
 
159
            self.assertTrue(tree_a.branch.repository.has_revision(rev2b))
 
160
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history']),
 
161
                           stop_revision=rev2b)
 
162
        self.assertEqual(rev2b, tree_a.branch.last_revision())
 
163
        self.assertEqual(tree_b.branch.last_revision(),
 
164
                         tree_a.branch.last_revision())
 
165
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history', 'tags']),
 
166
                           stop_revision=rev2b)
 
167
 
 
168
    def test_pull_overwrite_set_tags(self):
 
169
        tree_a = self.make_branch_and_tree('tree_a')
 
170
        if not tree_a.branch.supports_tags():
 
171
            raise TestNotApplicable("branch does not support tags")
 
172
        rev1 = tree_a.commit('message 1')
 
173
        tree_a.branch.tags.set_tag('tag1', rev1)
 
174
 
 
175
        tree_b = tree_a.controldir.sprout('tree_b').open_workingtree()
 
176
        rev2b = tree_b.commit('message 2b')
 
177
        tree_b.branch.tags.set_tag('tag1', rev2b)
 
178
        rev1b = tree_a.commit('message 1b')
 
179
        tree_a.branch.get_config_stack().set('branch.fetch_tags', True)
 
180
        self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
 
181
        self.assertRaises(errors.DivergedBranches,
 
182
                          tree_a.branch.pull, tree_b.branch,
 
183
                          overwrite=set(), stop_revision=rev2b)
 
184
        # It should not have updated the branch tip, but it should have fetched
 
185
        # the revision if the repository supports "invisible" revisions
 
186
        self.assertEqual(rev1b, tree_a.branch.last_revision())
 
187
        # It also should not have updated the tags
 
188
        self.assertEqual(tree_a.branch.tags.get_tag_dict(), {'tag1': rev1})
 
189
        if tree_a.branch.repository._format.supports_unreferenced_revisions:
 
190
            self.assertTrue(tree_a.branch.repository.has_revision(rev2b))
 
191
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history']),
 
192
                           stop_revision=rev2b)
 
193
        self.assertEqual(rev2b, tree_a.branch.last_revision())
 
194
        self.assertEqual(tree_b.branch.last_revision(),
 
195
                         tree_a.branch.last_revision())
 
196
        self.assertEqual(rev1, tree_a.branch.tags.lookup_tag('tag1'))
 
197
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history', 'tags']),
 
198
                           stop_revision=rev2b)
 
199
        self.assertEqual(rev2b, tree_a.branch.tags.lookup_tag('tag1'))
 
200
 
141
201
    def test_pull_merges_and_fetches_tags(self):
142
202
        """Tags are updated by br.pull(source), and revisions named in those
143
203
        tags are fetched.
147
207
            builder = self.make_branch_builder('source')
148
208
        except errors.UninitializableFormat:
149
209
            raise TestNotApplicable('uninitializeable format')
150
 
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(builder)
 
210
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(
 
211
            builder)
151
212
        target = source.controldir.sprout('target').open_branch()
152
213
        # Add a tag to the source, then pull from source
153
214
        try:
168
229
            builder = self.make_branch_builder('source')
169
230
        except errors.UninitializableFormat:
170
231
            raise TestNotApplicable('uninitializeable format')
171
 
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(builder)
 
232
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(
 
233
            builder)
172
234
        target = source.controldir.sprout('target').open_branch()
173
235
        # Add a new commit to the ancestry
174
236
        rev_2_again = builder.build_commit(message="Rev 2 again")
260
322
        rev1 = target.commit('rev 1')
261
323
        target.unlock()
262
324
        sourcedir = target.controldir.clone(self.get_url('source'))
263
 
        source = memorytree.MemoryTree.create_on_branch(sourcedir.open_branch())
 
325
        source = memorytree.MemoryTree.create_on_branch(
 
326
            sourcedir.open_branch())
264
327
        rev2 = source.commit('rev 2')
265
328
        branch.Branch.hooks.install_named_hook(
266
329
            'post_pull', self.capture_post_pull_hook, None)