57
55
self.run_bzr('pull')
60
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
58
self.run_bzr('branch a b')
62
60
self.run_bzr('pull')
65
b_tree.commit(message='blah', allow_pointless=True)
70
self.assertEqual(a.revision_history(), b.revision_history()[:-1])
62
self.run_bzr('add subdir')
63
self.run_bzr('commit -m blah --unchanged')
66
b = Branch.open('../b')
67
self.assertEquals(a.revision_history(), b.revision_history()[:-1])
73
68
self.run_bzr('pull ../b')
74
self.assertEqual(a.revision_history(), b.revision_history())
75
a_tree.commit(message='blah2', allow_pointless=True)
76
b_tree.commit(message='blah3', allow_pointless=True)
69
self.assertEquals(a.revision_history(), b.revision_history())
70
self.run_bzr('commit -m blah2 --unchanged')
72
self.run_bzr('commit -m blah3 --unchanged')
79
74
self.run_bzr('pull ../a', retcode=3)
81
b_tree.bzrdir.sprout('overwriteme')
76
self.run_bzr('branch b overwriteme')
82
77
os.chdir('overwriteme')
83
78
self.run_bzr('pull --overwrite ../a')
84
79
overwritten = Branch.open('.')
85
80
self.assertEqual(overwritten.revision_history(),
86
81
a.revision_history())
87
a_tree.merge_from_branch(b_tree.branch)
88
a_tree.commit(message="blah4", allow_pointless=True)
83
self.run_bzr('merge ../b')
84
self.run_bzr('commit -m blah4 --unchanged')
89
85
os.chdir('../b/subdir')
90
86
self.run_bzr('pull ../../a')
91
self.assertEqual(a.revision_history()[-1], b.revision_history()[-1])
92
sub_tree = WorkingTree.open_containing('.')[0]
93
sub_tree.commit(message="blah5", allow_pointless=True)
94
sub_tree.commit(message="blah6", allow_pointless=True)
87
self.assertEquals(a.revision_history()[-1], b.revision_history()[-1])
88
self.run_bzr('commit -m blah5 --unchanged')
89
self.run_bzr('commit -m blah6 --unchanged')
96
91
self.run_bzr('pull ../a')
98
a_tree.commit(message="blah7", allow_pointless=True)
99
a_tree.merge_from_branch(b_tree.branch)
100
a_tree.commit(message="blah8", allow_pointless=True)
93
self.run_bzr('commit -m blah7 --unchanged')
94
self.run_bzr('merge ../b')
95
self.run_bzr('commit -m blah8 --unchanged')
101
96
self.run_bzr('pull ../b')
102
97
self.run_bzr('pull ../b')
104
99
def test_pull_dash_d(self):
105
self.example_branch('a')
106
self.make_branch_and_tree('b')
107
self.make_branch_and_tree('c')
102
self.example_branch()
103
self.run_bzr('init ../b')
104
self.run_bzr('init ../c')
108
105
# pull into that branch
109
self.run_bzr('pull -d b a')
106
self.run_bzr('pull -d ../b .')
110
107
# pull into a branch specified by a url
111
c_url = urlutils.local_path_to_url('c')
108
c_url = urlutils.local_path_to_url('../c')
112
109
self.assertStartsWith(c_url, 'file://')
113
self.run_bzr(['pull', '-d', c_url, 'a'])
110
self.run_bzr('pull -d %s .' % c_url)
115
112
def test_pull_revision(self):
116
113
"""Pull some changes from one branch to another."""
117
a_tree = self.example_branch('a')
118
self.build_tree_contents([
120
('a/goodbye2', 'baz')])
122
a_tree.commit(message="setup")
123
a_tree.add('goodbye2')
124
a_tree.commit(message="setup")
126
b_tree = a_tree.bzrdir.sprout('b',
127
revision_id=a_tree.branch.get_rev_id(1)).open_workingtree()
117
self.example_branch()
118
file('hello2', 'wt').write('foo')
119
self.run_bzr('add hello2')
120
self.run_bzr('commit -m setup hello2')
121
file('goodbye2', 'wt').write('baz')
122
self.run_bzr('add goodbye2')
123
self.run_bzr('commit -m setup goodbye2')
126
self.run_bzr('branch -r 1 a b')
129
128
self.run_bzr('pull -r 2')
130
129
a = Branch.open('../a')
131
130
b = Branch.open('.')
132
self.assertEqual(a.revno(),4)
133
self.assertEqual(b.revno(),2)
131
self.assertEquals(a.revno(),4)
132
self.assertEquals(b.revno(),2)
134
133
self.run_bzr('pull -r 3')
135
self.assertEqual(b.revno(),3)
134
self.assertEquals(b.revno(),3)
136
135
self.run_bzr('pull -r 4')
137
self.assertEqual(a.revision_history(), b.revision_history())
136
self.assertEquals(a.revision_history(), b.revision_history())
140
139
def test_overwrite_uptodate(self):
141
140
# Make sure pull --overwrite overwrites
142
141
# even if the target branch has merged
143
142
# everything already.
144
a_tree = self.make_branch_and_tree('a')
145
self.build_tree_contents([('a/foo', 'original\n')])
147
a_tree.commit(message='initial commit')
149
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
151
self.build_tree_contents([('a/foo', 'changed\n')])
152
a_tree.commit(message='later change')
154
self.build_tree_contents([('a/foo', 'a third change')])
155
a_tree.commit(message='a third change')
157
rev_history_a = a_tree.branch.revision_history()
158
self.assertEqual(len(rev_history_a), 3)
160
b_tree.merge_from_branch(a_tree.branch)
161
b_tree.commit(message='merge')
163
self.assertEqual(len(b_tree.branch.revision_history()), 2)
166
self.run_bzr('pull --overwrite ../a')
167
rev_history_b = b_tree.branch.revision_history()
168
self.assertEqual(len(rev_history_b), 3)
145
def get_rh(expected_len):
146
rh = self.run_bzr('revision-history')[0]
147
# Make sure we don't have trailing empty revisions
148
rh = rh.strip().split('\n')
149
self.assertEqual(len(rh), expected_len)
155
open('foo', 'wb').write('original\n')
157
bzr(['commit', '-m', 'initial commit'])
163
open('foo', 'wb').write('changed\n')
164
bzr(['commit', '-m', 'later change'])
166
open('foo', 'wb').write('another\n')
167
bzr(['commit', '-m', 'a third change'])
169
rev_history_a = get_rh(3)
173
bzr('commit -m merge')
175
rev_history_b = get_rh(2)
177
bzr('pull --overwrite ../a')
178
rev_history_b = get_rh(3)
170
180
self.assertEqual(rev_history_b, rev_history_a)
172
182
def test_overwrite_children(self):
173
183
# Make sure pull --overwrite sets the revision-history
174
184
# to be identical to the pull source, even if we have convergence
175
a_tree = self.make_branch_and_tree('a')
176
self.build_tree_contents([('a/foo', 'original\n')])
178
a_tree.commit(message='initial commit')
180
b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
182
self.build_tree_contents([('a/foo', 'changed\n')])
183
a_tree.commit(message='later change')
185
self.build_tree_contents([('a/foo', 'a third change')])
186
a_tree.commit(message='a third change')
188
self.assertEqual(len(a_tree.branch.revision_history()), 3)
190
b_tree.merge_from_branch(a_tree.branch)
191
b_tree.commit(message='merge')
193
self.assertEqual(len(b_tree.branch.revision_history()), 2)
195
self.build_tree_contents([('a/foo', 'a fourth change\n')])
196
a_tree.commit(message='a fourth change')
198
rev_history_a = a_tree.branch.revision_history()
199
self.assertEqual(len(rev_history_a), 4)
187
def get_rh(expected_len):
188
rh = self.run_bzr('revision-history')[0]
189
# Make sure we don't have trailing empty revisions
190
rh = rh.strip().split('\n')
191
self.assertEqual(len(rh), expected_len)
197
open('foo', 'wb').write('original\n')
199
bzr(['commit', '-m', 'initial commit'])
205
open('foo', 'wb').write('changed\n')
206
bzr(['commit', '-m', 'later change'])
208
open('foo', 'wb').write('another\n')
209
bzr(['commit', '-m', 'a third change'])
211
rev_history_a = get_rh(3)
215
bzr('commit -m merge')
217
rev_history_b = get_rh(2)
220
open('foo', 'wb').write('a fourth change\n')
221
bzr(['commit', '-m', 'a fourth change'])
223
rev_history_a = get_rh(4)
201
225
# With convergence, we could just pull over the
202
226
# new change, but with --overwrite, we want to switch our history
204
self.run_bzr('pull --overwrite ../a')
205
rev_history_b = b_tree.branch.revision_history()
206
self.assertEqual(len(rev_history_b), 4)
228
bzr('pull --overwrite ../a')
229
rev_history_b = get_rh(4)
208
231
self.assertEqual(rev_history_b, rev_history_a)