~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2011-05-17 12:12:09 UTC
  • mto: This revision was merged to the branch mainline in revision 5884.
  • Revision ID: v.ladeuil+lp@free.fr-20110517121209-j8so4msanb5ryk04
Fix send --no-remember when no location is set.

Show diffs side-by-side

added added

removed removed

Lines of Context:
346
346
 
347
347
 
348
348
class TestSendStrictWithChanges(tests.TestCaseWithTransport,
349
 
                                   TestSendStrictMixin):
 
349
                                TestSendStrictMixin):
350
350
 
351
351
    # These are textually the same as test_push.strict_push_change_scenarios,
352
352
    # but since the functions are reimplemented here, the definitions are left
433
433
class TestBundleStrictWithoutChanges(TestSendStrictWithoutChanges):
434
434
 
435
435
    _default_command = ['bundle-revisions', '../parent']
 
436
 
 
437
 
 
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
 
441
 
 
442
# * default does not override stored
 
443
# * --remember overrides stored
 
444
# * --no-remember does not override stored
 
445
 
 
446
class TestRemember(tests.TestCaseWithTransport, TestSendMixin):
 
447
 
 
448
    _default_wd = 'work'
 
449
 
 
450
    def setUp(self):
 
451
        super(TestRemember, self).setUp()
 
452
        grand_parent_tree = bzrdir.BzrDir.create_standalone_workingtree(
 
453
            'grand_parent')
 
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
 
458
 
 
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
 
463
 
 
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
 
468
 
 
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(
 
474
            'new_grand_parent')
 
475
        new_parent_tree = self.parent_tree.bzrdir.sprout('new_parent')
 
476
 
 
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())
 
481
 
 
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)
 
486
 
 
487
    def test_first_use_no_option(self):
 
488
        self.do_send(['../parent', '../grand_parent'])
 
489
        self.assertLocations('../parent', '../grand_parent')
 
490
 
 
491
    def test_first_use_remember(self):
 
492
        self.do_send(['--remember', '../parent', '../grand_parent'])
 
493
        self.assertLocations('../parent', '../grand_parent')
 
494
 
 
495
    def test_first_use_no_remember(self):
 
496
        self.do_send(['--no-remember', '../parent', '../grand_parent'])
 
497
        self.assertLocations(None, None)
 
498
 
 
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')
 
503
 
 
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')
 
508
 
 
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')