/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2008-2012, 2016 Canonical Ltd
3221.11.3 by Robert Collins
Add missing test script.
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
4183.7.1 by Sabin Iacob
update FSF mailing address
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
3221.11.3 by Robert Collins
Add missing test script.
16
3537.3.3 by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url
17
"""Tests for Branch.get_stacked_on_url and set_stacked_on_url."""
3221.11.3 by Robert Collins
Add missing test script.
18
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
19
from breezy import (
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
20
    branch as _mod_branch,
6472.2.2 by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places.
21
    controldir,
4332.3.35 by Robert Collins
Fix failing tests.
22
    check,
3517.4.12 by Martin Pool
Clearer per-branch-format tests for stacking
23
    errors,
24
    )
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
25
from breezy.revision import NULL_REVISION
26
from breezy.tests import fixtures, TestNotApplicable, transport_util
27
from breezy.tests.per_branch import TestCaseWithBranch
3221.11.3 by Robert Collins
Add missing test script.
28
29
3928.3.3 by John Arbash Meinel
Change the name of 'old_format_errors' to 'unstackable_format_errors'
30
unstackable_format_errors = (
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
31
    _mod_branch.UnstackableBranchFormat,
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
32
    errors.UnstackableRepositoryFormat,
33
    )
34
35
3221.11.3 by Robert Collins
Add missing test script.
36
class TestStacking(TestCaseWithBranch):
37
3830.3.16 by Martin Pool
Add passing tests for iter_lines_added_or_present in stacked repos
38
    def check_lines_added_or_present(self, stacked_branch, revid):
39
        # similar to a failure seen in bug 288751 by mbp 20081120
40
        stacked_repo = stacked_branch.repository
41
        stacked_repo.lock_read()
42
        try:
43
            list(stacked_repo.inventories.iter_lines_added_or_present_in_keys(
44
                    [(revid,)]))
45
        finally:
46
            stacked_repo.unlock()
47
3537.3.3 by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url
48
    def test_get_set_stacked_on_url(self):
3221.11.3 by Robert Collins
Add missing test script.
49
        # branches must either:
50
        # raise UnstackableBranchFormat or
51
        # raise UnstackableRepositoryFormat or
52
        # permit stacking to be done and then return the stacked location.
53
        branch = self.make_branch('branch')
54
        target = self.make_branch('target')
55
        try:
3537.3.3 by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url
56
            branch.set_stacked_on_url(target.base)
3928.3.3 by John Arbash Meinel
Change the name of 'old_format_errors' to 'unstackable_format_errors'
57
        except unstackable_format_errors:
3221.11.3 by Robert Collins
Add missing test script.
58
            # if the set failed, so must the get
3928.3.3 by John Arbash Meinel
Change the name of 'old_format_errors' to 'unstackable_format_errors'
59
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
4103.2.3 by Andrew Bennetts
Other tests for good luck.
60
            self.assertFalse(branch._format.supports_stacking())
3221.11.3 by Robert Collins
Add missing test script.
61
            return
4103.2.3 by Andrew Bennetts
Other tests for good luck.
62
        self.assertTrue(branch._format.supports_stacking())
3221.11.3 by Robert Collins
Add missing test script.
63
        # now we have a stacked branch:
3537.3.1 by Martin Pool
Rename branch.get_stacked_on to get_stacked_on_url
64
        self.assertEqual(target.base, branch.get_stacked_on_url())
3537.3.3 by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url
65
        branch.set_stacked_on_url(None)
3537.3.1 by Martin Pool
Rename branch.get_stacked_on to get_stacked_on_url
66
        self.assertRaises(errors.NotStacked, branch.get_stacked_on_url)
3221.13.2 by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery.
67
3242.5.1 by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs.
68
    def test_get_set_stacked_on_relative(self):
69
        # Branches can be stacked on other branches using relative paths.
70
        branch = self.make_branch('branch')
71
        target = self.make_branch('target')
72
        try:
3537.3.5 by Martin Pool
merge trunk including stacking policy
73
            branch.set_stacked_on_url('../target')
3928.3.3 by John Arbash Meinel
Change the name of 'old_format_errors' to 'unstackable_format_errors'
74
        except unstackable_format_errors:
3242.5.1 by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs.
75
            # if the set failed, so must the get
3928.3.3 by John Arbash Meinel
Change the name of 'old_format_errors' to 'unstackable_format_errors'
76
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
3242.5.1 by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs.
77
            return
3537.3.5 by Martin Pool
merge trunk including stacking policy
78
        self.assertEqual('../target', branch.get_stacked_on_url())
3242.5.1 by Jonathan Lange
Allow stacked-on branch locations to be stored as relative URLs.
79
4462.3.2 by Robert Collins
Do not stack on the same branch/repository anymore. This was never supported and would generally result in infinite recursion. Fixes bug 376243.
80
    def test_set_stacked_on_same_branch_raises(self):
81
        # Stacking on the same branch silently raises and doesn't execute the
82
        # change. Reported in bug 376243.
83
        branch = self.make_branch('branch')
84
        try:
85
            self.assertRaises(errors.UnstackableLocationError,
86
                branch.set_stacked_on_url, '../branch')
87
        except unstackable_format_errors:
88
            # if the set failed, so must the get
89
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
90
            return
91
        self.assertRaises(errors.NotStacked, branch.get_stacked_on_url)
92
93
    def test_set_stacked_on_same_branch_after_being_stacked_raises(self):
94
        # Stacking on the same branch silently raises and doesn't execute the
95
        # change.
96
        branch = self.make_branch('branch')
97
        target = self.make_branch('target')
98
        try:
99
            branch.set_stacked_on_url('../target')
100
        except unstackable_format_errors:
101
            # if the set failed, so must the get
102
            self.assertRaises(unstackable_format_errors, branch.get_stacked_on_url)
103
            return
104
        self.assertRaises(errors.UnstackableLocationError,
105
            branch.set_stacked_on_url, '../branch')
106
        self.assertEqual('../target', branch.get_stacked_on_url())
107
3517.4.12 by Martin Pool
Clearer per-branch-format tests for stacking
108
    def assertRevisionInRepository(self, repo_path, revid):
109
        """Check that a revision is in a repository, disregarding stacking."""
6472.2.2 by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places.
110
        repo = controldir.ControlDir.open(repo_path).open_repository()
3517.4.12 by Martin Pool
Clearer per-branch-format tests for stacking
111
        self.assertTrue(repo.has_revision(revid))
112
113
    def assertRevisionNotInRepository(self, repo_path, revid):
114
        """Check that a revision is not in a repository, disregarding stacking."""
6472.2.2 by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places.
115
        repo = controldir.ControlDir.open(repo_path).open_repository()
3517.4.12 by Martin Pool
Clearer per-branch-format tests for stacking
116
        self.assertFalse(repo.has_revision(revid))
117
118
    def test_get_graph_stacked(self):
119
        """A stacked repository shows the graph of its parent."""
120
        trunk_tree = self.make_branch_and_tree('mainline')
121
        trunk_revid = trunk_tree.commit('mainline')
122
        # make a new branch, and stack on the existing one.  we don't use
123
        # sprout(stacked=True) here because if that is buggy and copies data
124
        # it would cause a false pass of this test.
125
        new_branch = self.make_branch('new_branch')
126
        try:
3537.3.3 by Martin Pool
Rename Branch.set_stacked_on to set_stacked_on_url
127
            new_branch.set_stacked_on_url(trunk_tree.branch.base)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
128
        except unstackable_format_errors as e:
3517.4.12 by Martin Pool
Clearer per-branch-format tests for stacking
129
            raise TestNotApplicable(e)
130
        # reading the graph from the stacked branch's repository should see
131
        # data from the stacked-on branch
132
        new_repo = new_branch.repository
133
        new_repo.lock_read()
134
        try:
135
            self.assertEqual(new_repo.get_parent_map([trunk_revid]),
136
                {trunk_revid: (NULL_REVISION, )})
137
        finally:
138
            new_repo.unlock()
139
140
    def test_sprout_stacked(self):
3221.13.2 by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery.
141
        # We have a mainline
142
        trunk_tree = self.make_branch_and_tree('mainline')
143
        trunk_revid = trunk_tree.commit('mainline')
3221.18.4 by Ian Clatworthy
shallow -> stacked
144
        # and make branch from it which is stacked
3221.13.2 by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery.
145
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
146
            new_dir = trunk_tree.controldir.sprout('newbranch', stacked=True)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
147
        except unstackable_format_errors as e:
3517.4.12 by Martin Pool
Clearer per-branch-format tests for stacking
148
            raise TestNotApplicable(e)
149
        # stacked repository
150
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
151
        tree = new_dir.open_branch().create_checkout('local')
152
        new_branch_revid = tree.commit('something local')
6182.1.5 by Jelmer Vernooij
Fix more tests.
153
        self.assertRevisionNotInRepository(
154
            trunk_tree.branch.base, new_branch_revid)
3537.3.4 by Martin Pool
Improved branch stacking tests
155
        self.assertRevisionInRepository('newbranch', new_branch_revid)
156
3793.1.2 by Andrew Bennetts
Add test showing that stacking from the smart server works.
157
    def test_sprout_stacked_from_smart_server(self):
158
        # We have a mainline
159
        trunk_tree = self.make_branch_and_tree('mainline')
160
        trunk_revid = trunk_tree.commit('mainline')
161
        # Make sure that we can make a stacked branch from it
162
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
163
            trunk_tree.controldir.sprout('testbranch', stacked=True)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
164
        except unstackable_format_errors as e:
3793.1.2 by Andrew Bennetts
Add test showing that stacking from the smart server works.
165
            raise TestNotApplicable(e)
166
        # Now serve the original mainline from a smart server
167
        remote_transport = self.make_smart_server('mainline')
6472.2.2 by Jelmer Vernooij
Use controldir rather than bzrdir in a couple more places.
168
        remote_bzrdir = controldir.ControlDir.open_from_transport(remote_transport)
3793.1.2 by Andrew Bennetts
Add test showing that stacking from the smart server works.
169
        # and make branch from the smart server which is stacked
170
        new_dir = remote_bzrdir.sprout('newbranch', stacked=True)
171
        # stacked repository
172
        self.assertRevisionNotInRepository('newbranch', trunk_revid)
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
173
        tree = new_dir.open_branch().create_checkout('local')
174
        new_branch_revid = tree.commit('something local')
6182.1.9 by Jelmer Vernooij
More test fixes.
175
        self.assertRevisionNotInRepository(trunk_tree.branch.user_url,
176
            new_branch_revid)
3793.1.2 by Andrew Bennetts
Add test showing that stacking from the smart server works.
177
        self.assertRevisionInRepository('newbranch', new_branch_revid)
178
3537.3.4 by Martin Pool
Improved branch stacking tests
179
    def test_unstack_fetches(self):
180
        """Removing the stacked-on branch pulls across all data"""
5651.5.1 by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646)
181
        try:
182
            builder = self.make_branch_builder('trunk')
183
        except errors.UninitializableFormat:
184
            raise TestNotApplicable('uninitializeable format')
3537.3.4 by Martin Pool
Improved branch stacking tests
185
        # We have a mainline
6747.4.1 by Jelmer Vernooij
Fix remaining tests.
186
        trunk, mainline_revid, rev2 = fixtures.build_branch_with_non_ancestral_rev(builder)
5651.5.1 by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646)
187
        # and make branch from it which is stacked (with no tags)
3537.3.4 by Martin Pool
Improved branch stacking tests
188
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
189
            new_dir = trunk.controldir.sprout(self.get_url('newbranch'), stacked=True)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
190
        except unstackable_format_errors as e:
3537.3.4 by Martin Pool
Improved branch stacking tests
191
            raise TestNotApplicable(e)
192
        # stacked repository
5651.5.1 by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646)
193
        self.assertRevisionNotInRepository('newbranch', mainline_revid)
4509.3.17 by Martin Pool
test_unstack_fetches must put the stacked branch on the right transport to test remote formats
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')
3537.3.4 by Martin Pool
Improved branch stacking tests
199
        # now when we unstack that should implicitly fetch, to make sure that
200
        # the branch will still work
201
        new_branch = new_dir.open_branch()
5651.5.2 by Andrew Bennetts
Simplify new fixture slightly, and other test tweaks.
202
        try:
6747.4.1 by Jelmer Vernooij
Fix remaining tests.
203
            new_branch.tags.set_tag('tag-a', rev2)
5651.5.2 by Andrew Bennetts
Simplify new fixture slightly, and other test tweaks.
204
        except errors.TagsNotSupported:
205
            tags_supported = False
206
        else:
207
            tags_supported = True
3537.3.4 by Martin Pool
Improved branch stacking tests
208
        new_branch.set_stacked_on_url(None)
5651.5.1 by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646)
209
        self.assertRevisionInRepository('newbranch', mainline_revid)
3537.3.4 by Martin Pool
Improved branch stacking tests
210
        # of course it's still in the mainline
5651.5.1 by Andrew Bennetts
Make 'bzr reconfigure --unstacked' fetch tagged revisions too. (#401646)
211
        self.assertRevisionInRepository('trunk', mainline_revid)
5651.5.2 by Andrew Bennetts
Simplify new fixture slightly, and other test tweaks.
212
        if tags_supported:
213
            # the tagged revision in trunk is now in newbranch too
6747.4.1 by Jelmer Vernooij
Fix remaining tests.
214
            self.assertRevisionInRepository('newbranch', rev2)
3537.3.4 by Martin Pool
Improved branch stacking tests
215
        # and now we're no longer stacked
5651.5.2 by Andrew Bennetts
Simplify new fixture slightly, and other test tweaks.
216
        self.assertRaises(errors.NotStacked, new_branch.get_stacked_on_url)
3221.13.2 by Robert Collins
Add a shallow parameter to bzrdir.sprout, which involved fixing a lateny bug in pack to pack fetching with ghost discovery.
217
5325.1.4 by Andrew Bennetts
Improve comments.
218
    def test_unstack_already_locked(self):
5325.1.1 by Andrew Bennetts
Add failing test.
219
        """Removing the stacked-on branch with an already write-locked branch
220
        works.
221
222
        This was bug 551525.
223
        """
224
        try:
225
            stacked_bzrdir = self.make_stacked_bzrdir()
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
226
        except unstackable_format_errors as e:
5325.1.1 by Andrew Bennetts
Add failing test.
227
            raise TestNotApplicable(e)
228
        stacked_branch = stacked_bzrdir.open_branch()
229
        stacked_branch.lock_write()
230
        stacked_branch.set_stacked_on_url(None)
231
        stacked_branch.unlock()
232
5325.1.4 by Andrew Bennetts
Improve comments.
233
    def test_unstack_already_multiple_locked(self):
234
        """Unstacking a branch preserves the lock count (even though it
235
        replaces the br.repository object).
236
237
        This is a more extreme variation of test_unstack_already_locked.
238
        """
5325.1.2 by Andrew Bennetts
Add another failing test.
239
        try:
240
            stacked_bzrdir = self.make_stacked_bzrdir()
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
241
        except unstackable_format_errors as e:
5325.1.2 by Andrew Bennetts
Add another failing test.
242
            raise TestNotApplicable(e)
243
        stacked_branch = stacked_bzrdir.open_branch()
244
        stacked_branch.lock_write()
245
        stacked_branch.lock_write()
246
        stacked_branch.lock_write()
247
        stacked_branch.set_stacked_on_url(None)
248
        stacked_branch.unlock()
249
        stacked_branch.unlock()
250
        stacked_branch.unlock()
251
3567.3.4 by Michael Hudson
make test a lot better
252
    def make_stacked_bzrdir(self, in_directory=None):
3567.3.7 by Michael Hudson
better docstring
253
        """Create a stacked branch and return its bzrdir.
3567.3.4 by Michael Hudson
make test a lot better
254
255
        :param in_directory: If not None, create a directory of this
256
            name and create the stacking and stacked-on bzrdirs in
257
            this directory.
258
        """
259
        if in_directory is not None:
260
            self.get_transport().mkdir(in_directory)
261
            prefix = in_directory + '/'
262
        else:
263
            prefix = ''
264
        tree = self.make_branch_and_tree(prefix + 'stacked-on')
3242.3.40 by Aaron Bentley
Turn failing test into KnownFailure
265
        tree.commit('Added foo')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
266
        stacked_bzrdir = tree.branch.controldir.sprout(
5325.1.1 by Andrew Bennetts
Add failing test.
267
            self.get_url(prefix + 'stacked'), tree.branch.last_revision(),
268
            stacked=True)
3242.3.40 by Aaron Bentley
Turn failing test into KnownFailure
269
        return stacked_bzrdir
270
271
    def test_clone_from_stacked_branch_preserve_stacking(self):
3242.3.24 by Aaron Bentley
Fix test failures
272
        # We can clone from the bzrdir of a stacked branch. If
273
        # preserve_stacking is True, the cloned branch is stacked on the
274
        # same branch as the original.
3242.3.21 by Jonathan Lange
Preserve stacking in clone
275
        try:
3567.3.4 by Michael Hudson
make test a lot better
276
            stacked_bzrdir = self.make_stacked_bzrdir()
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
277
        except unstackable_format_errors as e:
3567.3.5 by Michael Hudson
use TestNotApplicable in all the stacking clone() tests.
278
            raise TestNotApplicable(e)
3242.3.24 by Aaron Bentley
Fix test failures
279
        cloned_bzrdir = stacked_bzrdir.clone('cloned', preserve_stacking=True)
3242.3.21 by Jonathan Lange
Preserve stacking in clone
280
        try:
281
            self.assertEqual(
3537.3.5 by Martin Pool
merge trunk including stacking policy
282
                stacked_bzrdir.open_branch().get_stacked_on_url(),
283
                cloned_bzrdir.open_branch().get_stacked_on_url())
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
284
        except unstackable_format_errors as e:
3242.3.21 by Jonathan Lange
Preserve stacking in clone
285
            pass
3242.3.40 by Aaron Bentley
Turn failing test into KnownFailure
286
3567.3.4 by Michael Hudson
make test a lot better
287
    def test_clone_from_branch_stacked_on_relative_url_preserve_stacking(self):
288
        # If a branch's stacked-on url is relative, we can still clone
289
        # from it with preserve_stacking True and get a branch stacked
290
        # on an appropriately adjusted relative url.
3567.3.3 by Michael Hudson
very hackish test
291
        try:
3567.3.4 by Michael Hudson
make test a lot better
292
            stacked_bzrdir = self.make_stacked_bzrdir(in_directory='dir')
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
293
        except unstackable_format_errors as e:
3567.3.5 by Michael Hudson
use TestNotApplicable in all the stacking clone() tests.
294
            raise TestNotApplicable(e)
3567.3.4 by Michael Hudson
make test a lot better
295
        stacked_bzrdir.open_branch().set_stacked_on_url('../stacked-on')
5325.1.6 by Andrew Bennetts
Fix test_clone_from_branch_stacked_on_relative_url_preserve_stacking failure by making it use get_url so that it tests RemoteBranch* cases the same as others. Also remove some unused imports.
296
        cloned_bzrdir = stacked_bzrdir.clone(
297
            self.get_url('cloned'), preserve_stacking=True)
3567.3.4 by Michael Hudson
make test a lot better
298
        self.assertEqual(
299
            '../dir/stacked-on',
300
            cloned_bzrdir.open_branch().get_stacked_on_url())
3567.3.3 by Michael Hudson
very hackish test
301
3242.3.40 by Aaron Bentley
Turn failing test into KnownFailure
302
    def test_clone_from_stacked_branch_no_preserve_stacking(self):
303
        try:
3567.3.4 by Michael Hudson
make test a lot better
304
            stacked_bzrdir = self.make_stacked_bzrdir()
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
305
        except unstackable_format_errors as e:
3242.3.40 by Aaron Bentley
Turn failing test into KnownFailure
306
            # not a testable combination.
3567.3.5 by Michael Hudson
use TestNotApplicable in all the stacking clone() tests.
307
            raise TestNotApplicable(e)
1551.19.46 by Aaron Bentley
Fix fetch from stacked respositories (#248506)
308
        cloned_unstacked_bzrdir = stacked_bzrdir.clone('cloned-unstacked',
309
            preserve_stacking=False)
3242.3.24 by Aaron Bentley
Fix test failures
310
        unstacked_branch = cloned_unstacked_bzrdir.open_branch()
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
311
        self.assertRaises((errors.NotStacked, _mod_branch.UnstackableBranchFormat),
3537.3.5 by Martin Pool
merge trunk including stacking policy
312
                          unstacked_branch.get_stacked_on_url)
3242.3.37 by Aaron Bentley
Updates from reviews
313
314
    def test_no_op_preserve_stacking(self):
315
        """With no stacking, preserve_stacking should be a no-op."""
316
        branch = self.make_branch('source')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
317
        cloned_bzrdir = branch.controldir.clone('cloned', preserve_stacking=True)
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
318
        self.assertRaises((errors.NotStacked, _mod_branch.UnstackableBranchFormat),
3537.3.5 by Martin Pool
merge trunk including stacking policy
319
                          cloned_bzrdir.open_branch().get_stacked_on_url)
3242.3.37 by Aaron Bentley
Updates from reviews
320
4617.3.1 by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code.
321
    def make_stacked_on_matching(self, source):
322
        if source.repository.supports_rich_root():
323
            if source.repository._format.supports_chks:
324
                format = "2a"
325
            else:
326
                format = "1.9-rich-root"
327
        else:
328
            format = "1.9"
329
        return self.make_branch('stack-on', format)
330
3242.3.37 by Aaron Bentley
Updates from reviews
331
    def test_sprout_stacking_policy_handling(self):
332
        """Obey policy where possible, ignore otherwise."""
5673.1.3 by Jelmer Vernooij
Change flexible_components to fixed_components.
333
        if self.bzrdir_format.fixed_components:
4617.3.1 by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code.
334
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
335
        source = self.make_branch('source')
336
        stack_on = self.make_stacked_on_matching(source)
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
337
        parent_bzrdir = self.make_controldir('.', format='default')
3242.3.37 by Aaron Bentley
Updates from reviews
338
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
339
        target = source.controldir.sprout('target').open_branch()
4617.3.1 by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code.
340
        # When we sprout we upgrade the branch when there is a default stack_on
341
        # set by a config *and* the targeted branch supports stacking.
342
        if stack_on._format.supports_stacking():
3641.1.1 by John Arbash Meinel
Merge in 1.6rc5 and revert disabling default stack on policy
343
            self.assertEqual('../stack-on', target.get_stacked_on_url())
4103.2.1 by Andrew Bennetts
Make clone/sprout stacking policy tests a little more precise.
344
        else:
345
            self.assertRaises(
6734.1.11 by Jelmer Vernooij
Move UnstackableBranchFormat.
346
                branch.UnstackableBranchFormat, target.get_stacked_on_url)
3242.3.38 by Aaron Bentley
Enhance tests
347
348
    def test_clone_stacking_policy_handling(self):
349
        """Obey policy where possible, ignore otherwise."""
5673.1.3 by Jelmer Vernooij
Change flexible_components to fixed_components.
350
        if self.bzrdir_format.fixed_components:
4617.3.1 by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code.
351
            raise TestNotApplicable('Branch format 4 does not autoupgrade.')
352
        source = self.make_branch('source')
353
        stack_on = self.make_stacked_on_matching(source)
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
354
        parent_bzrdir = self.make_controldir('.', format='default')
3242.3.38 by Aaron Bentley
Enhance tests
355
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
356
        target = source.controldir.clone('target').open_branch()
4617.3.1 by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code.
357
        # When we clone we upgrade the branch when there is a default stack_on
358
        # set by a config *and* the targeted branch supports stacking.
359
        if stack_on._format.supports_stacking():
3641.1.1 by John Arbash Meinel
Merge in 1.6rc5 and revert disabling default stack on policy
360
            self.assertEqual('../stack-on', target.get_stacked_on_url())
4103.2.1 by Andrew Bennetts
Make clone/sprout stacking policy tests a little more precise.
361
        else:
362
            self.assertRaises(
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
363
                _mod_branch.UnstackableBranchFormat, target.get_stacked_on_url)
1551.19.46 by Aaron Bentley
Fix fetch from stacked respositories (#248506)
364
4103.2.3 by Andrew Bennetts
Other tests for good luck.
365
    def test_sprout_to_smart_server_stacking_policy_handling(self):
366
        """Obey policy where possible, ignore otherwise."""
5674.1.1 by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat.
367
        if not self.branch_format.supports_leaving_lock():
368
            raise TestNotApplicable('Branch format is not usable via HPSS.')
4617.3.1 by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code.
369
        source = self.make_branch('source')
370
        stack_on = self.make_stacked_on_matching(source)
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
371
        parent_bzrdir = self.make_controldir('.', format='default')
4103.2.3 by Andrew Bennetts
Other tests for good luck.
372
        parent_bzrdir.get_config().set_default_stack_on('stack-on')
373
        url = self.make_smart_server('target').base
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
374
        target = source.controldir.sprout(url).open_branch()
4617.3.1 by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code.
375
        # When we sprout we upgrade the branch when there is a default stack_on
376
        # set by a config *and* the targeted branch supports stacking.
377
        if stack_on._format.supports_stacking():
4103.2.3 by Andrew Bennetts
Other tests for good luck.
378
            self.assertEqual('../stack-on', target.get_stacked_on_url())
379
        else:
380
            self.assertRaises(
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
381
                _mod_branch.UnstackableBranchFormat, target.get_stacked_on_url)
4103.2.3 by Andrew Bennetts
Other tests for good luck.
382
1551.19.47 by Aaron Bentley
Add test per JAM
383
    def prepare_stacked_on_fetch(self):
1551.19.46 by Aaron Bentley
Fix fetch from stacked respositories (#248506)
384
        stack_on = self.make_branch_and_tree('stack-on')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
385
        rev1 = stack_on.commit('first commit')
1551.19.46 by Aaron Bentley
Fix fetch from stacked respositories (#248506)
386
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
387
            stacked_dir = stack_on.controldir.sprout('stacked', stacked=True)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
388
        except unstackable_format_errors as e:
1551.19.46 by Aaron Bentley
Fix fetch from stacked respositories (#248506)
389
            raise TestNotApplicable('Format does not support stacking.')
390
        unstacked = self.make_repository('unstacked')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
391
        return stacked_dir.open_workingtree(), unstacked, rev1
1551.19.47 by Aaron Bentley
Add test per JAM
392
393
    def test_fetch_copies_from_stacked_on(self):
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
394
        stacked, unstacked, rev1 = self.prepare_stacked_on_fetch()
395
        unstacked.fetch(stacked.branch.repository, rev1)
396
        unstacked.get_revision(rev1)
1551.19.47 by Aaron Bentley
Add test per JAM
397
398
    def test_fetch_copies_from_stacked_on_and_stacked(self):
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
399
        stacked, unstacked, rev1 = self.prepare_stacked_on_fetch()
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
400
        tree = stacked.branch.create_checkout('local')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
401
        rev2 = tree.commit('second commit')
402
        unstacked.fetch(stacked.branch.repository, rev2)
403
        unstacked.get_revision(rev1)
404
        unstacked.get_revision(rev2)
405
        self.check_lines_added_or_present(stacked.branch, rev1)
406
        self.check_lines_added_or_present(stacked.branch, rev2)
3582.2.1 by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work.
407
3582.1.8 by Martin Pool
Add test for repeated commits into packed repository
408
    def test_autopack_when_stacked(self):
409
        # in bzr.dev as of 20080730, autopack was reported to fail in stacked
410
        # repositories because of problems with text deltas spanning physical
3582.1.10 by Martin Pool
Add failing tets for pull into stacked repository
411
        # repository boundaries.  however, i didn't actually get this test to
412
        # fail on that code. -- mbp
3582.1.11 by Martin Pool
doc
413
        # see https://bugs.launchpad.net/bzr/+bug/252821
4617.3.1 by Robert Collins
Fix test_stacking tests for 2a as a default format. The change to 2a exposed some actual bugs, both in tests and bzrdir/branch code.
414
        stack_on = self.make_branch_and_tree('stack-on')
415
        if not stack_on.branch._format.supports_stacking():
3582.1.8 by Martin Pool
Add test for repeated commits into packed repository
416
            raise TestNotApplicable("%r does not support stacking"
417
                % self.branch_format)
3582.1.9 by Martin Pool
Make autopack-stacked test use larger files; still does not fail
418
        text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
419
        self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
3582.1.8 by Martin Pool
Add test for repeated commits into packed repository
420
        stack_on.add('a')
421
        stack_on.commit('base commit')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
422
        stacked_dir = stack_on.controldir.sprout('stacked', stacked=True)
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
423
        stacked_branch = stacked_dir.open_branch()
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
424
        local_tree = stack_on.controldir.sprout('local').open_workingtree()
3582.1.8 by Martin Pool
Add test for repeated commits into packed repository
425
        for i in range(20):
3582.1.9 by Martin Pool
Make autopack-stacked test use larger files; still does not fail
426
            text_lines[0] = 'changed in %d\n' % i
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
427
            self.build_tree_contents([('local/a', ''.join(text_lines))])
428
            local_tree.commit('commit %d' % i)
429
            local_tree.branch.push(stacked_branch)
430
        stacked_branch.repository.pack()
431
        check.check_dwim(stacked_branch.base, False, True, True)
3582.1.10 by Martin Pool
Add failing tets for pull into stacked repository
432
433
    def test_pull_delta_when_stacked(self):
434
        if not self.branch_format.supports_stacking():
435
            raise TestNotApplicable("%r does not support stacking"
436
                % self.branch_format)
437
        stack_on = self.make_branch_and_tree('stack-on')
438
        text_lines = ['line %d blah blah blah\n' % i for i in range(20)]
439
        self.build_tree_contents([('stack-on/a', ''.join(text_lines))])
440
        stack_on.add('a')
441
        stack_on.commit('base commit')
442
        # make a stacked branch from the mainline
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
443
        stacked_dir = stack_on.controldir.sprout('stacked', stacked=True)
3582.1.10 by Martin Pool
Add failing tets for pull into stacked repository
444
        stacked_tree = stacked_dir.open_workingtree()
445
        # make a second non-stacked branch from the mainline
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
446
        other_dir = stack_on.controldir.sprout('other')
3582.1.10 by Martin Pool
Add failing tets for pull into stacked repository
447
        other_tree = other_dir.open_workingtree()
448
        text_lines[9] = 'changed in other\n'
449
        self.build_tree_contents([('other/a', ''.join(text_lines))])
3830.3.16 by Martin Pool
Add passing tests for iter_lines_added_or_present in stacked repos
450
        stacked_revid = other_tree.commit('commit in other')
3582.1.10 by Martin Pool
Add failing tets for pull into stacked repository
451
        # this should have generated a delta; try to pull that across
3582.1.15 by Martin Pool
Comments and tests for repository stacking
452
        # bug 252821 caused a RevisionNotPresent here...
453
        stacked_tree.pull(other_tree.branch)
3582.1.10 by Martin Pool
Add failing tets for pull into stacked repository
454
        stacked_tree.branch.repository.pack()
4332.3.35 by Robert Collins
Fix failing tests.
455
        check.check_dwim(stacked_tree.branch.base, False, True, True)
3830.3.16 by Martin Pool
Add passing tests for iter_lines_added_or_present in stacked repos
456
        self.check_lines_added_or_present(stacked_tree.branch, stacked_revid)
3582.1.12 by Martin Pool
merge from trunk
457
3582.2.1 by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work.
458
    def test_fetch_revisions_with_file_changes(self):
459
        # Fetching revisions including file changes into a stacked branch
460
        # works without error.
461
        # Make the source tree.
462
        src_tree = self.make_branch_and_tree('src')
463
        self.build_tree_contents([('src/a', 'content')])
464
        src_tree.add('a')
465
        src_tree.commit('first commit')
466
467
        # Make the stacked-on branch.
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
468
        src_tree.controldir.sprout('stacked-on')
3582.2.1 by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work.
469
470
        # Make a branch stacked on it.
471
        target = self.make_branch('target')
472
        try:
473
            target.set_stacked_on_url('../stacked-on')
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
474
        except unstackable_format_errors as e:
3582.2.1 by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work.
475
            raise TestNotApplicable('Format does not support stacking.')
476
477
        # Change the source branch.
478
        self.build_tree_contents([('src/a', 'new content')])
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
479
        rev2 = src_tree.commit('second commit')
3582.2.1 by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work.
480
481
        # Fetch changes to the target.
482
        target.fetch(src_tree.branch)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
483
        rtree = target.repository.revision_tree(rev2)
3582.2.1 by Jonathan Lange
Fix up problems with fetching revisions. Almost entirely abentley's work.
484
        rtree.lock_read()
485
        self.addCleanup(rtree.unlock)
6809.4.5 by Jelmer Vernooij
Swap arguments for get_file_*.
486
        self.assertEqual('new content', rtree.get_file_text('a'))
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
487
        self.check_lines_added_or_present(target, rev2)
3770.2.1 by Michael Hudson
test and feature
488
489
    def test_transform_fallback_location_hook(self):
490
        # The 'transform_fallback_location' branch hook allows us to inspect
491
        # and transform the URL of the fallback location for the branch.
492
        stack_on = self.make_branch('stack-on')
493
        stacked = self.make_branch('stacked')
494
        try:
495
            stacked.set_stacked_on_url('../stack-on')
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
496
        except unstackable_format_errors as e:
3770.2.1 by Michael Hudson
test and feature
497
            raise TestNotApplicable('Format does not support stacking.')
498
        self.get_transport().rename('stack-on', 'new-stack-on')
499
        hook_calls = []
500
        def hook(stacked_branch, url):
501
            hook_calls.append(url)
502
            return '../new-stack-on'
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
503
        _mod_branch.Branch.hooks.install_named_hook(
3770.2.1 by Michael Hudson
test and feature
504
            'transform_fallback_location', hook, None)
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
505
        _mod_branch.Branch.open('stacked')
3770.2.1 by Michael Hudson
test and feature
506
        self.assertEqual(['../stack-on'], hook_calls)
3830.2.1 by Aaron Bentley
Fix HPSS with branch stacked on repository branch
507
508
    def test_stack_on_repository_branch(self):
509
        # Stacking should work when the repo isn't co-located with the
510
        # stack-on branch.
511
        try:
512
            repo = self.make_repository('repo', shared=True)
513
        except errors.IncompatibleFormat:
514
            raise TestNotApplicable()
6145.2.1 by Jelmer Vernooij
Add RepositoryFormat.supports_nesting_repositories.
515
        if not repo._format.supports_nesting_repositories:
516
            raise TestNotApplicable()
3830.2.1 by Aaron Bentley
Fix HPSS with branch stacked on repository branch
517
        # Avoid make_branch, which produces standalone branches.
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
518
        bzrdir = self.make_controldir('repo/stack-on')
3834.5.4 by John Arbash Meinel
Skip the stack_on_repository test for BranchReference branches.
519
        try:
520
            b = bzrdir.create_branch()
521
        except errors.UninitializableFormat:
522
            raise TestNotApplicable()
3830.2.1 by Aaron Bentley
Fix HPSS with branch stacked on repository branch
523
        transport = self.get_transport('stacked')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
524
        b.controldir.clone_on_transport(transport, stacked_on=b.base)
3830.2.2 by Aaron Bentley
Add explanatory comment.
525
        # Ensure that opening the branch doesn't raise.
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
526
        _mod_branch.Branch.open(transport.base)
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
527
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
528
    def test_revision_history_of_stacked(self):
4419.1.6 by Andrew Bennetts
Add comments requested by Martin's review.
529
        # See <https://launchpad.net/bugs/380314>.
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
530
        stack_on = self.make_branch_and_tree('stack-on')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
531
        rev1 = stack_on.commit('first commit')
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
532
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
533
            stacked_dir = stack_on.controldir.sprout(
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
534
                self.get_url('stacked'), stacked=True)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
535
        except unstackable_format_errors as e:
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
536
            raise TestNotApplicable('Format does not support stacking.')
537
        try:
538
            stacked = stacked_dir.open_workingtree()
539
        except errors.NoWorkingTree:
540
            stacked = stacked_dir.open_branch().create_checkout(
541
                'stacked-checkout', lightweight=True)
4595.4.4 by Robert Collins
Disable committing directly to stacked branches from lightweight checkouts.
542
        tree = stacked.branch.create_checkout('local')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
543
        rev2 = tree.commit('second commit')
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
544
        # Sanity check: stacked's repo should not contain rev1, otherwise this
545
        # test isn't testing what it's supposed to.
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
546
        repo = stacked.branch.repository.controldir.open_repository()
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
547
        repo.lock_read()
548
        self.addCleanup(repo.unlock)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
549
        self.assertEqual({}, repo.get_parent_map([rev1]))
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
550
        # revision_history should work, even though the history is spread over
551
        # multiple repositories.
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
552
        self.assertEqual((2, rev2), stacked.branch.last_revision_info())
4419.1.2 by Andrew Bennetts
Add branch_implementations test for revision_history() on a stacked branch.
553
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
554
555
class TestStackingConnections(
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
556
        transport_util.TestCaseWithConnectionHookedTransport):
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
557
558
    def setUp(self):
559
        super(TestStackingConnections, self).setUp()
560
        try:
561
            base_tree = self.make_branch_and_tree('base',
562
                                                  format=self.bzrdir_format)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
563
        except errors.UninitializableFormat as e:
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
564
            raise TestNotApplicable(e)
565
        stacked = self.make_branch('stacked', format=self.bzrdir_format)
566
        try:
567
            stacked.set_stacked_on_url(base_tree.branch.base)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
568
        except unstackable_format_errors as e:
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
569
            raise TestNotApplicable(e)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
570
        self.rev_base = base_tree.commit('first')
571
        stacked.set_last_revision_info(1, self.rev_base)
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
572
        stacked_relative = self.make_branch('stacked_relative',
573
                                            format=self.bzrdir_format)
6182.1.12 by Jelmer Vernooij
Fix two more tests.
574
        stacked_relative.set_stacked_on_url(base_tree.branch.user_url)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
575
        stacked.set_last_revision_info(1, self.rev_base)
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
576
        self.start_logging_connections()
577
578
    def test_open_stacked(self):
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
579
        b = _mod_branch.Branch.open(self.get_url('stacked'))
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
580
        rev = b.repository.get_revision(self.rev_base)
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
581
        self.assertEqual(1, len(self.connections))
582
583
    def test_open_stacked_relative(self):
6743 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-more.
584
        b = _mod_branch.Branch.open(self.get_url('stacked_relative'))
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
585
        rev = b.repository.get_revision(self.rev_base)
3928.3.1 by John Arbash Meinel
Fix Branch.open() so that for stacked branches we don't open multiple connections.
586
        self.assertEqual(1, len(self.connections))