433
433
class TestBundleStrictWithoutChanges(TestSendStrictWithoutChanges):
435
435
_default_command = ['bundle-revisions', '../parent']
438
# * first use remembers by default
439
# * first use remembers if --remember is used
440
# * first use does not remember if --no-remember is used
442
# * default does not override stored
443
# * --remember overrides stored
444
# * --no-remember does not override stored
446
class TestRemember(tests.TestCaseWithTransport, TestSendMixin):
451
super(TestRemember, self).setUp()
452
grand_parent_tree = bzrdir.BzrDir.create_standalone_workingtree(
454
self.build_tree_contents([('grand_parent/file1', 'grand_parent')])
455
grand_parent_tree.add('file1')
456
grand_parent_tree.commit('initial commit', rev_id='grand_parent')
457
self.grand_parent_tree = grand_parent_tree
459
parent_bzrdir = grand_parent_tree.bzrdir.sprout('parent')
460
parent_tree = parent_bzrdir.open_workingtree()
461
parent_tree.commit('next commit', rev_id='parent')
462
self.parent_tree = parent_tree
464
branch_tree = parent_tree.bzrdir.sprout('branch').open_workingtree()
465
self.build_tree_contents([('branch/file1', 'branch')])
466
branch_tree.commit('last commit', rev_id='branch')
467
self.branch_tree = branch_tree
469
def prepare_next_uses(self):
470
# Do a first send that remembers the locations
471
self.do_send(['../parent', '../grand_parent'])
472
# Now create some new targets
473
new_grand_parent_tree = self.grand_parent_tree.bzrdir.sprout(
475
new_parent_tree = self.parent_tree.bzrdir.sprout('new_parent')
477
def assertLocations(self, expected_submit_branch, expected_public_branch):
478
br = self.branch_tree.branch
479
self.assertEquals(expected_submit_branch, br.get_submit_branch())
480
self.assertEquals(expected_public_branch, br.get_public_branch())
482
def do_send(self, *args):
483
# We always expect the same result here and care only about the
484
# arguments used and their consequences on the remembered locations
485
self.assertBundleContains(['branch'], *args)
487
def test_first_use_no_option(self):
488
self.do_send(['../parent', '../grand_parent'])
489
self.assertLocations('../parent', '../grand_parent')
491
def test_first_use_remember(self):
492
self.do_send(['--remember', '../parent', '../grand_parent'])
493
self.assertLocations('../parent', '../grand_parent')
495
def test_first_use_no_remember(self):
496
self.do_send(['--no-remember', '../parent', '../grand_parent'])
497
self.assertLocations(None, None)
499
def test_next_uses_no_option(self):
500
self.prepare_next_uses()
501
self.do_send(['../new_parent', '../new_grand_parent'])
502
self.assertLocations('../parent', '../grand_parent')
504
def test_next_uses_remember(self):
505
self.prepare_next_uses()
506
self.do_send(['--remember', '../new_parent', '../new_grand_parent'])
507
self.assertLocations('../new_parent', '../new_grand_parent')
509
def test_next_uses_no_remember(self):
510
self.prepare_next_uses()
511
self.do_send(['--no-remember', '../new_parent', '../new_grand_parent'])
512
self.assertLocations('../parent', '../grand_parent')