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