/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-04 04:23:28 UTC
  • mto: This revision was merged to the branch mainline in revision 7169.
  • Revision ID: jelmer@jelmer.uk-20181104042328-sualtxf9f30dhuyy
Fix overwrite for git branches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
138
138
        self.assertEqual(tree_b.branch.last_revision(),
139
139
                         tree_a.branch.last_revision())
140
140
 
 
141
    def test_pull_overwrite_set(self):
 
142
        tree_a = self.make_branch_and_tree('tree_a')
 
143
        rev1 = tree_a.commit('message 1')
 
144
 
 
145
        tree_b = tree_a.controldir.sprout('tree_b').open_workingtree()
 
146
        rev2a = tree_a.commit('message 2a')
 
147
        rev2b = tree_b.commit('message 2b')
 
148
        self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
 
149
        self.assertRaises(errors.DivergedBranches,
 
150
                          tree_a.branch.pull, tree_b.branch,
 
151
                          overwrite=set(), stop_revision=rev2b)
 
152
        # It should not have updated the branch tip, but it should have fetched
 
153
        # the revision if the repository supports "invisible" revisions
 
154
        self.assertEqual(rev2a, tree_a.branch.last_revision())
 
155
        if tree_a.branch.repository._format.supports_unreferenced_revisions:
 
156
            self.assertTrue(tree_a.branch.repository.has_revision(rev2b))
 
157
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history']),
 
158
                           stop_revision=rev2b)
 
159
        self.assertEqual(rev2b, tree_a.branch.last_revision())
 
160
        self.assertEqual(tree_b.branch.last_revision(),
 
161
                         tree_a.branch.last_revision())
 
162
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history', 'tags']),
 
163
                           stop_revision=rev2b)
 
164
 
 
165
    def test_pull_overwrite_set_tags(self):
 
166
        tree_a = self.make_branch_and_tree('tree_a')
 
167
        if not tree_a.branch.supports_tags():
 
168
            raise TestNotApplicable("branch does not support tags")
 
169
        rev1 = tree_a.commit('message 1')
 
170
        tree_a.branch.tags.set_tag('tag1', rev1)
 
171
 
 
172
        tree_b = tree_a.controldir.sprout('tree_b').open_workingtree()
 
173
        rev2a = tree_a.commit('message 2a')
 
174
        tree_b.branch.tags.set_tag('tag1', rev2a)
 
175
        rev2b = tree_b.commit('message 2b')
 
176
        tree_a.branch.get_config_stack().set('branch.fetch_tags', True)
 
177
        self.assertRaises(errors.DivergedBranches, tree_a.pull, tree_b.branch)
 
178
        self.assertRaises(errors.DivergedBranches,
 
179
                          tree_a.branch.pull, tree_b.branch,
 
180
                          overwrite=set(), stop_revision=rev2b)
 
181
        # It should not have updated the branch tip, but it should have fetched
 
182
        # the revision if the repository supports "invisible" revisions
 
183
        self.assertEqual(rev2a, tree_a.branch.last_revision())
 
184
        if tree_a.branch.repository._format.supports_unreferenced_revisions:
 
185
            self.assertTrue(tree_a.branch.repository.has_revision(rev2b))
 
186
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history']),
 
187
                           stop_revision=rev2b)
 
188
        self.assertEqual(rev2b, tree_a.branch.last_revision())
 
189
        self.assertEqual(tree_b.branch.last_revision(),
 
190
                         tree_a.branch.last_revision())
 
191
        self.assertEqual(rev1, tree_a.branch.tags.lookup_tag('tag1'))
 
192
        tree_a.branch.pull(tree_b.branch, overwrite=set(['history', 'tags']),
 
193
                           stop_revision=rev2b)
 
194
        self.assertEqual(rev2a, tree_a.branch.tags.lookup_tag('tag1'))
 
195
 
141
196
    def test_pull_merges_and_fetches_tags(self):
142
197
        """Tags are updated by br.pull(source), and revisions named in those
143
198
        tags are fetched.