/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/branch_implementations/test_stacking.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-08 14:37:25 UTC
  • mfrom: (4516 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4517.
  • Revision ID: john@arbash-meinel.com-20090708143725-sc9sjy3mz4cxwxzz
Merge bzr.dev 4516

Show diffs side-by-side

added added

removed removed

Lines of Context:
78
78
            return
79
79
        self.assertEqual('../target', branch.get_stacked_on_url())
80
80
 
 
81
    def test_set_stacked_on_same_branch_raises(self):
 
82
        # Stacking on the same branch silently raises and doesn't execute the
 
83
        # change. Reported in bug 376243.
 
84
        branch = self.make_branch('branch')
 
85
        try:
 
86
            self.assertRaises(errors.UnstackableLocationError,
 
87
                branch.set_stacked_on_url, '../branch')
 
88
        except unstackable_format_errors:
 
89
            # if the set failed, so must the get
 
90
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
 
91
            return
 
92
        self.assertRaises(errors.NotStacked, branch.get_stacked_on_url)
 
93
 
 
94
    def test_set_stacked_on_same_branch_after_being_stacked_raises(self):
 
95
        # Stacking on the same branch silently raises and doesn't execute the
 
96
        # change.
 
97
        branch = self.make_branch('branch')
 
98
        target = self.make_branch('target')
 
99
        try:
 
100
            branch.set_stacked_on_url('../target')
 
101
        except unstackable_format_errors:
 
102
            # if the set failed, so must the get
 
103
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
 
104
            return
 
105
        self.assertRaises(errors.UnstackableLocationError,
 
106
            branch.set_stacked_on_url, '../branch')
 
107
        self.assertEqual('../target', branch.get_stacked_on_url())
 
108
 
81
109
    def assertRevisionInRepository(self, repo_path, revid):
82
110
        """Check that a revision is in a repository, disregarding stacking."""
83
111
        repo = bzrdir.BzrDir.open(repo_path).open_repository()
421
449
        # Ensure that opening the branch doesn't raise.
422
450
        branch.Branch.open(transport.base)
423
451
 
 
452
    def test_revision_history_of_stacked(self):
 
453
        # See <https://launchpad.net/bugs/380314>.
 
454
        stack_on = self.make_branch_and_tree('stack-on')
 
455
        stack_on.commit('first commit', rev_id='rev1')
 
456
        try:
 
457
            stacked_dir = stack_on.bzrdir.sprout(
 
458
                self.get_url('stacked'), stacked=True)
 
459
        except unstackable_format_errors, e:
 
460
            raise TestNotApplicable('Format does not support stacking.')
 
461
        try:
 
462
            stacked = stacked_dir.open_workingtree()
 
463
        except errors.NoWorkingTree:
 
464
            stacked = stacked_dir.open_branch().create_checkout(
 
465
                'stacked-checkout', lightweight=True)
 
466
        stacked.commit('second commit', rev_id='rev2')
 
467
        # Sanity check: stacked's repo should not contain rev1, otherwise this
 
468
        # test isn't testing what it's supposed to.
 
469
        repo = stacked.branch.repository.bzrdir.open_repository()
 
470
        repo.lock_read()
 
471
        self.addCleanup(repo.unlock)
 
472
        self.assertEqual({}, repo.get_parent_map(['rev1']))
 
473
        # revision_history should work, even though the history is spread over
 
474
        # multiple repositories.
 
475
        self.assertLength(2, stacked.branch.revision_history())
 
476
 
424
477
 
425
478
class TestStackingConnections(
426
479
    transport_util.TestCaseWithConnectionHookedTransport):