/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Martin von Gagern
  • Date: 2010-04-20 08:47:38 UTC
  • mfrom: (5167 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5195.
  • Revision ID: martin.vgagern@gmx.net-20100420084738-ygymnqmdllzrhpfn
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Tests for Branch.get_stacked_on_url and set_stacked_on_url."""
18
18
 
19
19
from bzrlib import (
 
20
    branch,
20
21
    bzrdir,
 
22
    check,
21
23
    errors,
22
24
    )
23
25
from bzrlib.revision import NULL_REVISION
24
 
from bzrlib.tests import TestNotApplicable, KnownFailure
25
 
from bzrlib.tests.branch_implementations import TestCaseWithBranch
 
26
from bzrlib.smart import server
 
27
from bzrlib.tests import TestNotApplicable, KnownFailure, transport_util
 
28
from bzrlib.tests.per_branch import TestCaseWithBranch
 
29
from bzrlib.transport import get_transport
 
30
 
 
31
 
 
32
unstackable_format_errors = (
 
33
    errors.UnstackableBranchFormat,
 
34
    errors.UnstackableRepositoryFormat,
 
35
    )
26
36
 
27
37
 
28
38
class TestStacking(TestCaseWithBranch):
29
39
 
 
40
    def check_lines_added_or_present(self, stacked_branch, revid):
 
41
        # similar to a failure seen in bug 288751 by mbp 20081120
 
42
        stacked_repo = stacked_branch.repository
 
43
        stacked_repo.lock_read()
 
44
        try:
 
45
            list(stacked_repo.inventories.iter_lines_added_or_present_in_keys(
 
46
                    [(revid,)]))
 
47
        finally:
 
48
            stacked_repo.unlock()
 
49
 
30
50
    def test_get_set_stacked_on_url(self):
31
51
        # branches must either:
32
52
        # raise UnstackableBranchFormat or
34
54
        # permit stacking to be done and then return the stacked location.
35
55
        branch = self.make_branch('branch')
36
56
        target = self.make_branch('target')
37
 
        old_format_errors = (
38
 
            errors.UnstackableBranchFormat,
39
 
            errors.UnstackableRepositoryFormat,
40
 
            )
41
57
        try:
42
58
            branch.set_stacked_on_url(target.base)
43
 
        except old_format_errors:
 
59
        except unstackable_format_errors:
44
60
            # if the set failed, so must the get
45
 
            self.assertRaises(old_format_errors, branch.get_stacked_on_url)
 
61
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
 
62
            self.assertFalse(branch._format.supports_stacking())
46
63
            return
 
64
        self.assertTrue(branch._format.supports_stacking())
47
65
        # now we have a stacked branch:
48
66
        self.assertEqual(target.base, branch.get_stacked_on_url())
49
67
        branch.set_stacked_on_url(None)
53
71
        # Branches can be stacked on other branches using relative paths.
54
72
        branch = self.make_branch('branch')
55
73
        target = self.make_branch('target')
56
 
        old_format_errors = (
57
 
            errors.UnstackableBranchFormat,
58
 
            errors.UnstackableRepositoryFormat,
59
 
            )
60
 
        try:
61
 
            branch.set_stacked_on_url('../target')
62
 
        except old_format_errors:
63
 
            # if the set failed, so must the get
64
 
            self.assertRaises(old_format_errors, branch.get_stacked_on_url)
65
 
            return
 
74
        try:
 
75
            branch.set_stacked_on_url('../target')
 
76
        except unstackable_format_errors:
 
77
            # if the set failed, so must the get
 
78
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
 
79
            return
 
80
        self.assertEqual('../target', branch.get_stacked_on_url())
 
81
 
 
82
    def test_set_stacked_on_same_branch_raises(self):
 
83
        # Stacking on the same branch silently raises and doesn't execute the
 
84
        # change. Reported in bug 376243.
 
85
        branch = self.make_branch('branch')
 
86
        try:
 
87
            self.assertRaises(errors.UnstackableLocationError,
 
88
                branch.set_stacked_on_url, '../branch')
 
89
        except unstackable_format_errors:
 
90
            # if the set failed, so must the get
 
91
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
 
92
            return
 
93
        self.assertRaises(errors.NotStacked, branch.get_stacked_on_url)
 
94
 
 
95
    def test_set_stacked_on_same_branch_after_being_stacked_raises(self):
 
96
        # Stacking on the same branch silently raises and doesn't execute the
 
97
        # change.
 
98
        branch = self.make_branch('branch')
 
99
        target = self.make_branch('target')
 
100
        try:
 
101
            branch.set_stacked_on_url('../target')
 
102
        except unstackable_format_errors:
 
103
            # if the set failed, so must the get
 
104
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
 
105
            return
 
106
        self.assertRaises(errors.UnstackableLocationError,
 
107
            branch.set_stacked_on_url, '../branch')
66
108
        self.assertEqual('../target', branch.get_stacked_on_url())
67
109
 
68
110
    def assertRevisionInRepository(self, repo_path, revid):
85
127
        new_branch = self.make_branch('new_branch')
86
128
        try:
87
129
            new_branch.set_stacked_on_url(trunk_tree.branch.base)
88
 
        except (errors.UnstackableBranchFormat,
89
 
            errors.UnstackableRepositoryFormat), e:
 
130
        except unstackable_format_errors, e:
90
131
            raise TestNotApplicable(e)
91
132
        # reading the graph from the stacked branch's repository should see
92
133
        # data from the stacked-on branch
105
146
        # and make branch from it which is stacked
106
147
        try:
107
148
            new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
108
 
        except (errors.UnstackableBranchFormat,
109
 
            errors.UnstackableRepositoryFormat), e:
110
 
            raise TestNotApplicable(e)
111
 
        # stacked repository
112
 
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
113
 
        new_tree = new_dir.open_workingtree()
114
 
        new_branch_revid = new_tree.commit('something local')
 
149
        except unstackable_format_errors, e:
 
150
            raise TestNotApplicable(e)
 
151
        # stacked repository
 
152
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
 
153
        tree = new_dir.open_branch().create_checkout('local')
 
154
        new_branch_revid = tree.commit('something local')
 
155
        self.assertRevisionNotInRepository('mainline', new_branch_revid)
 
156
        self.assertRevisionInRepository('newbranch', new_branch_revid)
 
157
 
 
158
    def test_sprout_stacked_from_smart_server(self):
 
159
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
160
            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
 
161
        # We have a mainline
 
162
        trunk_tree = self.make_branch_and_tree('mainline')
 
163
        trunk_revid = trunk_tree.commit('mainline')
 
164
        # Make sure that we can make a stacked branch from it
 
165
        try:
 
166
            trunk_tree.bzrdir.sprout('testbranch', stacked=True)
 
167
        except unstackable_format_errors, e:
 
168
            raise TestNotApplicable(e)
 
169
        # Now serve the original mainline from a smart server
 
170
        remote_transport = self.make_smart_server('mainline')
 
171
        remote_bzrdir = bzrdir.BzrDir.open_from_transport(remote_transport)
 
172
        # and make branch from the smart server which is stacked
 
173
        new_dir = remote_bzrdir.sprout('newbranch', stacked=True)
 
174
        # stacked repository
 
175
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
 
176
        tree = new_dir.open_branch().create_checkout('local')
 
177
        new_branch_revid = tree.commit('something local')
115
178
        self.assertRevisionNotInRepository('mainline', new_branch_revid)
116
179
        self.assertRevisionInRepository('newbranch', new_branch_revid)
117
180
 
122
185
        trunk_revid = trunk_tree.commit('revision on mainline')
123
186
        # and make branch from it which is stacked
124
187
        try:
125
 
            new_dir = trunk_tree.bzrdir.sprout('newbranch', stacked=True)
126
 
        except (errors.UnstackableBranchFormat,
127
 
            errors.UnstackableRepositoryFormat), e:
 
188
            new_dir = trunk_tree.bzrdir.sprout(self.get_url('newbranch'),
 
189
                stacked=True)
 
190
        except unstackable_format_errors, e:
128
191
            raise TestNotApplicable(e)
129
192
        # stacked repository
130
193
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
 
194
        # TODO: we'd like to commit in the stacked repository; that requires
 
195
        # some care (maybe a BranchBuilder) if it's remote and has no
 
196
        # workingtree
 
197
        ##newbranch_revid = new_dir.open_workingtree().commit('revision in '
 
198
            ##'newbranch')
131
199
        # now when we unstack that should implicitly fetch, to make sure that
132
200
        # the branch will still work
133
201
        new_branch = new_dir.open_branch()
163
231
        # same branch as the original.
164
232
        try:
165
233
            stacked_bzrdir = self.make_stacked_bzrdir()
166
 
        except (errors.UnstackableBranchFormat,
167
 
                errors.UnstackableRepositoryFormat), e:
168
 
            # not a testable combination.
 
234
        except unstackable_format_errors, e:
169
235
            raise TestNotApplicable(e)
170
236
        cloned_bzrdir = stacked_bzrdir.clone('cloned', preserve_stacking=True)
171
237
        try:
172
238
            self.assertEqual(
173
239
                stacked_bzrdir.open_branch().get_stacked_on_url(),
174
240
                cloned_bzrdir.open_branch().get_stacked_on_url())
175
 
        except (errors.UnstackableBranchFormat,
176
 
                errors.UnstackableRepositoryFormat):
 
241
        except unstackable_format_errors, e:
177
242
            pass
178
243
 
179
244
    def test_clone_from_branch_stacked_on_relative_url_preserve_stacking(self):
182
247
        # on an appropriately adjusted relative url.
183
248
        try:
184
249
            stacked_bzrdir = self.make_stacked_bzrdir(in_directory='dir')
185
 
        except (errors.UnstackableBranchFormat,
186
 
                errors.UnstackableRepositoryFormat), e:
187
 
            # not a testable combination.
 
250
        except unstackable_format_errors, e:
188
251
            raise TestNotApplicable(e)
189
252
        stacked_bzrdir.open_branch().set_stacked_on_url('../stacked-on')
190
253
        cloned_bzrdir = stacked_bzrdir.clone('cloned', preserve_stacking=True)
195
258
    def test_clone_from_stacked_branch_no_preserve_stacking(self):
196
259
        try:
197
260
            stacked_bzrdir = self.make_stacked_bzrdir()
198
 
        except (errors.UnstackableBranchFormat,
199
 
                errors.UnstackableRepositoryFormat), e:
 
261
        except unstackable_format_errors, e:
200
262
            # not a testable combination.
201
263
            raise TestNotApplicable(e)
202
264
        cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked',
212
274
        self.assertRaises((errors.NotStacked, errors.UnstackableBranchFormat),
213
275
                          cloned_bzrdir.open_branch().get_stacked_on_url)
214
276
 
 
277
    def make_stacked_on_matching(self, source):
 
278
        if source.repository.supports_rich_root():
 
279
            if source.repository._format.supports_chks:
 
280
                format = "2a"
 
281
            else:
 
282
                format = "1.9-rich-root"
 
283
        else:
 
284
            format = "1.9"
 
285
        return self.make_branch('stack-on', format)
 
286
 
215
287
    def test_sprout_stacking_policy_handling(self):
216
288
        """Obey policy where possible, ignore otherwise."""
217
 
        stack_on = self.make_branch('stack-on')
 
289
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
290
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
 
291
        source = self.make_branch('source')
 
292
        stack_on = self.make_stacked_on_matching(source)
218
293
        parent_bzrdir = self.make_bzrdir('.', format='default')
219
294
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
220
 
        source = self.make_branch('source')
221
295
        target = source.bzrdir.sprout('target').open_branch()
222
 
        try:
 
296
        # When we sprout we upgrade the branch when there is a default stack_on
 
297
        # set by a config *and* the targeted branch supports stacking.
 
298
        if stack_on._format.supports_stacking():
223
299
            self.assertEqual('../stack-on', target.get_stacked_on_url())
224
 
        except errors.UnstackableBranchFormat:
225
 
            pass
 
300
        else:
 
301
            self.assertRaises(
 
302
                errors.UnstackableBranchFormat, target.get_stacked_on_url)
226
303
 
227
304
    def test_clone_stacking_policy_handling(self):
228
305
        """Obey policy where possible, ignore otherwise."""
229
 
        stack_on = self.make_branch('stack-on')
 
306
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
307
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
 
308
        source = self.make_branch('source')
 
309
        stack_on = self.make_stacked_on_matching(source)
230
310
        parent_bzrdir = self.make_bzrdir('.', format='default')
231
311
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
232
 
        source = self.make_branch('source')
233
312
        target = source.bzrdir.clone('target').open_branch()
234
 
        try:
235
 
            self.assertEqual('../stack-on', target.get_stacked_on_url())
236
 
        except errors.UnstackableBranchFormat:
237
 
            pass
 
313
        # When we clone we upgrade the branch when there is a default stack_on
 
314
        # set by a config *and* the targeted branch supports stacking.
 
315
        if stack_on._format.supports_stacking():
 
316
            self.assertEqual('../stack-on', target.get_stacked_on_url())
 
317
        else:
 
318
            self.assertRaises(
 
319
                errors.UnstackableBranchFormat, target.get_stacked_on_url)
 
320
 
 
321
    def test_sprout_to_smart_server_stacking_policy_handling(self):
 
322
        """Obey policy where possible, ignore otherwise."""
 
323
        if isinstance(self.branch_format, branch.BzrBranchFormat4):
 
324
            raise TestNotApplicable('Branch format 4 is not usable via HPSS.')
 
325
        source = self.make_branch('source')
 
326
        stack_on = self.make_stacked_on_matching(source)
 
327
        parent_bzrdir = self.make_bzrdir('.', format='default')
 
328
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
 
329
        url = self.make_smart_server('target').base
 
330
        target = source.bzrdir.sprout(url).open_branch()
 
331
        # When we sprout we upgrade the branch when there is a default stack_on
 
332
        # set by a config *and* the targeted branch supports stacking.
 
333
        if stack_on._format.supports_stacking():
 
334
            self.assertEqual('../stack-on', target.get_stacked_on_url())
 
335
        else:
 
336
            self.assertRaises(
 
337
                errors.UnstackableBranchFormat, target.get_stacked_on_url)
238
338
 
239
339
    def prepare_stacked_on_fetch(self):
240
340
        stack_on = self.make_branch_and_tree('stack-on')
241
341
        stack_on.commit('first commit', rev_id='rev1')
242
342
        try:
243
343
            stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
244
 
        except (errors.UnstackableRepositoryFormat,
245
 
                errors.UnstackableBranchFormat):
 
344
        except unstackable_format_errors, e:
246
345
            raise TestNotApplicable('Format does not support stacking.')
247
346
        unstacked = self.make_repository('unstacked')
248
347
        return stacked_dir.open_workingtree(), unstacked
254
353
 
255
354
    def test_fetch_copies_from_stacked_on_and_stacked(self):
256
355
        stacked, unstacked = self.prepare_stacked_on_fetch()
257
 
        stacked.commit('second commit', rev_id='rev2')
 
356
        tree = stacked.branch.create_checkout('local')
 
357
        tree.commit('second commit', rev_id='rev2')
258
358
        unstacked.fetch(stacked.branch.repository, 'rev2')
259
359
        unstacked.get_revision('rev1')
260
360
        unstacked.get_revision('rev2')
 
361
        self.check_lines_added_or_present(stacked.branch, 'rev1')
 
362
        self.check_lines_added_or_present(stacked.branch, 'rev2')
261
363
 
262
364
    def test_autopack_when_stacked(self):
263
365
        # in bzr.dev as of 20080730, autopack was reported to fail in stacked
265
367
        # repository boundaries.  however, i didn't actually get this test to
266
368
        # fail on that code. -- mbp
267
369
        # see https://bugs.launchpad.net/bzr/+bug/252821
268
 
        if not self.branch_format.supports_stacking():
 
370
        stack_on = self.make_branch_and_tree('stack-on')
 
371
        if not stack_on.branch._format.supports_stacking():
269
372
            raise TestNotApplicable("%r does not support stacking"
270
373
                % self.branch_format)
271
 
        stack_on = self.make_branch_and_tree('stack-on')
272
374
        text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
273
375
        self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
274
376
        stack_on.add('a')
275
377
        stack_on.commit('base commit')
276
378
        stacked_dir = stack_on.bzrdir.sprout('stacked', stacked=True)
277
 
        stacked_tree = stacked_dir.open_workingtree()
 
379
        stacked_branch = stacked_dir.open_branch()
 
380
        local_tree = stack_on.bzrdir.sprout('local').open_workingtree()
278
381
        for i in range(20):
279
382
            text_lines[0] = 'changed in %d\n' % i
280
 
            self.build_tree_contents([('stacked/a', ''.join(text_lines))])
281
 
            stacked_tree.commit('commit %d' % i)
282
 
        stacked_tree.branch.repository.pack()
283
 
        stacked_tree.branch.check()
 
383
            self.build_tree_contents([('local/a', ''.join(text_lines))])
 
384
            local_tree.commit('commit %d' % i)
 
385
            local_tree.branch.push(stacked_branch)
 
386
        stacked_branch.repository.pack()
 
387
        check.check_dwim(stacked_branch.base, False, True, True)
284
388
 
285
389
    def test_pull_delta_when_stacked(self):
286
390
        if not self.branch_format.supports_stacking():
299
403
        other_tree = other_dir.open_workingtree()
300
404
        text_lines[9] = 'changed in other\n'
301
405
        self.build_tree_contents([('other/a', ''.join(text_lines))])
302
 
        other_tree.commit('commit in other')
 
406
        stacked_revid = other_tree.commit('commit in other')
303
407
        # this should have generated a delta; try to pull that across
304
408
        # bug 252821 caused a RevisionNotPresent here...
305
409
        stacked_tree.pull(other_tree.branch)
306
410
        stacked_tree.branch.repository.pack()
307
 
        stacked_tree.branch.check()
 
411
        check.check_dwim(stacked_tree.branch.base, False, True, True)
 
412
        self.check_lines_added_or_present(stacked_tree.branch, stacked_revid)
308
413
 
309
414
    def test_fetch_revisions_with_file_changes(self):
310
415
        # Fetching revisions including file changes into a stacked branch
322
427
        target = self.make_branch('target')
323
428
        try:
324
429
            target.set_stacked_on_url('../stacked-on')
325
 
        except (errors.UnstackableRepositoryFormat,
326
 
                errors.UnstackableBranchFormat):
 
430
        except unstackable_format_errors, e:
327
431
            raise TestNotApplicable('Format does not support stacking.')
328
432
 
329
433
        # Change the source branch.
336
440
        rtree.lock_read()
337
441
        self.addCleanup(rtree.unlock)
338
442
        self.assertEqual('new content', rtree.get_file_by_path('a').read())
 
443
        self.check_lines_added_or_present(target, 'rev2')
 
444
 
 
445
    def test_transform_fallback_location_hook(self):
 
446
        # The 'transform_fallback_location' branch hook allows us to inspect
 
447
        # and transform the URL of the fallback location for the branch.
 
448
        stack_on = self.make_branch('stack-on')
 
449
        stacked = self.make_branch('stacked')
 
450
        try:
 
451
            stacked.set_stacked_on_url('../stack-on')
 
452
        except unstackable_format_errors, e:
 
453
            raise TestNotApplicable('Format does not support stacking.')
 
454
        self.get_transport().rename('stack-on', 'new-stack-on')
 
455
        hook_calls = []
 
456
        def hook(stacked_branch, url):
 
457
            hook_calls.append(url)
 
458
            return '../new-stack-on'
 
459
        branch.Branch.hooks.install_named_hook(
 
460
            'transform_fallback_location', hook, None)
 
461
        branch.Branch.open('stacked')
 
462
        self.assertEqual(['../stack-on'], hook_calls)
 
463
 
 
464
    def test_stack_on_repository_branch(self):
 
465
        # Stacking should work when the repo isn't co-located with the
 
466
        # stack-on branch.
 
467
        try:
 
468
            repo = self.make_repository('repo', shared=True)
 
469
        except errors.IncompatibleFormat:
 
470
            raise TestNotApplicable()
 
471
        # Avoid make_branch, which produces standalone branches.
 
472
        bzrdir = self.make_bzrdir('repo/stack-on')
 
473
        try:
 
474
            b = bzrdir.create_branch()
 
475
        except errors.UninitializableFormat:
 
476
            raise TestNotApplicable()
 
477
        transport = self.get_transport('stacked')
 
478
        b.bzrdir.clone_on_transport(transport, stacked_on=b.base)
 
479
        # Ensure that opening the branch doesn't raise.
 
480
        branch.Branch.open(transport.base)
 
481
 
 
482
    def test_revision_history_of_stacked(self):
 
483
        # See <https://launchpad.net/bugs/380314>.
 
484
        stack_on = self.make_branch_and_tree('stack-on')
 
485
        stack_on.commit('first commit', rev_id='rev1')
 
486
        try:
 
487
            stacked_dir = stack_on.bzrdir.sprout(
 
488
                self.get_url('stacked'), stacked=True)
 
489
        except unstackable_format_errors, e:
 
490
            raise TestNotApplicable('Format does not support stacking.')
 
491
        try:
 
492
            stacked = stacked_dir.open_workingtree()
 
493
        except errors.NoWorkingTree:
 
494
            stacked = stacked_dir.open_branch().create_checkout(
 
495
                'stacked-checkout', lightweight=True)
 
496
        tree = stacked.branch.create_checkout('local')
 
497
        tree.commit('second commit', rev_id='rev2')
 
498
        # Sanity check: stacked's repo should not contain rev1, otherwise this
 
499
        # test isn't testing what it's supposed to.
 
500
        repo = stacked.branch.repository.bzrdir.open_repository()
 
501
        repo.lock_read()
 
502
        self.addCleanup(repo.unlock)
 
503
        self.assertEqual({}, repo.get_parent_map(['rev1']))
 
504
        # revision_history should work, even though the history is spread over
 
505
        # multiple repositories.
 
506
        self.assertLength(2, stacked.branch.revision_history())
 
507
 
 
508
 
 
509
class TestStackingConnections(
 
510
    transport_util.TestCaseWithConnectionHookedTransport):
 
511
 
 
512
    def setUp(self):
 
513
        super(TestStackingConnections, self).setUp()
 
514
        try:
 
515
            base_tree = self.make_branch_and_tree('base',
 
516
                                                  format=self.bzrdir_format)
 
517
        except errors.UninitializableFormat, e:
 
518
            raise TestNotApplicable(e)
 
519
        stacked = self.make_branch('stacked', format=self.bzrdir_format)
 
520
        try:
 
521
            stacked.set_stacked_on_url(base_tree.branch.base)
 
522
        except unstackable_format_errors, e:
 
523
            raise TestNotApplicable(e)
 
524
        base_tree.commit('first', rev_id='rev-base')
 
525
        stacked.set_last_revision_info(1, 'rev-base')
 
526
        stacked_relative = self.make_branch('stacked_relative',
 
527
                                            format=self.bzrdir_format)
 
528
        stacked_relative.set_stacked_on_url('../base')
 
529
        stacked.set_last_revision_info(1, 'rev-base')
 
530
        self.start_logging_connections()
 
531
 
 
532
    def test_open_stacked(self):
 
533
        b = branch.Branch.open(self.get_url('stacked'))
 
534
        rev = b.repository.get_revision('rev-base')
 
535
        self.assertEqual(1, len(self.connections))
 
536
 
 
537
    def test_open_stacked_relative(self):
 
538
        b = branch.Branch.open(self.get_url('stacked_relative'))
 
539
        rev = b.repository.get_revision('rev-base')
 
540
        self.assertEqual(1, len(self.connections))