/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Tests for Branch.get_stacked_on_url and set_stacked_on_url."""
18
18
 
19
 
from bzrlib import (
 
19
from breezy import (
20
20
    branch,
21
21
    controldir,
22
22
    check,
23
23
    errors,
24
24
    )
25
 
from bzrlib.revision import NULL_REVISION
26
 
from bzrlib.tests import fixtures, TestNotApplicable, transport_util
27
 
from bzrlib.tests.per_branch import TestCaseWithBranch
 
25
from breezy.revision import NULL_REVISION
 
26
from breezy.tests import fixtures, TestNotApplicable, transport_util
 
27
from breezy.tests.per_branch import TestCaseWithBranch
28
28
 
29
29
 
30
30
unstackable_format_errors = (
125
125
        new_branch = self.make_branch('new_branch')
126
126
        try:
127
127
            new_branch.set_stacked_on_url(trunk_tree.branch.base)
128
 
        except unstackable_format_errors, e:
 
128
        except unstackable_format_errors as e:
129
129
            raise TestNotApplicable(e)
130
130
        # reading the graph from the stacked branch's repository should see
131
131
        # data from the stacked-on branch
144
144
        # and make branch from it which is stacked
145
145
        try:
146
146
            new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
147
 
        except unstackable_format_errors, e:
 
147
        except unstackable_format_errors as e:
148
148
            raise TestNotApplicable(e)
149
149
        # stacked repository
150
150
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
161
161
        # Make sure that we can make a stacked branch from it
162
162
        try:
163
163
            trunk_tree.bzrdir.sprout('testbranch', stacked=True)
164
 
        except unstackable_format_errors, e:
 
164
        except unstackable_format_errors as e:
165
165
            raise TestNotApplicable(e)
166
166
        # Now serve the original mainline from a smart server
167
167
        remote_transport = self.make_smart_server('mainline')
188
188
        # and make branch from it which is stacked (with no tags)
189
189
        try:
190
190
            new_dir = trunk.bzrdir.sprout(self.get_url('newbranch'), stacked=True)
191
 
        except unstackable_format_errors, e:
 
191
        except unstackable_format_errors as e:
192
192
            raise TestNotApplicable(e)
193
193
        # stacked repository
194
194
        self.assertRevisionNotInRepository('newbranch', mainline_revid)
224
224
        """
225
225
        try:
226
226
            stacked_bzrdir = self.make_stacked_bzrdir()
227
 
        except unstackable_format_errors, e:
 
227
        except unstackable_format_errors as e:
228
228
            raise TestNotApplicable(e)
229
229
        stacked_branch = stacked_bzrdir.open_branch()
230
230
        stacked_branch.lock_write()
239
239
        """
240
240
        try:
241
241
            stacked_bzrdir = self.make_stacked_bzrdir()
242
 
        except unstackable_format_errors, e:
 
242
        except unstackable_format_errors as e:
243
243
            raise TestNotApplicable(e)
244
244
        stacked_branch = stacked_bzrdir.open_branch()
245
245
        stacked_branch.lock_write()
275
275
        # same branch as the original.
276
276
        try:
277
277
            stacked_bzrdir = self.make_stacked_bzrdir()
278
 
        except unstackable_format_errors, e:
 
278
        except unstackable_format_errors as e:
279
279
            raise TestNotApplicable(e)
280
280
        cloned_bzrdir = stacked_bzrdir.clone('cloned', preserve_stacking=True)
281
281
        try:
282
282
            self.assertEqual(
283
283
                stacked_bzrdir.open_branch().get_stacked_on_url(),
284
284
                cloned_bzrdir.open_branch().get_stacked_on_url())
285
 
        except unstackable_format_errors, e:
 
285
        except unstackable_format_errors as e:
286
286
            pass
287
287
 
288
288
    def test_clone_from_branch_stacked_on_relative_url_preserve_stacking(self):
291
291
        # on an appropriately adjusted relative url.
292
292
        try:
293
293
            stacked_bzrdir = self.make_stacked_bzrdir(in_directory='dir')
294
 
        except unstackable_format_errors, e:
 
294
        except unstackable_format_errors as e:
295
295
            raise TestNotApplicable(e)
296
296
        stacked_bzrdir.open_branch().set_stacked_on_url('../stacked-on')
297
297
        cloned_bzrdir = stacked_bzrdir.clone(
303
303
    def test_clone_from_stacked_branch_no_preserve_stacking(self):
304
304
        try:
305
305
            stacked_bzrdir = self.make_stacked_bzrdir()
306
 
        except unstackable_format_errors, e:
 
306
        except unstackable_format_errors as e:
307
307
            # not a testable combination.
308
308
            raise TestNotApplicable(e)
309
309
        cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked',
386
386
        stack_on.commit('first commit', rev_id='rev1')
387
387
        try:
388
388
            stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
389
 
        except unstackable_format_errors, e:
 
389
        except unstackable_format_errors as e:
390
390
            raise TestNotApplicable('Format does not support stacking.')
391
391
        unstacked = self.make_repository('unstacked')
392
392
        return stacked_dir.open_workingtree(), unstacked
472
472
        target = self.make_branch('target')
473
473
        try:
474
474
            target.set_stacked_on_url('../stacked-on')
475
 
        except unstackable_format_errors, e:
 
475
        except unstackable_format_errors as e:
476
476
            raise TestNotApplicable('Format does not support stacking.')
477
477
 
478
478
        # Change the source branch.
496
496
        stacked = self.make_branch('stacked')
497
497
        try:
498
498
            stacked.set_stacked_on_url('../stack-on')
499
 
        except unstackable_format_errors, e:
 
499
        except unstackable_format_errors as e:
500
500
            raise TestNotApplicable('Format does not support stacking.')
501
501
        self.get_transport().rename('stack-on', 'new-stack-on')
502
502
        hook_calls = []
535
535
        try:
536
536
            stacked_dir = stack_on.bzrdir.sprout(
537
537
                self.get_url('stacked'), stacked=True)
538
 
        except unstackable_format_errors, e:
 
538
        except unstackable_format_errors as e:
539
539
            raise TestNotApplicable('Format does not support stacking.')
540
540
        try:
541
541
            stacked = stacked_dir.open_workingtree()
563
563
        try:
564
564
            base_tree = self.make_branch_and_tree('base',
565
565
                                                  format=self.bzrdir_format)
566
 
        except errors.UninitializableFormat, e:
 
566
        except errors.UninitializableFormat as e:
567
567
            raise TestNotApplicable(e)
568
568
        stacked = self.make_branch('stacked', format=self.bzrdir_format)
569
569
        try:
570
570
            stacked.set_stacked_on_url(base_tree.branch.base)
571
 
        except unstackable_format_errors, e:
 
571
        except unstackable_format_errors as e:
572
572
            raise TestNotApplicable(e)
573
573
        base_tree.commit('first', rev_id='rev-base')
574
574
        stacked.set_last_revision_info(1, 'rev-base')