71
69
rev2 = other.commit('other commit')
72
70
# now pull, which should update both checkout and master.
73
71
checkout.branch.pull(other.branch)
74
self.assertEqual(rev2, checkout.branch.last_revision())
75
self.assertEqual(rev2, master_tree.branch.last_revision())
72
self.assertEqual([rev1, rev2], checkout.branch.revision_history())
73
self.assertEqual([rev1, rev2], master_tree.branch.revision_history())
77
75
def test_pull_local_updates_checkout_only(self):
78
76
"""Pulling --local into a checkout updates the checkout and not the
85
83
rev2 = other.commit('other commit')
86
84
# now pull local, which should update checkout but not master.
87
85
checkout.branch.pull(other.branch, local = True)
88
self.assertEqual(rev2, checkout.branch.last_revision())
89
self.assertEqual(rev1, master_tree.branch.last_revision())
86
self.assertEqual([rev1, rev2], checkout.branch.revision_history())
87
self.assertEqual([rev1], master_tree.branch.revision_history())
91
89
def test_pull_local_raises_LocalRequiresBoundBranch_on_unbound(self):
92
90
"""Pulling --local into a branch that is not bound should fail."""
98
96
# now pull --local, which should raise LocalRequiresBoundBranch error.
99
97
self.assertRaises(errors.LocalRequiresBoundBranch,
100
98
master_tree.branch.pull, other.branch, local = True)
101
self.assertEqual(rev1, master_tree.branch.last_revision())
99
self.assertEqual([rev1], master_tree.branch.revision_history())
103
101
def test_pull_returns_result(self):
104
102
parent = self.make_branch_and_tree('parent')
128
126
tree_a.branch.pull, tree_b.branch,
129
127
overwrite=False, stop_revision='rev2b')
130
128
# It should not have updated the branch tip, but it should have fetched
131
# the revision if the repository supports "invisible" revisions
132
130
self.assertEqual('rev2a', tree_a.branch.last_revision())
133
if tree_a.branch.repository._format.supports_unreferenced_revisions:
134
self.assertTrue(tree_a.branch.repository.has_revision('rev2b'))
131
self.assertTrue(tree_a.branch.repository.has_revision('rev2b'))
135
132
tree_a.branch.pull(tree_b.branch, overwrite=True,
136
133
stop_revision='rev2b')
137
134
self.assertEqual('rev2b', tree_a.branch.last_revision())
138
self.assertEqual(tree_b.branch.last_revision(),
139
tree_a.branch.last_revision())
141
def test_pull_merges_and_fetches_tags(self):
142
"""Tags are updated by br.pull(source), and revisions named in those
145
# Make a source, sprout a target off it
147
builder = self.make_branch_builder('source')
148
except errors.UninitializableFormat:
149
raise TestNotApplicable('uninitializeable format')
150
source = fixtures.build_branch_with_non_ancestral_rev(builder)
151
target = source.bzrdir.sprout('target').open_branch()
152
# Add a tag to the source, then pull from source
154
source.tags.set_tag('tag-a', 'rev-2')
155
except errors.TagsNotSupported:
156
raise TestNotApplicable('format does not support tags.')
157
source.tags.set_tag('tag-a', 'rev-2')
158
source.get_config_stack().set('branch.fetch_tags', True)
160
# The tag is present, and so is its revision.
161
self.assertEqual('rev-2', target.tags.lookup_tag('tag-a'))
162
target.repository.get_revision('rev-2')
164
def test_pull_stop_revision_merges_and_fetches_tags(self):
165
"""br.pull(source, stop_revision=REV) updates and fetches tags."""
166
# Make a source, sprout a target off it
168
builder = self.make_branch_builder('source')
169
except errors.UninitializableFormat:
170
raise TestNotApplicable('uninitializeable format')
171
source = fixtures.build_branch_with_non_ancestral_rev(builder)
172
target = source.bzrdir.sprout('target').open_branch()
173
# Add a new commit to the ancestry
174
builder.build_commit(message="Rev 2 again", rev_id='rev-2-again')
175
# Add a tag to the source, then pull rev-2-again from source
177
source.tags.set_tag('tag-a', 'rev-2')
178
except errors.TagsNotSupported:
179
raise TestNotApplicable('format does not support tags.')
180
source.get_config_stack().set('branch.fetch_tags', True)
181
target.pull(source, 'rev-2-again')
182
# The tag is present, and so is its revision.
183
self.assertEqual('rev-2', target.tags.lookup_tag('tag-a'))
184
target.repository.get_revision('rev-2')
135
self.assertEqual(tree_b.branch.revision_history(),
136
tree_a.branch.revision_history())
187
139
class TestPullHook(per_branch.TestCaseWithBranch):