~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ 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
 
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
318
329
 
319
330
    def test_sprout_stacking_policy_handling(self):
320
331
        """Obey policy where possible, ignore otherwise."""
321
 
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
332
        if self.bzrdir_format.fixed_components:
322
333
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
323
334
        source = self.make_branch('source')
324
335
        stack_on = self.make_stacked_on_matching(source)
335
346
 
336
347
    def test_clone_stacking_policy_handling(self):
337
348
        """Obey policy where possible, ignore otherwise."""
338
 
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
349
        if self.bzrdir_format.fixed_components:
339
350
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
340
351
        source = self.make_branch('source')
341
352
        stack_on = self.make_stacked_on_matching(source)
352
363
 
353
364
    def test_sprout_to_smart_server_stacking_policy_handling(self):
354
365
        """Obey policy where possible, ignore otherwise."""
355
 
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
356
 
            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.')
357
368
        source = self.make_branch('source')
358
369
        stack_on = self.make_stacked_on_matching(source)
359
370
        parent_bzrdir = self.make_bzrdir('.', format='default')