~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge pt1 hooks branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    errors,
24
24
    )
25
25
from bzrlib.revision import NULL_REVISION
26
 
from bzrlib.tests import TestNotApplicable, transport_util
 
26
from bzrlib.tests import fixtures, TestNotApplicable, transport_util
27
27
from bzrlib.tests.per_branch import TestCaseWithBranch
28
28
 
29
29
 
176
176
 
177
177
    def test_unstack_fetches(self):
178
178
        """Removing the stacked-on branch pulls across all data"""
 
179
        try:
 
180
            builder = self.make_branch_builder('trunk')
 
181
        except errors.UninitializableFormat:
 
182
            raise TestNotApplicable('uninitializeable format')
179
183
        # We have a mainline
180
 
        trunk_tree = self.make_branch_and_tree('mainline')
181
 
        trunk_revid = trunk_tree.commit('revision on mainline')
182
 
        # and make branch from it which is stacked
 
184
        trunk = fixtures.build_branch_with_non_ancestral_rev(builder)
 
185
        mainline_revid = 'rev-1'
 
186
        # and make branch from it which is stacked (with no tags)
183
187
        try:
184
 
            new_dir = trunk_tree.bzrdir.sprout(self.get_url('newbranch'),
185
 
                stacked=True)
 
188
            new_dir = trunk.bzrdir.sprout(self.get_url('newbranch'), stacked=True)
186
189
        except unstackable_format_errors, e:
187
190
            raise TestNotApplicable(e)
188
191
        # stacked repository
189
 
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
 
192
        self.assertRevisionNotInRepository('newbranch', mainline_revid)
190
193
        # TODO: we'd like to commit in the stacked repository; that requires
191
194
        # some care (maybe a BranchBuilder) if it's remote and has no
192
195
        # workingtree
195
198
        # now when we unstack that should implicitly fetch, to make sure that
196
199
        # the branch will still work
197
200
        new_branch = new_dir.open_branch()
 
201
        try:
 
202
            new_branch.tags.set_tag('tag-a', 'rev-2')
 
203
        except errors.TagsNotSupported:
 
204
            tags_supported = False
 
205
        else:
 
206
            tags_supported = True
198
207
        new_branch.set_stacked_on_url(None)
199
 
        self.assertRevisionInRepository('newbranch', trunk_revid)
 
208
        self.assertRevisionInRepository('newbranch', mainline_revid)
200
209
        # of course it's still in the mainline
201
 
        self.assertRevisionInRepository('mainline', trunk_revid)
 
210
        self.assertRevisionInRepository('trunk', mainline_revid)
 
211
        if tags_supported:
 
212
            # the tagged revision in trunk is now in newbranch too
 
213
            self.assertRevisionInRepository('newbranch', 'rev-2')
202
214
        # and now we're no longer stacked
203
 
        self.assertRaises(errors.NotStacked,
204
 
            new_branch.get_stacked_on_url)
 
215
        self.assertRaises(errors.NotStacked, new_branch.get_stacked_on_url)
205
216
 
206
217
    def test_unstack_already_locked(self):
207
218
        """Removing the stacked-on branch with an already write-locked branch