141
141
self.assertEqual(tree_b.branch.last_revision(),
142
142
tree_a.branch.last_revision())
144
def test_pull_overwrite_set(self):
145
tree_a = self.make_branch_and_tree('tree_a')
146
rev1 = tree_a.commit('message 1')
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']),
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']),
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)
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']),
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']),
197
self.assertEqual(rev2a, tree_a.branch.tags.lookup_tag('tag1'))
144
199
def test_pull_merges_and_fetches_tags(self):
145
200
"""Tags are updated by br.pull(source), and revisions named in those
146
201
tags are fetched.