~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_branch/test_stacking.py

  • Committer: Martin Pool
  • Date: 2009-08-04 11:40:59 UTC
  • mfrom: (4584 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4586.
  • Revision ID: mbp@sourcefrog.net-20090804114059-xptutagbs5jev3ry
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.revision import NULL_REVISION
25
25
from bzrlib.smart import server
26
26
from bzrlib.tests import TestNotApplicable, KnownFailure, transport_util
27
 
from bzrlib.tests.branch_implementations import TestCaseWithBranch
 
27
from bzrlib.tests.per_branch import TestCaseWithBranch
28
28
from bzrlib.transport import get_transport
29
29
 
30
30
 
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()
156
184
        trunk_revid = trunk_tree.commit('revision on mainline')
157
185
        # and make branch from it which is stacked
158
186
        try:
159
 
            new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
 
187
            new_dir = trunk_tree.bzrdir.sprout(self.get_url('newbranch'),
 
188
                stacked=True)
160
189
        except unstackable_format_errors, e:
161
190
            raise TestNotApplicable(e)
162
191
        # stacked repository
163
192
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
 
193
        # TODO: we'd like to commit in the stacked repository; that requires
 
194
        # some care (maybe a BranchBuilder) if it's remote and has no
 
195
        # workingtree
 
196
        ##newbranch_revid = new_dir.open_workingtree().commit('revision in '
 
197
            ##'newbranch')
164
198
        # now when we unstack that should implicitly fetch, to make sure that
165
199
        # the branch will still work
166
200
        new_branch = new_dir.open_branch()