138
138
self.assertEqual(tree_b.branch.last_revision(),
139
139
tree_a.branch.last_revision())
141
def test_pull_overwrite_set(self):
142
tree_a = self.make_branch_and_tree('tree_a')
143
rev1 = tree_a.commit('message 1')
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']),
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']),
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)
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']),
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']),
194
self.assertEqual(rev2a, tree_a.branch.tags.lookup_tag('tag1'))
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.