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()
58
57
self.run_bzr('pull', retcode=3)
59
58
self.run_bzr('missing', retcode=3)
72
71
self.run_bzr('pull')
74
73
b_tree.add('subdir')
75
new_rev = b_tree.commit(message='blah', allow_pointless=True)
74
b_tree.commit(message='blah', allow_pointless=True)
78
77
a = Branch.open('a')
79
78
b = Branch.open('b')
80
self.assertEqual(a.last_revision(), base_rev)
81
self.assertEqual(b.last_revision(), new_rev)
79
self.assertEqual(a.revision_history(), b.revision_history()[:-1])
84
82
self.run_bzr('pull ../b')
85
self.assertEqual(a.last_revision(), b.last_revision())
83
self.assertEqual(a.revision_history(), b.revision_history())
86
84
a_tree.commit(message='blah2', allow_pointless=True)
87
85
b_tree.commit(message='blah3', allow_pointless=True)
93
91
os.chdir('overwriteme')
94
92
self.run_bzr('pull --overwrite ../a')
95
93
overwritten = Branch.open('.')
96
self.assertEqual(overwritten.last_revision(),
94
self.assertEqual(overwritten.revision_history(),
98
96
a_tree.merge_from_branch(b_tree.branch)
99
97
a_tree.commit(message="blah4", allow_pointless=True)
100
98
os.chdir('../b/subdir')
101
99
self.run_bzr('pull ../../a')
102
self.assertEqual(a.last_revision(), b.last_revision())
100
self.assertEqual(a.revision_history()[-1], b.revision_history()[-1])
103
101
sub_tree = WorkingTree.open_containing('.')[0]
104
102
sub_tree.commit(message="blah5", allow_pointless=True)
105
103
sub_tree.commit(message="blah6", allow_pointless=True)
145
143
self.run_bzr('pull -r 3')
146
144
self.assertEqual(b.revno(),3)
147
145
self.run_bzr('pull -r 4')
148
self.assertEqual(a.last_revision(), b.last_revision())
146
self.assertEqual(a.revision_history(), b.revision_history())
150
148
def test_pull_tags(self):
151
149
"""Tags are updated by pull, and revisions named in those tags are
181
179
self.build_tree_contents([('a/foo', 'a third change')])
182
180
a_tree.commit(message='a third change')
184
self.assertEqual(a_tree.branch.last_revision_info()[0], 3)
182
rev_history_a = a_tree.branch.revision_history()
183
self.assertEqual(len(rev_history_a), 3)
186
185
b_tree.merge_from_branch(a_tree.branch)
187
186
b_tree.commit(message='merge')
189
self.assertEqual(b_tree.branch.last_revision_info()[0], 2)
188
self.assertEqual(len(b_tree.branch.revision_history()), 2)
192
191
self.run_bzr('pull --overwrite ../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())
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)
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(a_tree.branch.last_revision_info()[0], 3)
213
self.assertEqual(len(a_tree.branch.revision_history()), 3)
215
215
b_tree.merge_from_branch(a_tree.branch)
216
216
b_tree.commit(message='merge')
218
self.assertEqual(b_tree.branch.last_revision_info()[0], 2)
218
self.assertEqual(len(b_tree.branch.revision_history()), 2)
220
220
self.build_tree_contents([('a/foo', 'a fourth change\n')])
221
221
a_tree.commit(message='a fourth change')
223
rev_info_a = a_tree.branch.last_revision_info()
224
self.assertEqual(rev_info_a[0], 4)
223
rev_history_a = a_tree.branch.revision_history()
224
self.assertEqual(len(rev_history_a), 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_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)
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)
234
235
def test_pull_remember(self):
235
236
"""Pull changes from one branch to another and test parent location."""
304
305
self.assertEqual(err,
305
306
' M a\nAll changes applied successfully.\n')
307
self.assertEqualDiff(tree_a.branch.last_revision(),
308
tree_b.branch.last_revision())
308
self.assertEqualDiff(tree_a.branch.revision_history(),
309
tree_b.branch.revision_history())
310
311
testament_a = Testament.from_revision(tree_a.branch.repository,
311
312
tree_a.get_parent_ids()[0])