/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_bound_branches.py

  • Committer: John Arbash Meinel
  • Date: 2007-07-11 23:45:20 UTC
  • mfrom: (2601 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070711234520-do3h7zw8skbathpz
[merge] bzr.dev 2601

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    def setUp(self):
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')
41
41
        os.chdir('child')
42
42
    
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
72
72
        tree.commit('init')
73
73
        tree.unlock()
74
74
 
75
 
        self.run_bzr('checkout', 'base', 'child')
 
75
        self.run_bzr('checkout base child')
76
76
 
77
77
        self.check_revno(1, 'child')
78
78
        d = BzrDir.open('child')
86
86
        self.build_tree(['base/', 'base/a', 'base/b'])
87
87
 
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')
91
91
 
92
 
        self.run_bzr('branch', 'base', 'child')
 
92
        self.run_bzr('branch base child')
93
93
 
94
94
        os.chdir('child')
95
 
        self.run_bzr('bind', '../base')
 
95
        self.run_bzr('bind ../base')
96
96
 
97
97
        d = BzrDir.open('')
98
98
        self.assertNotEqual(None, d.open_branch().get_master_branch())
137
137
 
138
138
        os.chdir('child')
139
139
        open('a', 'wb').write('new contents\n')
140
 
        bzr('commit', '-m', 'child')
 
140
        bzr('commit -m child')
141
141
 
142
142
        self.check_revno(2)
143
143
 
151
151
 
152
152
        os.chdir('base')
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)
156
156
 
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)
162
162
 
163
163
        bzr('update')
164
164
        self.check_revno(2)
165
165
 
166
 
        bzr('commit', '-m', 'child')
 
166
        bzr('commit -m child')
167
167
        self.check_revno(3)
168
168
        self.check_revno(3, '../base')
169
169
 
171
171
        bzr = self.run_bzr
172
172
        self.create_branches()
173
173
 
174
 
        bzr('branch', 'child', 'child2')
 
174
        bzr('branch child child2')
175
175
        os.chdir('child2')
176
176
 
177
177
        # Double binding succeeds, but committing to child2 should fail
178
 
        bzr('bind', '../child')
 
178
        bzr('bind ../child')
179
179
 
180
 
        bzr('commit', '-m', 'child2', '--unchanged', retcode=3)
 
180
        bzr('commit -m child2 --unchanged', retcode=3)
181
181
 
182
182
    def test_unbinding(self):
183
183
        bzr = self.run_bzr
185
185
 
186
186
        os.chdir('base')
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)
190
190
 
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)
196
196
        bzr('unbind')
197
 
        bzr('commit', '-m', 'child')
 
197
        bzr('commit -m child')
198
198
        self.check_revno(2)
199
199
 
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')
208
208
        os.chdir('base')
209
209
        
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')
214
214
 
215
215
        os.chdir('../child')
216
 
        bzr('commit', '-m', 'failure', '--unchanged', retcode=3)
 
216
        bzr('commit -m failure --unchanged', retcode=3)
217
217
 
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)
226
226
 
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)
232
232
 
233
233
        self.check_revno(2, '../base')
239
239
        os.chdir('child')
240
240
        bzr('unbind')
241
241
 
242
 
        bzr('commit', '-m', 'child', '--unchanged')
 
242
        bzr('commit -m child --unchanged')
243
243
        self.check_revno(2)
244
244
 
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)
249
249
 
250
250
        os.chdir('../child')
251
251
        # These branches have diverged
252
 
        bzr('bind', '../base', retcode=3)
 
252
        bzr('bind ../base', retcode=3)
253
253
 
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')
 
256
        bzr('merge ../base')
 
257
        bzr('commit -m merged')
258
258
        self.check_revno(3)
259
259
 
260
260
        # After binding, the revision history should be unaltered
266
266
 
267
267
        # After a merge, trying to bind again should succeed
268
268
        # keeping the new change as a local commit.
269
 
        bzr('bind', '../base')
 
269
        bzr('bind ../base')
270
270
        self.check_revno(3)
271
271
        self.check_revno(2, '../base')
272
272
 
282
282
        bzr('unbind')
283
283
 
284
284
        os.chdir('../base')
285
 
        bzr('commit', '-m', 'base', '--unchanged')
 
285
        bzr('commit -m base --unchanged')
286
286
 
287
287
        os.chdir('../child')
288
288
        self.check_revno(1)
289
 
        bzr('bind', '../base')
 
289
        bzr('bind ../base')
290
290
 
291
291
        # binding does not pull data:
292
292
        self.check_revno(1)
294
294
 
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)
301
301
 
302
302
        os.chdir('../child')
303
303
        self.check_revno(1)
304
 
        bzr('bind', '../base')
 
304
        bzr('bind ../base')
305
305
        self.check_revno(1)
306
306
 
307
307
    def test_bind_child_ahead(self):
313
313
 
314
314
        os.chdir('child')
315
315
        bzr('unbind')
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')
319
319
 
320
 
        bzr('bind', '../base')
 
320
        bzr('bind ../base')
321
321
        self.check_revno(1, '../base')
322
322
 
323
323
        # Check and make sure it also works if child is ahead multiple
324
324
        bzr('unbind')
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)
329
329
 
330
330
        self.check_revno(1, '../base')
331
 
        bzr('bind', '../base')
 
331
        bzr('bind ../base')
332
332
        self.check_revno(1, '../base')
333
333
 
334
334
    def test_commit_after_merge(self):
340
340
        # the binding invariants.
341
341
        # But we can't fail afterwards
342
342
 
343
 
        bzr('branch', 'child', 'other')
 
343
        bzr('branch child other')
344
344
 
345
345
        os.chdir('other')
346
346
        open('c', 'wb').write('file c\n')
347
 
        bzr('add', 'c')
348
 
        bzr('commit', '-m', 'adding c')
 
347
        bzr('add c')
 
348
        bzr(['commit', '-m', 'adding c'])
349
349
        new_rev_id = bzr('revision-history')[0].strip().split('\n')[-1]
350
350
 
351
351
        os.chdir('../child')
352
 
        bzr('merge', '../other')
 
352
        bzr('merge ../other')
353
353
 
354
354
        self.failUnlessExists('c')
355
355
        tree = WorkingTree.open('.') # opens child
356
356
        self.assertEqual([new_rev_id], tree.get_parent_ids()[1:])
357
357
 
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])
360
360
        
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)
364
364
 
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'])
369
369
 
370
370
        self.check_revno(2)
371
371
 
372
372
        os.chdir('../base')
373
373
        self.check_revno(2)
374
374
 
375
 
        bzr('cat-revision', new_rev_id)
 
375
        bzr(['cat-revision', new_rev_id])
376
376
 
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()
381
381
 
382
 
        bzr('branch', 'child', 'other')
 
382
        bzr('branch child other')
383
383
        
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)
394
394
 
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'])
398
398
 
399
399
        self.check_revno(2)
400
400
        self.check_revno(2, '../base')
401
401
 
402
 
        bzr('pull', '--overwrite', '../other')
 
402
        bzr('pull --overwrite ../other')
403
403
 
404
404
        # both the local and master should have been updated.
405
405
        self.check_revno(4)