~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

merge trunk

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
 
154
154
        self.assertRevisionInRepository('newbranch', new_branch_revid)
155
155
 
156
156
    def test_sprout_stacked_from_smart_server(self):
157
 
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
158
 
            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
159
157
        # We have a mainline
160
158
        trunk_tree = self.make_branch_and_tree('mainline')
161
159
        trunk_revid = trunk_tree.commit('mainline')
178
176
 
179
177
    def test_unstack_fetches(self):
180
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')
181
183
        # We have a mainline
182
 
        trunk_tree = self.make_branch_and_tree('mainline')
183
 
        trunk_revid = trunk_tree.commit('revision on mainline')
184
 
        # 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)
185
187
        try:
186
 
            new_dir = trunk_tree.bzrdir.sprout(self.get_url('newbranch'),
187
 
                stacked=True)
 
188
            new_dir = trunk.bzrdir.sprout(self.get_url('newbranch'), stacked=True)
188
189
        except unstackable_format_errors, e:
189
190
            raise TestNotApplicable(e)
190
191
        # stacked repository
191
 
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
 
192
        self.assertRevisionNotInRepository('newbranch', mainline_revid)
192
193
        # TODO: we'd like to commit in the stacked repository; that requires
193
194
        # some care (maybe a BranchBuilder) if it's remote and has no
194
195
        # workingtree
197
198
        # now when we unstack that should implicitly fetch, to make sure that
198
199
        # the branch will still work
199
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
200
207
        new_branch.set_stacked_on_url(None)
201
 
        self.assertRevisionInRepository('newbranch', trunk_revid)
 
208
        self.assertRevisionInRepository('newbranch', mainline_revid)
202
209
        # of course it's still in the mainline
203
 
        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')
204
214
        # and now we're no longer stacked
205
 
        self.assertRaises(errors.NotStacked,
206
 
            new_branch.get_stacked_on_url)
 
215
        self.assertRaises(errors.NotStacked, new_branch.get_stacked_on_url)
207
216
 
208
217
    def test_unstack_already_locked(self):
209
218
        """Removing the stacked-on branch with an already write-locked branch
320
329
 
321
330
    def test_sprout_stacking_policy_handling(self):
322
331
        """Obey policy where possible, ignore otherwise."""
323
 
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
332
        if self.bzrdir_format.fixed_components:
324
333
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
325
334
        source = self.make_branch('source')
326
335
        stack_on = self.make_stacked_on_matching(source)
337
346
 
338
347
    def test_clone_stacking_policy_handling(self):
339
348
        """Obey policy where possible, ignore otherwise."""
340
 
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
349
        if self.bzrdir_format.fixed_components:
341
350
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
342
351
        source = self.make_branch('source')
343
352
        stack_on = self.make_stacked_on_matching(source)
354
363
 
355
364
    def test_sprout_to_smart_server_stacking_policy_handling(self):
356
365
        """Obey policy where possible, ignore otherwise."""
357
 
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
358
 
            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
 
366
        if not self.branch_format.supports_leaving_lock():
 
367
            raise TestNotApplicable('Branch format is not usable via HPSS.')
359
368
        source = self.make_branch('source')
360
369
        stack_on = self.make_stacked_on_matching(source)
361
370
        parent_bzrdir = self.make_bzrdir('.', format='default')