81
82
rev1 = master_tree.commit('master')
82
83
checkout = master_tree.branch.create_checkout('checkout')
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())
93
95
master_tree = self.make_branch_and_tree('branch')
94
96
rev1 = master_tree.commit('master')
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())
103
106
def test_pull_returns_result(self):
138
141
self.assertEqual(tree_b.branch.last_revision(),
139
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
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']),
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']),
199
self.assertEqual(rev2b, tree_a.branch.tags.lookup_tag('tag1'))
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.