/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: 2018-11-16 23:15:15 UTC
  • mfrom: (7180 work)
  • mto: This revision was merged to the branch mainline in revision 7183.
  • Revision ID: jelmer@jelmer.uk-20181116231515-zqd2yn6kj8lfydyp
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
        rev2a = tree_a.commit('message 2a')
 
177
        tree_b.branch.tags.set_tag('tag1', rev2a)
 
178
        rev2b = tree_b.commit('message 2b')
 
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(rev2a, tree_a.branch.last_revision())
 
187
        if tree_a.branch.repository._format.supports_unreferenced_revisions:
 
188
            self.assertTrue(tree_a.branch.repository.has_revision(rev2b))
 
189
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history']),
 
190
                           stop_revision=rev2b)
 
191
        self.assertEqual(rev2b, tree_a.branch.last_revision())
 
192
        self.assertEqual(tree_b.branch.last_revision(),
 
193
                         tree_a.branch.last_revision())
 
194
        self.assertEqual(rev1, tree_a.branch.tags.lookup_tag('tag1'))
 
195
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history', 'tags']),
 
196
                           stop_revision=rev2b)
 
197
        self.assertEqual(rev2a, tree_a.branch.tags.lookup_tag('tag1'))
 
198
 
141
199
    def test_pull_merges_and_fetches_tags(self):
142
200
        """Tags are updated by br.pull(source), and revisions named in those
143
201
        tags are fetched.
147
205
            builder = self.make_branch_builder('source')
148
206
        except errors.UninitializableFormat:
149
207
            raise TestNotApplicable('uninitializeable format')
150
 
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(builder)
 
208
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(
 
209
            builder)
151
210
        target = source.controldir.sprout('target').open_branch()
152
211
        # Add a tag to the source, then pull from source
153
212
        try:
168
227
            builder = self.make_branch_builder('source')
169
228
        except errors.UninitializableFormat:
170
229
            raise TestNotApplicable('uninitializeable format')
171
 
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(builder)
 
230
        source, rev1, rev2 = fixtures.build_branch_with_non_ancestral_rev(
 
231
            builder)
172
232
        target = source.controldir.sprout('target').open_branch()
173
233
        # Add a new commit to the ancestry
174
234
        rev_2_again = builder.build_commit(message="Rev 2 again")
260
320
        rev1 = target.commit('rev 1')
261
321
        target.unlock()
262
322
        sourcedir = target.controldir.clone(self.get_url('source'))
263
 
        source = memorytree.MemoryTree.create_on_branch(sourcedir.open_branch())
 
323
        source = memorytree.MemoryTree.create_on_branch(
 
324
            sourcedir.open_branch())
264
325
        rev2 = source.commit('rev 2')
265
326
        branch.Branch.hooks.install_named_hook(
266
327
            'post_pull', self.capture_post_pull_hook, None)