150
150
raise TestNotApplicable(e)
151
151
# stacked repository
152
152
self.assertRevisionNotInRepository('newbranch', trunk_revid)
153
new_tree = new_dir.open_workingtree()
154
new_branch_revid = new_tree.commit('something local')
153
tree = new_dir.open_branch().create_checkout('local')
154
new_branch_revid = tree.commit('something local')
155
155
self.assertRevisionNotInRepository('mainline', new_branch_revid)
156
156
self.assertRevisionInRepository('newbranch', new_branch_revid)
173
173
new_dir = remote_bzrdir.sprout('newbranch', stacked=True)
174
174
# stacked repository
175
175
self.assertRevisionNotInRepository('newbranch', trunk_revid)
176
new_tree = new_dir.open_workingtree()
177
new_branch_revid = new_tree.commit('something local')
176
tree = new_dir.open_branch().create_checkout('local')
177
new_branch_revid = tree.commit('something local')
178
178
self.assertRevisionNotInRepository('mainline', new_branch_revid)
179
179
self.assertRevisionInRepository('newbranch', new_branch_revid)
274
274
self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat),
275
275
cloned_bzrdir.open_branch().get_stacked_on_url)
277
def make_stacked_on_matching(self, source):
278
if source.repository.supports_rich_root():
279
if source.repository._format.supports_chks:
282
format = "1.9-rich-root"
285
return self.make_branch('stack-on', format)
277
287
def test_sprout_stacking_policy_handling(self):
278
288
"""Obey policy where possible, ignore otherwise."""
279
stack_on = self.make_branch('stack-on')
289
if isinstance(self.branch_format, branch.BzrBranchFormat4):
290
raise TestNotApplicable('Branch format 4 does not autoupgrade.')
291
source = self.make_branch('source')
292
stack_on = self.make_stacked_on_matching(source)
280
293
parent_bzrdir = self.make_bzrdir('.', format='default')
281
294
parent_bzrdir.get_config().set_default_stack_on('stack-on')
282
source = self.make_branch('source')
283
295
target = source.bzrdir.sprout('target').open_branch()
284
if self.branch_format.supports_stacking():
296
# When we sprout we upgrade the branch when there is a default stack_on
297
# set by a config *and* the targeted branch supports stacking.
298
if stack_on._format.supports_stacking():
285
299
self.assertEqual('../stack-on', target.get_stacked_on_url())
287
301
self.assertRaises(
290
304
def test_clone_stacking_policy_handling(self):
291
305
"""Obey policy where possible, ignore otherwise."""
292
stack_on = self.make_branch('stack-on')
306
if isinstance(self.branch_format, branch.BzrBranchFormat4):
307
raise TestNotApplicable('Branch format 4 does not autoupgrade.')
308
source = self.make_branch('source')
309
stack_on = self.make_stacked_on_matching(source)
293
310
parent_bzrdir = self.make_bzrdir('.', format='default')
294
311
parent_bzrdir.get_config().set_default_stack_on('stack-on')
295
source = self.make_branch('source')
296
312
target = source.bzrdir.clone('target').open_branch()
297
if self.branch_format.supports_stacking():
313
# When we clone we upgrade the branch when there is a default stack_on
314
# set by a config *and* the targeted branch supports stacking.
315
if stack_on._format.supports_stacking():
298
316
self.assertEqual('../stack-on', target.get_stacked_on_url())
300
318
self.assertRaises(
304
322
"""Obey policy where possible, ignore otherwise."""
305
323
if isinstance(self.branch_format, branch.BzrBranchFormat4):
306
324
raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
307
stack_on = self.make_branch('stack-on')
325
source = self.make_branch('source')
326
stack_on = self.make_stacked_on_matching(source)
308
327
parent_bzrdir = self.make_bzrdir('.', format='default')
309
328
parent_bzrdir.get_config().set_default_stack_on('stack-on')
310
source = self.make_branch('source')
311
329
url = self.make_smart_server('target').base
312
330
target = source.bzrdir.sprout(url).open_branch()
313
if self.branch_format.supports_stacking():
331
# When we sprout we upgrade the branch when there is a default stack_on
332
# set by a config *and* the targeted branch supports stacking.
333
if stack_on._format.supports_stacking():
314
334
self.assertEqual('../stack-on', target.get_stacked_on_url())
316
336
self.assertRaises(
334
354
def test_fetch_copies_from_stacked_on_and_stacked(self):
335
355
stacked, unstacked = self.prepare_stacked_on_fetch()
336
stacked.commit('second commit', rev_id='rev2')
356
tree = stacked.branch.create_checkout('local')
357
tree.commit('second commit', rev_id='rev2')
337
358
unstacked.fetch(stacked.branch.repository, 'rev2')
338
359
unstacked.get_revision('rev1')
339
360
unstacked.get_revision('rev2')
346
367
# repository boundaries. however, i didn't actually get this test to
347
368
# fail on that code. -- mbp
348
369
# see https://bugs.launchpad.net/bzr/+bug/252821
349
if not self.branch_format.supports_stacking():
370
stack_on = self.make_branch_and_tree('stack-on')
371
if not stack_on.branch._format.supports_stacking():
350
372
raise TestNotApplicable("%r does not support stacking"
351
373
% self.branch_format)
352
stack_on = self.make_branch_and_tree('stack-on')
353
374
text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
354
375
self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
355
376
stack_on.add('a')
356
377
stack_on.commit('base commit')
357
378
stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
358
stacked_tree = stacked_dir.open_workingtree()
379
stacked_branch = stacked_dir.open_branch()
380
local_tree = stack_on.bzrdir.sprout('local').open_workingtree()
359
381
for i in range(20):
360
382
text_lines[0] = 'changed in %d\n' % i
361
self.build_tree_contents([('stacked/a', ''.join(text_lines))])
362
stacked_tree.commit('commit %d' % i)
363
stacked_tree.branch.repository.pack()
364
check.check_dwim(stacked_tree.branch.base, False, True, True)
383
self.build_tree_contents([('local/a', ''.join(text_lines))])
384
local_tree.commit('commit %d' % i)
385
local_tree.branch.push(stacked_branch)
386
stacked_branch.repository.pack()
387
check.check_dwim(stacked_branch.base, False, True, True)
366
389
def test_pull_delta_when_stacked(self):
367
390
if not self.branch_format.supports_stacking():
470
493
except errors.NoWorkingTree:
471
494
stacked = stacked_dir.open_branch().create_checkout(
472
495
'stacked-checkout', lightweight=True)
473
stacked.commit('second commit', rev_id='rev2')
496
tree = stacked.branch.create_checkout('local')
497
tree.commit('second commit', rev_id='rev2')
474
498
# Sanity check: stacked's repo should not contain rev1, otherwise this
475
499
# test isn't testing what it's supposed to.
476
500
repo = stacked.branch.repository.bzrdir.open_repository()