143
143
bzr = self.run_bzr
145
145
def get_rh(expected_len):
146
rh = self.run_bzr(['revision-history'])[0]
146
rh = self.run_bzr('revision-history')[0]
147
147
# Make sure we don't have trailing empty revisions
148
148
rh = rh.strip().split('\n')
149
149
self.assertEqual(len(rh), expected_len)
155
155
open('foo', 'wb').write('original\n')
157
bzr('commit', '-m', 'initial commit')
157
bzr(['commit', '-m', 'initial commit'])
160
bzr('branch', 'a', 'b')
163
163
open('foo', 'wb').write('changed\n')
164
bzr('commit', '-m', 'later change')
164
bzr(['commit', '-m', 'later change'])
166
166
open('foo', 'wb').write('another\n')
167
bzr('commit', '-m', 'a third change')
167
bzr(['commit', '-m', 'a third change'])
169
169
rev_history_a = get_rh(3)
173
bzr('commit', '-m', 'merge')
173
bzr('commit -m merge')
175
175
rev_history_b = get_rh(2)
177
bzr('pull', '--overwrite', '../a')
177
bzr('pull --overwrite ../a')
178
178
rev_history_b = get_rh(3)
180
180
self.assertEqual(rev_history_b, rev_history_a)
185
185
bzr = self.run_bzr
187
187
def get_rh(expected_len):
188
rh = self.run_bzr(['revision-history'])[0]
188
rh = self.run_bzr('revision-history')[0]
189
189
# Make sure we don't have trailing empty revisions
190
190
rh = rh.strip().split('\n')
191
191
self.assertEqual(len(rh), expected_len)
197
197
open('foo', 'wb').write('original\n')
199
bzr('commit', '-m', 'initial commit')
199
bzr(['commit', '-m', 'initial commit'])
202
bzr('branch', 'a', 'b')
205
205
open('foo', 'wb').write('changed\n')
206
bzr('commit', '-m', 'later change')
206
bzr(['commit', '-m', 'later change'])
208
208
open('foo', 'wb').write('another\n')
209
bzr('commit', '-m', 'a third change')
209
bzr(['commit', '-m', 'a third change'])
211
211
rev_history_a = get_rh(3)
215
bzr('commit', '-m', 'merge')
215
bzr('commit -m merge')
217
217
rev_history_b = get_rh(2)
220
220
open('foo', 'wb').write('a fourth change\n')
221
bzr('commit', '-m', 'a fourth change')
221
bzr(['commit', '-m', 'a fourth change'])
223
223
rev_history_a = get_rh(4)
225
225
# With convergence, we could just pull over the
226
226
# new change, but with --overwrite, we want to switch our history
228
bzr('pull', '--overwrite', '../a')
228
bzr('pull --overwrite ../a')
229
229
rev_history_b = get_rh(4)
231
231
self.assertEqual(rev_history_b, rev_history_a)
294
294
# Create the bundle for 'b' to pull
295
295
os.chdir('branch_a')
296
296
bundle_file = open('../bundle', 'wb')
297
bundle_file.write(self.run_bzr('bundle', '../branch_b')[0])
297
bundle_file.write(self.run_bzr('bundle ../branch_b')[0])
298
298
bundle_file.close()
300
300
os.chdir('../branch_b')
301
out, err = self.run_bzr('pull', '../bundle')
301
out, err = self.run_bzr('pull ../bundle')
302
302
self.assertEqual(out,
303
303
'Now on revision 2.\n')
304
304
self.assertEqual(err,
315
315
testament_b.as_text())
317
317
# it is legal to attempt to pull an already-merged bundle
318
out, err = self.run_bzr('pull', '../bundle')
318
out, err = self.run_bzr('pull ../bundle')
319
319
self.assertEqual(err, '')
320
320
self.assertEqual(out, 'No revisions to pull.\n')