53
53
def test_pull(self):
54
54
"""Pull changes from one branch to another."""
55
55
a_tree = self.example_branch('a')
56
base_rev = a_tree.branch.last_revision()
57
58
self.run_bzr('pull', retcode=3)
58
59
self.run_bzr('missing', retcode=3)
71
72
self.run_bzr('pull')
73
74
b_tree.add('subdir')
74
b_tree.commit(message='blah', allow_pointless=True)
75
new_rev = b_tree.commit(message='blah', allow_pointless=True)
77
78
a = Branch.open('a')
78
79
b = Branch.open('b')
79
self.assertEqual(a.revision_history(), b.revision_history()[:-1])
80
self.assertEqual(a.last_revision(), base_rev)
81
self.assertEqual(b.last_revision(), new_rev)
82
84
self.run_bzr('pull ../b')
83
self.assertEqual(a.revision_history(), b.revision_history())
85
self.assertEqual(a.last_revision(), b.last_revision())
84
86
a_tree.commit(message='blah2', allow_pointless=True)
85
87
b_tree.commit(message='blah3', allow_pointless=True)
91
93
os.chdir('overwriteme')
92
94
self.run_bzr('pull --overwrite ../a')
93
95
overwritten = Branch.open('.')
94
self.assertEqual(overwritten.revision_history(),
96
self.assertEqual(overwritten.last_revision(),
96
98
a_tree.merge_from_branch(b_tree.branch)
97
99
a_tree.commit(message="blah4", allow_pointless=True)
98
100
os.chdir('../b/subdir')
99
101
self.run_bzr('pull ../../a')
100
self.assertEqual(a.revision_history()[-1], b.revision_history()[-1])
102
self.assertEqual(a.last_revision(), b.last_revision())
101
103
sub_tree = WorkingTree.open_containing('.')[0]
102
104
sub_tree.commit(message="blah5", allow_pointless=True)
103
105
sub_tree.commit(message="blah6", allow_pointless=True)
143
145
self.run_bzr('pull -r 3')
144
146
self.assertEqual(b.revno(),3)
145
147
self.run_bzr('pull -r 4')
146
self.assertEqual(a.revision_history(), b.revision_history())
148
self.assertEqual(a.last_revision(), b.last_revision())
148
150
def test_pull_tags(self):
149
151
"""Tags are updated by pull, and revisions named in those tags are
179
181
self.build_tree_contents([('a/foo', 'a third change')])
180
182
a_tree.commit(message='a third change')
182
rev_history_a = a_tree.branch.revision_history()
183
self.assertEqual(len(rev_history_a), 3)
184
self.assertEqual(a_tree.branch.last_revision_info()[0], 3)
185
186
b_tree.merge_from_branch(a_tree.branch)
186
187
b_tree.commit(message='merge')
188
self.assertEqual(len(b_tree.branch.revision_history()), 2)
189
self.assertEqual(b_tree.branch.last_revision_info()[0], 2)
191
192
self.run_bzr('pull --overwrite ../a')
192
rev_history_b = b_tree.branch.revision_history()
193
self.assertEqual(len(rev_history_b), 3)
195
self.assertEqual(rev_history_b, rev_history_a)
193
(last_revinfo_b) = b_tree.branch.last_revision_info()
194
self.assertEqual(last_revinfo_b[0], 3)
195
self.assertEqual(last_revinfo_b[1], a_tree.branch.last_revision())
197
197
def test_overwrite_children(self):
198
198
# Make sure pull --overwrite sets the revision-history
210
210
self.build_tree_contents([('a/foo', 'a third change')])
211
211
a_tree.commit(message='a third change')
213
self.assertEqual(len(a_tree.branch.revision_history()), 3)
213
self.assertEqual(a_tree.branch.last_revision_info()[0], 3)
215
215
b_tree.merge_from_branch(a_tree.branch)
216
216
b_tree.commit(message='merge')
218
self.assertEqual(len(b_tree.branch.revision_history()), 2)
218
self.assertEqual(b_tree.branch.last_revision_info()[0], 2)
220
220
self.build_tree_contents([('a/foo', 'a fourth change\n')])
221
221
a_tree.commit(message='a fourth change')
223
rev_history_a = a_tree.branch.revision_history()
224
self.assertEqual(len(rev_history_a), 4)
223
rev_info_a = a_tree.branch.last_revision_info()
224
self.assertEqual(rev_info_a[0], 4)
226
226
# With convergence, we could just pull over the
227
227
# new change, but with --overwrite, we want to switch our history
229
229
self.run_bzr('pull --overwrite ../a')
230
rev_history_b = b_tree.branch.revision_history()
231
self.assertEqual(len(rev_history_b), 4)
233
self.assertEqual(rev_history_b, rev_history_a)
230
rev_info_b = b_tree.branch.last_revision_info()
231
self.assertEqual(rev_info_b[0], 4)
232
self.assertEqual(rev_info_b, rev_info_a)
235
234
def test_pull_remember(self):
236
235
"""Pull changes from one branch to another and test parent location."""
305
304
self.assertEqual(err,
306
305
' M a\nAll changes applied successfully.\n')
308
self.assertEqualDiff(tree_a.branch.revision_history(),
309
tree_b.branch.revision_history())
307
self.assertEqualDiff(tree_a.branch.last_revision(),
308
tree_b.branch.last_revision())
311
310
testament_a = Testament.from_revision(tree_a.branch.repository,
312
311
tree_a.get_parent_ids()[0])