37
37
super(TestLegacyFormats, self).setUp()
38
38
self.build_tree(['master/', 'child/'])
39
self.run_bzr('init', 'master')
40
self.run_bzr('init', '--format=weave', 'child')
39
self.run_bzr('init master')
40
self.run_bzr('init --format=weave child')
43
43
def test_bind_format_6_bzrdir(self):
44
44
# bind on a format 6 bzrdir should error
45
out,err = self.run_bzr('bind', '../master', retcode=3)
45
out,err = self.run_bzr('bind ../master', retcode=3)
46
46
self.assertEqual('', out)
47
47
# TODO: jam 20060427 Probably something like this really should
48
48
# print out the actual path, rather than the URL
86
86
self.build_tree(['base/', 'base/a', 'base/b'])
88
88
self.init_meta_branch('base')
89
self.run_bzr('add', 'base')
90
self.run_bzr('commit', '-m', 'init', 'base')
89
self.run_bzr('add base')
90
self.run_bzr('commit -m init base')
92
self.run_bzr('branch', 'base', 'child')
92
self.run_bzr('branch base child')
95
self.run_bzr('bind', '../base')
95
self.run_bzr('bind ../base')
97
97
d = BzrDir.open('')
98
98
self.assertNotEqual(None, d.open_branch().get_master_branch())
153
153
open('a', 'wb').write('new base contents\n')
154
bzr('commit', '-m', 'base')
154
bzr('commit -m base')
155
155
self.check_revno(2)
157
157
os.chdir('../child')
158
158
self.check_revno(1)
159
159
open('b', 'wb').write('new b child contents\n')
160
bzr('commit', '-m', 'child', retcode=3)
160
bzr('commit -m child', retcode=3)
161
161
self.check_revno(1)
164
164
self.check_revno(2)
166
bzr('commit', '-m', 'child')
166
bzr('commit -m child')
167
167
self.check_revno(3)
168
168
self.check_revno(3, '../base')
171
171
bzr = self.run_bzr
172
172
self.create_branches()
174
bzr('branch', 'child', 'child2')
174
bzr('branch child child2')
175
175
os.chdir('child2')
177
177
# Double binding succeeds, but committing to child2 should fail
178
bzr('bind', '../child')
180
bzr('commit', '-m', 'child2', '--unchanged', retcode=3)
180
bzr('commit -m child2 --unchanged', retcode=3)
182
182
def test_unbinding(self):
183
183
bzr = self.run_bzr
187
187
open('a', 'wb').write('new base contents\n')
188
bzr('commit', '-m', 'base')
188
bzr('commit -m base')
189
189
self.check_revno(2)
191
191
os.chdir('../child')
192
192
open('b', 'wb').write('new b child contents\n')
193
193
self.check_revno(1)
194
bzr('commit', '-m', 'child', retcode=3)
194
bzr('commit -m child', retcode=3)
195
195
self.check_revno(1)
197
bzr('commit', '-m', 'child')
197
bzr('commit -m child')
198
198
self.check_revno(2)
200
200
bzr('bind', retcode=3)
204
204
# which is bound to a branch which is bound
205
205
bzr = self.run_bzr
206
206
self.create_branches()
207
bzr('branch', 'base', 'newbase')
207
bzr('branch base newbase')
210
210
# There is no way to know that B has already
211
211
# been bound by someone else, otherwise it
212
212
# might be nice if this would fail
213
bzr('bind', '../newbase')
213
bzr('bind ../newbase')
215
215
os.chdir('../child')
216
bzr('commit', '-m', 'failure', '--unchanged', retcode=3)
216
bzr('commit -m failure --unchanged', retcode=3)
218
218
def test_pull_updates_both(self):
219
219
bzr = self.run_bzr
220
220
self.create_branches()
221
bzr('branch', 'base', 'newchild')
221
bzr('branch base newchild')
222
222
os.chdir('newchild')
223
223
open('b', 'wb').write('newchild b contents\n')
224
bzr('commit', '-m', 'newchild')
224
bzr('commit -m newchild')
225
225
self.check_revno(2)
227
227
os.chdir('../child')
228
228
# The pull should succeed, and update
229
229
# the bound parent branch
230
bzr('pull', '../newchild')
230
bzr('pull ../newchild')
231
231
self.check_revno(2)
233
233
self.check_revno(2, '../base')
239
239
os.chdir('child')
242
bzr('commit', '-m', 'child', '--unchanged')
242
bzr('commit -m child --unchanged')
243
243
self.check_revno(2)
245
245
os.chdir('../base')
246
246
self.check_revno(1)
247
bzr('commit', '-m', 'base', '--unchanged')
247
bzr('commit -m base --unchanged')
248
248
self.check_revno(2)
250
250
os.chdir('../child')
251
251
# These branches have diverged
252
bzr('bind', '../base', retcode=3)
252
bzr('bind ../base', retcode=3)
254
254
# TODO: In the future, this might require actual changes
255
255
# to have occurred, rather than just a new revision entry
256
bzr('merge', '../base')
257
bzr('commit', '-m', 'merged')
257
bzr('commit -m merged')
258
258
self.check_revno(3)
260
260
# After binding, the revision history should be unaltered
295
295
# Check and make sure it also works if parent is ahead multiple
296
296
os.chdir('../base')
297
bzr('commit', '-m', 'base 3', '--unchanged')
298
bzr('commit', '-m', 'base 4', '--unchanged')
299
bzr('commit', '-m', 'base 5', '--unchanged')
297
bzr(['commit', '-m', 'base 3', '--unchanged'])
298
bzr(['commit', '-m', 'base 4', '--unchanged'])
299
bzr(['commit', '-m', 'base 5', '--unchanged'])
300
300
self.check_revno(5)
302
302
os.chdir('../child')
303
303
self.check_revno(1)
304
bzr('bind', '../base')
305
305
self.check_revno(1)
307
307
def test_bind_child_ahead(self):
314
314
os.chdir('child')
316
bzr('commit', '-m', 'child', '--unchanged')
316
bzr('commit -m child --unchanged')
317
317
self.check_revno(2)
318
318
self.check_revno(1, '../base')
320
bzr('bind', '../base')
321
321
self.check_revno(1, '../base')
323
323
# Check and make sure it also works if child is ahead multiple
325
bzr('commit', '-m', 'child 3', '--unchanged')
326
bzr('commit', '-m', 'child 4', '--unchanged')
327
bzr('commit', '-m', 'child 5', '--unchanged')
325
bzr(['commit', '-m', 'child 3', '--unchanged'])
326
bzr(['commit', '-m', 'child 4', '--unchanged'])
327
bzr(['commit', '-m', 'child 5', '--unchanged'])
328
328
self.check_revno(5)
330
330
self.check_revno(1, '../base')
331
bzr('bind', '../base')
332
332
self.check_revno(1, '../base')
334
334
def test_commit_after_merge(self):
340
340
# the binding invariants.
341
341
# But we can't fail afterwards
343
bzr('branch', 'child', 'other')
343
bzr('branch child other')
345
345
os.chdir('other')
346
346
open('c', 'wb').write('file c\n')
348
bzr('commit', '-m', 'adding c')
348
bzr(['commit', '-m', 'adding c'])
349
349
new_rev_id = bzr('revision-history')[0].strip().split('\n')[-1]
351
351
os.chdir('../child')
352
bzr('merge', '../other')
352
bzr('merge ../other')
354
354
self.failUnlessExists('c')
355
355
tree = WorkingTree.open('.') # opens child
356
356
self.assertEqual([new_rev_id], tree.get_parent_ids()[1:])
358
358
# Make sure the local branch has the installed revision
359
bzr('cat-revision', new_rev_id)
359
bzr(['cat-revision', new_rev_id])
361
361
# And make sure that the base tree does not
362
362
os.chdir('../base')
363
bzr('cat-revision', new_rev_id, retcode=3)
363
bzr(['cat-revision', new_rev_id], retcode=3)
365
365
# Commit should succeed, and cause merged revisions to
366
366
# be pulled into base
367
367
os.chdir('../child')
368
bzr('commit', '-m', 'merge other')
368
bzr(['commit', '-m', 'merge other'])
370
370
self.check_revno(2)
372
372
os.chdir('../base')
373
373
self.check_revno(2)
375
bzr('cat-revision', new_rev_id)
375
bzr(['cat-revision', new_rev_id])
377
377
def test_pull_overwrite(self):
378
378
# XXX: This test should be moved to branch-implemenations/test_pull
379
379
bzr = self.run_bzr
380
380
self.create_branches()
382
bzr('branch', 'child', 'other')
382
bzr('branch child other')
384
384
os.chdir('other')
385
385
open('a', 'wb').write('new contents\n')
386
bzr('commit', '-m', 'changed a')
386
bzr(['commit', '-m', 'changed a'])
387
387
self.check_revno(2)
388
388
open('a', 'ab').write('and then some\n')
389
bzr('commit', '-m', 'another a')
389
bzr(['commit', '-m', 'another a'])
390
390
self.check_revno(3)
391
391
open('a', 'ab').write('and some more\n')
392
bzr('commit', '-m', 'yet another a')
392
bzr(['commit', '-m', 'yet another a'])
393
393
self.check_revno(4)
395
395
os.chdir('../child')
396
396
open('a', 'wb').write('also changed a\n')
397
bzr('commit', '-m', 'child modified a')
397
bzr(['commit', '-m', 'child modified a'])
399
399
self.check_revno(2)
400
400
self.check_revno(2, '../base')
402
bzr('pull', '--overwrite', '../other')
402
bzr('pull --overwrite ../other')
404
404
# both the local and master should have been updated.
405
405
self.check_revno(4)