/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
5557.1.15 by John Arbash Meinel
Merge bzr.dev 5597 to resolve NEWS, aka bzr-2.3.txt
1
# Copyright (C) 2006-2011 Canonical Ltd
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
2
#
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
7
#
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
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.
1887.1.1 by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines,
12
#
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
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
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
16
4118.1.1 by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests.
17
"""Tests for repository implementations - tests a repository format."""
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
18
7479.2.1 by Jelmer Vernooij
Drop python2 support.
19
from io import BytesIO
1666.1.6 by Robert Collins
Make knit the default format.
20
import re
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
21
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
22
from ... import (
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
23
    branch as _mod_branch,
6744 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-knit.
24
    commit,
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
25
    controldir,
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
26
    delta as _mod_delta,
1752.2.87 by Andrew Bennetts
Make tests pass.
27
    errors,
3735.2.100 by Vincent Ladeuil
Fix 3 failing tests due to an amazing typo.
28
    gpg,
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
29
    info,
1752.2.87 by Andrew Bennetts
Make tests pass.
30
    repository,
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
31
    revision as _mod_revision,
32
    tests,
33
    transport,
34
    upgrade,
35
    workingtree,
1752.2.87 by Andrew Bennetts
Make tests pass.
36
    )
6670.4.3 by Jelmer Vernooij
Fix more imports.
37
from ...bzr import (
38
    branch as _mod_bzrbranch,
39
    inventory,
6670.4.14 by Jelmer Vernooij
Move remote to breezy.bzr.
40
    remote,
6670.4.3 by Jelmer Vernooij
Fix more imports.
41
    repository as bzrrepository,
42
    )
6670.4.5 by Jelmer Vernooij
Move breezy.repofmt contents to breezy.bzr.
43
from ...bzr import (
5757.1.5 by Jelmer Vernooij
Fix import.
44
    knitpack_repo,
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
45
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
46
from .. import (
5017.3.42 by Vincent Ladeuil
-s bt.per_repository.test_repo passing
47
    per_repository,
48
    test_server,
49
    )
6624 by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes')
50
from ..matchers import *
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
51
52
53
class TestRepositoryMakeBranchAndTree(per_repository.TestCaseWithRepository):
2018.5.66 by Wouter van Heyst
Fix repository test parameterization for RemoteRepository.
54
55
    def test_repository_format(self):
2018.5.119 by Robert Collins
Unbreak TestRepositoryMakeBranchAndTree.
56
        # make sure the repository on tree.branch is of the desired format,
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
57
        # because developers use this api to setup the tree, branch and
2018.5.119 by Robert Collins
Unbreak TestRepositoryMakeBranchAndTree.
58
        # repository for their tests: having it now give the right repository
59
        # type would invalidate the tests.
2018.5.66 by Wouter van Heyst
Fix repository test parameterization for RemoteRepository.
60
        tree = self.make_branch_and_tree('repo')
61
        self.assertIsInstance(tree.branch.repository._format,
7143.15.2 by Jelmer Vernooij
Run autopep8.
62
                              self.repository_format.__class__)
2381.1.1 by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's.
63
64
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
65
class TestRepository(per_repository.TestCaseWithRepository):
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
66
4431.3.7 by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts.
67
    def assertFormatAttribute(self, attribute, allowed_values):
68
        """Assert that the format has an attribute 'attribute'."""
69
        repo = self.make_repository('repo')
6820.2.3 by Jelmer Vernooij
Review comments.
70
        self.assertIn(getattr(repo._format, attribute), allowed_values)
4431.3.7 by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts.
71
7254.5.1 by Jelmer Vernooij
Add supports_random_access attribute to repositories.
72
    def assertRepositoryAttribute(self, attribute, allowed_values):
73
        """Assert that the repo has an attribute 'attribute'."""
74
        repo = self.make_repository('repo')
75
        self.assertIn(getattr(repo, attribute), allowed_values)
76
4183.5.1 by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation.
77
    def test_attribute_fast_deltas(self):
78
        """Test the format.fast_deltas attribute."""
4431.3.7 by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts.
79
        self.assertFormatAttribute('fast_deltas', (True, False))
4183.5.1 by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation.
80
6145.2.2 by Jelmer Vernooij
Set supports_nesting_repositories.
81
    def test_attribute_supports_nesting_repositories(self):
82
        """Test the format.supports_nesting_repositories."""
83
        self.assertFormatAttribute('supports_nesting_repositories',
7143.15.2 by Jelmer Vernooij
Run autopep8.
84
                                   (True, False))
6145.2.2 by Jelmer Vernooij
Set supports_nesting_repositories.
85
6217.4.2 by Jelmer Vernooij
s/invisible/unreferenced.
86
    def test_attribute_supports_unreferenced_revisions(self):
87
        """Test the format.supports_unreferenced_revisions."""
88
        self.assertFormatAttribute('supports_unreferenced_revisions',
7143.15.2 by Jelmer Vernooij
Run autopep8.
89
                                   (True, False))
6217.4.1 by Jelmer Vernooij
Add RepositoryFormat.supports_invisible_revisions.
90
3565.3.4 by Robert Collins
Defer decision to reconcile to the repository being fetched into.
91
    def test_attribute__fetch_reconcile(self):
4775.1.1 by Martin Pool
Remove several 'the the' typos
92
        """Test the _fetch_reconcile attribute."""
4431.3.7 by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts.
93
        self.assertFormatAttribute('_fetch_reconcile', (True, False))
94
4988.9.1 by Jelmer Vernooij
Add experimental flag to RepositoryFormat.
95
    def test_attribute_format_experimental(self):
96
        self.assertFormatAttribute('experimental', (True, False))
97
4431.3.7 by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts.
98
    def test_attribute_format_pack_compresses(self):
99
        self.assertFormatAttribute('pack_compresses', (True, False))
3565.3.4 by Robert Collins
Defer decision to reconcile to the repository being fetched into.
100
5684.2.1 by Jelmer Vernooij
Add bzrlib.tests.per_repository_vf.
101
    def test_attribute_format_supports_full_versioned_files(self):
102
        self.assertFormatAttribute('supports_full_versioned_files',
7143.15.2 by Jelmer Vernooij
Run autopep8.
103
                                   (True, False))
5684.2.1 by Jelmer Vernooij
Add bzrlib.tests.per_repository_vf.
104
105
    def test_attribute_format_supports_funky_characters(self):
106
        self.assertFormatAttribute('supports_funky_characters',
7143.15.2 by Jelmer Vernooij
Run autopep8.
107
                                   (True, False))
5684.2.1 by Jelmer Vernooij
Add bzrlib.tests.per_repository_vf.
108
109
    def test_attribute_format_supports_leaving_lock(self):
110
        self.assertFormatAttribute('supports_leaving_lock',
7143.15.2 by Jelmer Vernooij
Run autopep8.
111
                                   (True, False))
3350.6.4 by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores.
112
5993.3.2 by Jelmer Vernooij
Add Repository.supports_versioned_directories.
113
    def test_attribute_format_versioned_directories(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
114
        self.assertFormatAttribute(
115
            'supports_versioned_directories', (True, False))
5993.3.2 by Jelmer Vernooij
Add Repository.supports_versioned_directories.
116
5766.1.1 by Jelmer Vernooij
Make revision-graph-can-have-wrong-parents a repository format attribute rather than a repository method.
117
    def test_attribute_format_revision_graph_can_have_wrong_parents(self):
118
        self.assertFormatAttribute('revision_graph_can_have_wrong_parents',
7143.15.2 by Jelmer Vernooij
Run autopep8.
119
                                   (True, False))
5766.1.1 by Jelmer Vernooij
Make revision-graph-can-have-wrong-parents a repository format attribute rather than a repository method.
120
7254.5.1 by Jelmer Vernooij
Add supports_random_access attribute to repositories.
121
    def test_attribute_format_supports_random_access(self):
122
        self.assertRepositoryAttribute('supports_random_access', (True, False))
123
6746.1.2 by Jelmer Vernooij
Add tests for supports_setting_revision_ids.
124
    def test_attribute_format_supports_setting_revision_ids(self):
125
        self.assertFormatAttribute('supports_setting_revision_ids',
7143.15.2 by Jelmer Vernooij
Run autopep8.
126
                                   (True, False))
6746.1.2 by Jelmer Vernooij
Add tests for supports_setting_revision_ids.
127
6820.1.1 by Jelmer Vernooij
add RepositoryFormat.supports_storing_branch_nick.
128
    def test_attribute_format_supports_storing_branch_nick(self):
129
        self.assertFormatAttribute('supports_storing_branch_nick',
7143.15.2 by Jelmer Vernooij
Run autopep8.
130
                                   (True, False))
6820.1.1 by Jelmer Vernooij
add RepositoryFormat.supports_storing_branch_nick.
131
6852.2.1 by Jelmer Vernooij
Allow formats to not support custom revision properties.
132
    def test_attribute_format_supports_custom_revision_properties(self):
133
        self.assertFormatAttribute(
7143.15.2 by Jelmer Vernooij
Run autopep8.
134
            'supports_custom_revision_properties',
135
            (True, False))
6852.2.1 by Jelmer Vernooij
Allow formats to not support custom revision properties.
136
6820.2.1 by Jelmer Vernooij
Add flag to check whether overriding transport is supported.
137
    def test_attribute_format_supports_overriding_transport(self):
138
        repo = self.make_repository('repo')
7143.15.2 by Jelmer Vernooij
Run autopep8.
139
        self.assertIn(
140
            repo._format.supports_overriding_transport, (True, False))
6820.2.1 by Jelmer Vernooij
Add flag to check whether overriding transport is supported.
141
142
        repo.control_transport.copy_tree('.', '../repository.backup')
143
        backup_transport = repo.control_transport.clone('../repository.backup')
144
        if repo._format.supports_overriding_transport:
145
            backup = repo._format.open(
7143.15.2 by Jelmer Vernooij
Run autopep8.
146
                repo.controldir,
147
                _override_transport=backup_transport)
6820.2.1 by Jelmer Vernooij
Add flag to check whether overriding transport is supported.
148
            self.assertIs(backup_transport, backup.control_transport)
149
        else:
150
            self.assertRaises(TypeError, repo._format.open,
7143.15.2 by Jelmer Vernooij
Run autopep8.
151
                              repo.controldir, _override_transport=backup_transport)
6820.2.1 by Jelmer Vernooij
Add flag to check whether overriding transport is supported.
152
5675.2.5 by Jelmer Vernooij
add tests for repository attributes.
153
    def test_format_is_deprecated(self):
154
        repo = self.make_repository('repo')
6820.2.3 by Jelmer Vernooij
Review comments.
155
        self.assertIn(repo._format.is_deprecated(), (True, False))
5675.2.5 by Jelmer Vernooij
add tests for repository attributes.
156
157
    def test_format_is_supported(self):
158
        repo = self.make_repository('repo')
6820.2.3 by Jelmer Vernooij
Review comments.
159
        self.assertIn(repo._format.is_supported(), (True, False))
5675.2.5 by Jelmer Vernooij
add tests for repository attributes.
160
6883.22.19 by Jelmer Vernooij
Add records_per_file_revision attribute.
161
    def test_attribute_format_records_per_file_revision(self):
162
        self.assertFormatAttribute('records_per_file_revision',
7143.15.2 by Jelmer Vernooij
Run autopep8.
163
                                   (True, False))
6883.22.19 by Jelmer Vernooij
Add records_per_file_revision attribute.
164
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
165
    def test_clone_to_default_format(self):
7143.15.2 by Jelmer Vernooij
Run autopep8.
166
        # TODO: Test that cloning a repository preserves all the information
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
167
        # such as signatures[not tested yet] etc etc.
168
        # when changing to the current default format.
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
169
        tree_a = self.make_branch_and_tree('a')
2381.1.3 by Robert Collins
Review feedback.
170
        self.build_tree(['a/foo'])
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
171
        tree_a.add('foo')
172
        file_id = tree_a.path2id('foo')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
173
        rev1 = tree_a.commit('rev1')
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
174
        bzrdirb = self.make_controldir('b')
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
175
        repo_b = tree_a.branch.repository.clone(bzrdirb)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
176
        tree_b = repo_b.revision_tree(rev1)
2592.3.214 by Robert Collins
Merge bzr.dev.
177
        tree_b.lock_read()
178
        self.addCleanup(tree_b.unlock)
6809.4.5 by Jelmer Vernooij
Swap arguments for get_file_*.
179
        tree_b.get_file_text('foo')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
180
        repo_b.get_revision(rev1)
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
181
1910.2.63 by Aaron Bentley
Add supports_rich_root member to repository
182
    def test_supports_rich_root(self):
183
        tree = self.make_branch_and_tree('a')
184
        tree.commit('')
185
        second_revision = tree.commit('')
4253.3.1 by Robert Collins
per_repository/test_repository improvements (Robert Collins)
186
        rev_tree = tree.branch.repository.revision_tree(second_revision)
187
        rev_tree.lock_read()
188
        self.addCleanup(rev_tree.unlock)
7141.7.1 by Jelmer Vernooij
Get rid of file_ids in most of Tree.
189
        root_revision = rev_tree.get_file_revision(u'')
5805.1.1 by Jelmer Vernooij
Avoid using inventories in some tests.
190
        rich_root = (root_revision != second_revision)
2018.5.113 by Robert Collins
Test only fixes from the ported-to-bzr.dev test-correctness branch.
191
        self.assertEqual(rich_root,
1910.2.63 by Aaron Bentley
Add supports_rich_root member to repository
192
                         tree.branch.repository.supports_rich_root())
193
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
194
    def test_clone_specific_format(self):
195
        """todo"""
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
196
197
    def test_format_initialize_find_open(self):
198
        # loopback test to check the current format initializes to itself.
199
        if not self.repository_format.is_supported():
200
            # unsupported formats are not loopback testable
201
            # because the default open will not open them and
202
            # they may not be initializable.
203
            return
204
        # supported formats must be able to init and open
5609.9.4 by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible.
205
        t = self.get_transport()
206
        readonly_t = self.get_readonly_transport()
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
207
        made_control = self.bzrdir_format.initialize(t.base)
208
        made_repo = self.repository_format.initialize(made_control)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
209
        self.assertEqual(made_control, made_repo.controldir)
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
210
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
211
        # find it via controldir opening:
212
        opened_control = controldir.ControlDir.open(readonly_t.base)
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
213
        direct_opened_repo = opened_control.open_repository()
214
        self.assertEqual(direct_opened_repo.__class__, made_repo.__class__)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
215
        self.assertEqual(opened_control, direct_opened_repo.controldir)
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
216
1752.2.52 by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories.
217
        self.assertIsInstance(direct_opened_repo._format,
218
                              self.repository_format.__class__)
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
219
        # find it via Repository.open
220
        opened_repo = repository.Repository.open(readonly_t.base)
5784.1.1 by Martin Pool
Stop using failIf, failUnless, etc
221
        self.assertIsInstance(opened_repo, made_repo.__class__)
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
222
        self.assertEqual(made_repo._format.__class__,
223
                         opened_repo._format.__class__)
224
        # if it has a unique id string, can we probe for it ?
225
        try:
226
            self.repository_format.get_format_string()
227
        except NotImplementedError:
228
            return
229
        self.assertEqual(self.repository_format,
7143.15.2 by Jelmer Vernooij
Run autopep8.
230
                         bzrrepository.RepositoryFormatMetaDir.find_format(opened_control))
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
231
6746.2.1 by Jelmer Vernooij
Rename matchingbzrdir to matchingcontroldir.
232
    def test_format_matchingcontroldir(self):
3845.1.1 by John Arbash Meinel
Ensure that RepositoryFormat._matchingbzrdir.repository_format matches.
233
        self.assertEqual(self.repository_format,
7143.15.2 by Jelmer Vernooij
Run autopep8.
234
                         self.repository_format._matchingcontroldir.repository_format)
3845.1.1 by John Arbash Meinel
Ensure that RepositoryFormat._matchingbzrdir.repository_format matches.
235
        self.assertEqual(self.repository_format,
7143.15.2 by Jelmer Vernooij
Run autopep8.
236
                         self.bzrdir_format.repository_format)
3845.1.1 by John Arbash Meinel
Ensure that RepositoryFormat._matchingbzrdir.repository_format matches.
237
3990.5.1 by Andrew Bennetts
Add network_name() to RepositoryFormat.
238
    def test_format_network_name(self):
239
        repo = self.make_repository('r')
240
        format = repo._format
241
        network_name = format.network_name()
6973.7.8 by Jelmer Vernooij
Fix more tests.
242
        self.assertIsInstance(network_name, bytes)
3990.5.1 by Andrew Bennetts
Add network_name() to RepositoryFormat.
243
        # We want to test that the network_name matches the actual format on
244
        # disk.  For local repositories, that means that using network_name as
245
        # a key in the registry gives back the same format.  For remote
246
        # repositories, that means that the network_name of the
247
        # RemoteRepositoryFormat we have locally matches the actual format
248
        # present on the remote side.
249
        if isinstance(format, remote.RemoteRepositoryFormat):
250
            repo._ensure_real()
251
            real_repo = repo._real_repository
252
            self.assertEqual(real_repo._format.network_name(), network_name)
253
        else:
254
            registry = repository.network_format_registry
255
            looked_up_format = registry.get(network_name)
256
            self.assertEqual(format.__class__, looked_up_format.__class__)
257
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
258
    def test_create_repository(self):
1534.6.1 by Robert Collins
allow API creation of shared repositories
259
        # bzrdir can construct a repository for itself.
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
260
        if not self.bzrdir_format.is_supported():
261
            # unsupported formats are not loopback testable
262
            # because the default open will not open them and
263
            # they may not be initializable.
264
            return
5609.9.4 by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible.
265
        t = self.get_transport()
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
266
        made_control = self.bzrdir_format.initialize(t.base)
267
        made_repo = made_control.create_repository()
1752.2.50 by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree}
268
        # Check that we have a repository object.
6973.5.2 by Jelmer Vernooij
Add more bees.
269
        made_repo.has_revision(b'foo')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
270
        self.assertEqual(made_control, made_repo.controldir)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
271
1534.6.1 by Robert Collins
allow API creation of shared repositories
272
    def test_create_repository_shared(self):
273
        # bzrdir can construct a shared repository.
274
        if not self.bzrdir_format.is_supported():
275
            # unsupported formats are not loopback testable
276
            # because the default open will not open them and
277
            # they may not be initializable.
278
            return
5609.9.4 by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible.
279
        t = self.get_transport()
1534.6.1 by Robert Collins
allow API creation of shared repositories
280
        made_control = self.bzrdir_format.initialize(t.base)
281
        try:
282
            made_repo = made_control.create_repository(shared=True)
283
        except errors.IncompatibleFormat:
284
            # not all repository formats understand being shared, or
285
            # may only be shared in some circumstances.
286
            return
1752.2.50 by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree}
287
        # Check that we have a repository object.
6973.5.2 by Jelmer Vernooij
Add more bees.
288
        made_repo.has_revision(b'foo')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
289
        self.assertEqual(made_control, made_repo.controldir)
1534.6.3 by Robert Collins
find_repository sufficiently robust.
290
        self.assertTrue(made_repo.is_shared())
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
291
292
    def test_revision_tree(self):
293
        wt = self.make_branch_and_tree('.')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
294
        rev1 = wt.commit('lala!', allow_pointless=True)
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
295
        root_id = wt.path2id('')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
296
        tree = wt.branch.repository.revision_tree(rev1)
7143.19.1 by Jelmer Vernooij
Drop superfluous kind and file_id return values from Tree.list_files.
297
        with tree.lock_read():
7141.7.1 by Jelmer Vernooij
Get rid of file_ids in most of Tree.
298
            self.assertEqual(rev1, tree.get_file_revision(u''))
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
299
            expected = inventory.InventoryDirectory(root_id, '', None)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
300
            expected.revision = rev1
7143.19.5 by Jelmer Vernooij
Undo removal of kind.
301
            self.assertEqual([('', 'V', 'directory', expected)],
4253.3.1 by Robert Collins
per_repository/test_repository improvements (Robert Collins)
302
                             list(tree.list_files(include_root=True)))
6630.1.1 by Jelmer Vernooij
Remove deprecated functionality.
303
        self.assertRaises(ValueError, wt.branch.repository.revision_tree, None)
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
304
        tree = wt.branch.repository.revision_tree(_mod_revision.NULL_REVISION)
7143.19.1 by Jelmer Vernooij
Drop superfluous kind and file_id return values from Tree.list_files.
305
        with tree.lock_read():
4253.3.1 by Robert Collins
per_repository/test_repository improvements (Robert Collins)
306
            self.assertEqual([], list(tree.list_files(include_root=True)))
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
307
1770.3.3 by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta().
308
    def test_get_revision_delta(self):
309
        tree_a = self.make_branch_and_tree('a')
2381.1.3 by Robert Collins
Review feedback.
310
        self.build_tree(['a/foo'])
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
311
        tree_a.add('foo')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
312
        rev1 = tree_a.commit('rev1')
2381.1.3 by Robert Collins
Review feedback.
313
        self.build_tree(['a/vla'])
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
314
        tree_a.add('vla')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
315
        rev2 = tree_a.commit('rev2')
1770.3.3 by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta().
316
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
317
        delta = tree_a.branch.repository.get_revision_delta(rev1)
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
318
        self.assertIsInstance(delta, _mod_delta.TreeDelta)
7358.11.3 by Jelmer Vernooij
TreeDelta holds TreeChange objects rather than tuples of various sizes.
319
        self.assertEqual([('foo', 'file')], [(c.path[1], c.kind[1]) for c in delta.added])
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
320
        delta = tree_a.branch.repository.get_revision_delta(rev2)
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
321
        self.assertIsInstance(delta, _mod_delta.TreeDelta)
7358.11.3 by Jelmer Vernooij
TreeDelta holds TreeChange objects rather than tuples of various sizes.
322
        self.assertEqual([('vla', 'file')], [(c.path[1], c.kind[1]) for c in delta.added])
1770.3.3 by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta().
323
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
324
    def test_clone_bzrdir_repository_revision(self):
325
        # make a repository with some revisions,
326
        # and clone it, this should not have unreferenced revisions.
327
        # also: test cloning with a revision id of NULL_REVISION -> empty repo.
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
328
        raise tests.TestSkipped('revision limiting is not implemented yet.')
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
329
330
    def test_clone_repository_basis_revision(self):
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
331
        raise tests.TestSkipped(
332
            'the use of a basis should not add noise data to the result.')
1534.4.50 by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running.
333
1534.6.5 by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes.
334
    def test_clone_shared_no_tree(self):
335
        # cloning a shared repository keeps it shared
336
        # and preserves the make_working_tree setting.
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
337
        made_control = self.make_controldir('source')
1534.6.5 by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes.
338
        try:
339
            made_repo = made_control.create_repository(shared=True)
340
        except errors.IncompatibleFormat:
341
            # not all repository formats understand being shared, or
342
            # may only be shared in some circumstances.
343
            return
2018.14.2 by Andrew Bennetts
All but one repository_implementation tests for RemoteRepository passing.
344
        try:
345
            made_repo.set_make_working_trees(False)
6104.2.2 by Jelmer Vernooij
Expect UnsupportedOperation when set_make_working_trees is not available.
346
        except errors.UnsupportedOperation:
2018.5.120 by Robert Collins
The Repository API ``make_working_trees`` is now permitted to return
347
            # the repository does not support having its tree-making flag
348
            # toggled.
349
            return
1534.6.5 by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes.
350
        result = made_control.clone(self.get_url('target'))
1752.2.55 by Andrew Bennetts
Replace another isinstance(made_repo, Repository) check.
351
        # Check that we have a repository object.
6973.5.2 by Jelmer Vernooij
Add more bees.
352
        made_repo.has_revision(b'foo')
1752.2.55 by Andrew Bennetts
Replace another isinstance(made_repo, Repository) check.
353
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
354
        self.assertEqual(made_control, made_repo.controldir)
1534.6.5 by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes.
355
        self.assertTrue(result.open_repository().is_shared())
356
        self.assertFalse(result.open_repository().make_working_trees())
357
2018.5.90 by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository.
358
    def test_upgrade_preserves_signatures(self):
6257.2.1 by Jelmer Vernooij
Cope with repositories that don't support revision signatures.
359
        if not self.repository_format.supports_revision_signatures:
360
            raise tests.TestNotApplicable(
361
                "repository does not support signing revisions")
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
362
        wt = self.make_branch_and_tree('source')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
363
        a = wt.commit('A', allow_pointless=True)
2018.5.90 by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository.
364
        repo = wt.branch.repository
2592.3.39 by Robert Collins
Fugly version to remove signatures.kndx
365
        repo.lock_write()
366
        repo.start_write_group()
5751.2.3 by Jelmer Vernooij
More tests
367
        try:
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
368
            repo.sign_revision(a, gpg.LoopbackGPGStrategy(None))
5751.2.3 by Jelmer Vernooij
More tests
369
        except errors.UnsupportedOperation:
370
            self.assertFalse(repo._format.supports_revision_signatures)
7143.15.2 by Jelmer Vernooij
Run autopep8.
371
            raise tests.TestNotApplicable(
372
                "signatures not supported by repository format")
2592.3.39 by Robert Collins
Fugly version to remove signatures.kndx
373
        repo.commit_write_group()
374
        repo.unlock()
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
375
        old_signature = repo.get_signature_text(a)
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
376
        try:
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
377
            old_format = controldir.ControlDirFormat.get_default_format()
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
378
            # This gives metadir branches something they can convert to.
379
            # it would be nice to have a 'latest' vs 'default' concept.
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
380
            format = controldir.format_registry.make_controldir(
6437.14.2 by Jelmer Vernooij
Run subtree tests with development-subtree rather than deprecated dirstate-with-subtree.
381
                'development-subtree')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
382
            upgrade.upgrade(repo.controldir.root_transport.base, format=format)
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
383
        except errors.UpToDateFormat:
384
            # this is in the most current format already.
385
            return
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
386
        except errors.BadConversionTarget as e:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
387
            raise tests.TestSkipped(str(e))
388
        wt = workingtree.WorkingTree.open(wt.basedir)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
389
        new_signature = wt.branch.repository.get_signature_text(a)
1556.1.4 by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same.
390
        self.assertEqual(old_signature, new_signature)
391
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
392
    def test_format_description(self):
393
        repo = self.make_repository('.')
394
        text = repo._format.get_format_description()
5784.1.1 by Martin Pool
Stop using failIf, failUnless, etc
395
        self.assertTrue(len(text))
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
396
3221.3.1 by Robert Collins
* Repository formats have a new supported-feature attribute
397
    def test_format_supports_external_lookups(self):
398
        repo = self.make_repository('.')
6820.2.3 by Jelmer Vernooij
Review comments.
399
        self.assertIn(repo._format.supports_external_lookups, (True, False))
3221.3.1 by Robert Collins
* Repository formats have a new supported-feature attribute
400
1666.1.6 by Robert Collins
Make knit the default format.
401
    def assertMessageRoundtrips(self, message):
402
        """Assert that message roundtrips to a repository and back intact."""
403
        tree = self.make_branch_and_tree('.')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
404
        a = tree.commit(message, allow_pointless=True)
405
        rev = tree.branch.repository.get_revision(a)
5815.4.13 by Jelmer Vernooij
Move corruption tests to bt.per_repository_vf.
406
        serializer = getattr(tree.branch.repository, "_serializer", None)
407
        if serializer is not None and serializer.squashes_xml_invalid_characters:
4416.5.1 by Jelmer Vernooij
Move squashing of XML-invalid characters to XMLSerializer.
408
            # we have to manually escape this as we dont try to
4443.1.2 by Jelmer Vernooij
Fix comment about XML escaping in tests.
409
            # roundtrip xml invalid characters in the xml-based serializers.
4416.5.1 by Jelmer Vernooij
Move squashing of XML-invalid characters to XMLSerializer.
410
            escaped_message, escape_count = re.subn(
411
                u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
7143.15.2 by Jelmer Vernooij
Run autopep8.
412
                lambda match: match.group(0).encode(
413
                    'unicode_escape').decode('ascii'),
4416.5.1 by Jelmer Vernooij
Move squashing of XML-invalid characters to XMLSerializer.
414
                message)
415
            self.assertEqual(rev.message, escaped_message)
416
        else:
417
            self.assertEqual(rev.message, message)
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
418
        # insist the class is unicode no matter what came in for
1666.1.6 by Robert Collins
Make knit the default format.
419
        # consistency.
7479.2.1 by Jelmer Vernooij
Drop python2 support.
420
        self.assertIsInstance(rev.message, str)
1666.1.6 by Robert Collins
Make knit the default format.
421
422
    def test_commit_unicode_message(self):
423
        # a siple unicode message should be preserved
424
        self.assertMessageRoundtrips(u'foo bar gamm\xae plop')
425
426
    def test_commit_unicode_control_characters(self):
427
        # a unicode message with control characters should roundtrip too.
7479.2.1 by Jelmer Vernooij
Drop python2 support.
428
        unichars = [chr(x) for x in range(256)]
3831.1.4 by John Arbash Meinel
Update the per-repository unicode commit test.
429
        # '\r' is not directly allowed anymore, as it used to be translated
430
        # into '\n' anyway
431
        unichars[ord('\r')] = u'\n'
1666.1.6 by Robert Collins
Make knit the default format.
432
        self.assertMessageRoundtrips(
7143.15.2 by Jelmer Vernooij
Run autopep8.
433
            u"All 8-bit chars: " + ''.join(unichars))
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
434
1732.2.4 by Martin Pool
Split check into Branch.check and Repository.check
435
    def test_check_repository(self):
436
        """Check a fairly simple repository's history"""
437
        tree = self.make_branch_and_tree('.')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
438
        a_rev = tree.commit('initial empty commit', allow_pointless=True)
2745.6.39 by Andrew Bennetts
Use scenario in test_check too, and make check actually report inconsistent parents to the end user.
439
        result = tree.branch.repository.check()
1732.2.4 by Martin Pool
Split check into Branch.check and Repository.check
440
        # writes to log; should accept both verbose or non-verbose
441
        result.report_results(verbose=True)
442
        result.report_results(verbose=False)
443
1756.1.5 by Aaron Bentley
Test get_revisions with all repository types (and fix bug...)
444
    def test_get_revisions(self):
445
        tree = self.make_branch_and_tree('.')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
446
        a_rev = tree.commit('initial empty commit', allow_pointless=True)
447
        b_rev = tree.commit('second empty commit', allow_pointless=True)
448
        c_rev = tree.commit('third empty commit', allow_pointless=True)
1756.1.5 by Aaron Bentley
Test get_revisions with all repository types (and fix bug...)
449
        repo = tree.branch.repository
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
450
        revision_ids = [a_rev, b_rev, c_rev]
1756.1.5 by Aaron Bentley
Test get_revisions with all repository types (and fix bug...)
451
        revisions = repo.get_revisions(revision_ids)
3376.2.4 by Martin Pool
Remove every assert statement from bzrlib!
452
        self.assertEqual(len(revisions), 3)
6631.2.1 by Martin
Run 2to3 zip fixer and refactor
453
        zipped = list(zip(revisions, revision_ids))
1756.1.5 by Aaron Bentley
Test get_revisions with all repository types (and fix bug...)
454
        self.assertEqual(len(zipped), 3)
455
        for revision, revision_id in zipped:
456
            self.assertEqual(revision.revision_id, revision_id)
457
            self.assertEqual(revision, repo.get_revision(revision_id))
1732.2.4 by Martin Pool
Split check into Branch.check and Repository.check
458
6714.1.3 by Jelmer Vernooij
Add Repository.iter_revisions.
459
    def test_iter_revisions(self):
460
        tree = self.make_branch_and_tree('.')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
461
        a_rev = tree.commit('initial empty commit', allow_pointless=True)
462
        b_rev = tree.commit('second empty commit', allow_pointless=True)
463
        c_rev = tree.commit('third empty commit', allow_pointless=True)
7045.2.13 by Jelmer Vernooij
Fix some workingtree_4 tests.
464
        d_rev = b'd-rev'
6714.1.3 by Jelmer Vernooij
Add Repository.iter_revisions.
465
        repo = tree.branch.repository
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
466
        revision_ids = [a_rev, c_rev, b_rev, d_rev]
6714.1.3 by Jelmer Vernooij
Add Repository.iter_revisions.
467
        revid_with_rev = repo.iter_revisions(revision_ids)
468
        self.assertEqual(
469
            set((revid, rev.revision_id if rev is not None else None)
470
                for (revid, rev) in revid_with_rev),
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
471
            {(a_rev, a_rev),
472
             (b_rev, b_rev),
473
             (c_rev, c_rev),
474
             (d_rev, None)})
6714.1.3 by Jelmer Vernooij
Add Repository.iter_revisions.
475
1910.2.1 by Aaron Bentley
Ensure root entry always has a revision
476
    def test_root_entry_has_revision(self):
477
        tree = self.make_branch_and_tree('.')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
478
        revid = tree.commit('message')
2255.7.65 by Robert Collins
Split test_root_revision_entry into tree and repository portions.
479
        rev_tree = tree.branch.repository.revision_tree(tree.last_revision())
4253.3.1 by Robert Collins
per_repository/test_repository improvements (Robert Collins)
480
        rev_tree.lock_read()
481
        self.addCleanup(rev_tree.unlock)
7141.7.1 by Jelmer Vernooij
Get rid of file_ids in most of Tree.
482
        self.assertEqual(revid, rev_tree.get_file_revision(u''))
1910.2.36 by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats
483
1910.2.37 by Aaron Bentley
Handle empty commits, fix test
484
    def test_pointless_commit(self):
485
        tree = self.make_branch_and_tree('.')
6744 by Jelmer Vernooij
Merge lp:~jelmer/brz/move-errors-knit.
486
        self.assertRaises(commit.PointlessCommit, tree.commit, 'pointless',
1910.2.37 by Aaron Bentley
Handle empty commits, fix test
487
                          allow_pointless=False)
488
        tree.commit('pointless', allow_pointless=True)
489
2323.5.17 by Martin Pool
Add supports_tree_reference to all repo formats (robert)
490
    def test_format_attributes(self):
491
        """All repository formats should have some basic attributes."""
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
492
        # create a repository to get a real format instance, not the
3128.1.3 by Vincent Ladeuil
Since we are there s/parameteris.*/parameteriz&/.
493
        # template from the test suite parameterization.
2323.5.17 by Martin Pool
Add supports_tree_reference to all repo formats (robert)
494
        repo = self.make_repository('.')
495
        repo._format.rich_root_data
496
        repo._format.supports_tree_reference
497
2708.1.7 by Aaron Bentley
Rename extract_files_bytes to iter_files_bytes
498
    def test_iter_files_bytes(self):
2708.1.3 by Aaron Bentley
Implement extract_files_bytes on Repository
499
        tree = self.make_branch_and_tree('tree')
6855.4.1 by Jelmer Vernooij
Yet more bees.
500
        self.build_tree_contents([('tree/file1', b'foo'),
501
                                  ('tree/file2', b'bar')])
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
502
        tree.add(['file1', 'file2'])
503
        file1_id = tree.path2id('file1')
504
        file2_id = tree.path2id('file2')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
505
        rev1 = tree.commit('rev1')
6855.4.1 by Jelmer Vernooij
Yet more bees.
506
        self.build_tree_contents([('tree/file1', b'baz')])
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
507
        rev2 = tree.commit('rev2')
2708.1.11 by Aaron Bentley
Test and tweak error handling
508
        repository = tree.branch.repository
2592.3.214 by Robert Collins
Merge bzr.dev.
509
        repository.lock_read()
510
        self.addCleanup(repository.unlock)
7045.1.14 by Jelmer Vernooij
More fixes.
511
        extracted = dict((i, b''.join(b)) for i, b in
2708.1.11 by Aaron Bentley
Test and tweak error handling
512
                         repository.iter_files_bytes(
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
513
                         [(file1_id, rev1, 'file1-old'),
514
                          (file1_id, rev2, 'file1-new'),
515
                          (file2_id, rev1, 'file2'),
7143.15.2 by Jelmer Vernooij
Run autopep8.
516
                          ]))
7045.1.14 by Jelmer Vernooij
More fixes.
517
        self.assertEqual(b'foo', extracted['file1-old'])
518
        self.assertEqual(b'bar', extracted['file2'])
519
        self.assertEqual(b'baz', extracted['file1-new'])
2708.1.11 by Aaron Bentley
Test and tweak error handling
520
        self.assertRaises(errors.RevisionNotPresent, list,
521
                          repository.iter_files_bytes(
7143.15.2 by Jelmer Vernooij
Run autopep8.
522
                              [(file1_id, b'rev3', 'file1-notpresent')]))
2592.3.102 by Robert Collins
Change the iter_files_bytes error to allow either RevisionNotPresent or NoSuchId when requesting a file that was not in the repository at all.
523
        self.assertRaises((errors.RevisionNotPresent, errors.NoSuchId), list,
2708.1.11 by Aaron Bentley
Test and tweak error handling
524
                          repository.iter_files_bytes(
7045.1.14 by Jelmer Vernooij
More fixes.
525
                          [(b'file3-id', b'rev3', 'file1-notpresent')]))
2708.1.3 by Aaron Bentley
Implement extract_files_bytes on Repository
526
2850.4.1 by Andrew Bennetts
Add smoketest for repo.get_graph, and fix bug in RemoteRepository.get_graph that it reveals.
527
    def test_get_graph(self):
528
        """Bare-bones smoketest that all repositories implement get_graph."""
529
        repo = self.make_repository('repo')
2592.3.214 by Robert Collins
Merge bzr.dev.
530
        repo.lock_read()
531
        self.addCleanup(repo.unlock)
2850.4.1 by Andrew Bennetts
Add smoketest for repo.get_graph, and fix bug in RemoteRepository.get_graph that it reveals.
532
        repo.get_graph()
533
3146.1.1 by Aaron Bentley
Fix bad ghost handling in KnitParentsProvider
534
    def test_graph_ghost_handling(self):
6844.1.1 by Jelmer Vernooij
Many more foreign branch fixes.
535
        if not self.repository_format.supports_ghosts:
536
            raise tests.TestNotApplicable('format does not support ghosts')
3146.1.1 by Aaron Bentley
Fix bad ghost handling in KnitParentsProvider
537
        tree = self.make_branch_and_tree('here')
538
        tree.lock_write()
539
        self.addCleanup(tree.unlock)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
540
        rev1 = tree.commit('initial commit')
6973.10.4 by Jelmer Vernooij
Update python3.passing.
541
        tree.add_parent_tree_id(b'ghost')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
542
        rev2 = tree.commit('commit-with-ghost')
3146.1.1 by Aaron Bentley
Fix bad ghost handling in KnitParentsProvider
543
        graph = tree.branch.repository.get_graph()
7045.4.34 by Jelmer Vernooij
Fix some more tests.
544
        parents = graph.get_parent_map([b'ghost', rev2])
545
        self.assertTrue(b'ghost' not in parents)
546
        self.assertEqual(parents[rev2], (rev1, b'ghost'))
3146.1.2 by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists
547
4913.4.4 by Jelmer Vernooij
Add test for Repository.get_known_graph_ancestry().
548
    def test_get_known_graph_ancestry(self):
549
        tree = self.make_branch_and_tree('here')
550
        tree.lock_write()
551
        self.addCleanup(tree.unlock)
552
        # A
553
        # |\
554
        # | B
555
        # |/
556
        # C
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
557
        a = tree.commit('initial commit')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
558
        tree_other = tree.controldir.sprout('there').open_workingtree()
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
559
        b = tree_other.commit('another')
4913.4.4 by Jelmer Vernooij
Add test for Repository.get_known_graph_ancestry().
560
        tree.merge_from_branch(tree_other.branch)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
561
        c = tree.commit('another')
4913.4.4 by Jelmer Vernooij
Add test for Repository.get_known_graph_ancestry().
562
        kg = tree.branch.repository.get_known_graph_ancestry(
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
563
            [c])
564
        self.assertEqual([c], list(kg.heads([a, b, c])))
565
        self.assertEqual([a, b, c], list(kg.topo_sort()))
4913.4.4 by Jelmer Vernooij
Add test for Repository.get_known_graph_ancestry().
566
3146.1.2 by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists
567
    def test_parent_map_type(self):
568
        tree = self.make_branch_and_tree('here')
569
        tree.lock_write()
570
        self.addCleanup(tree.unlock)
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
571
        rev1 = tree.commit('initial commit')
572
        rev2 = tree.commit('next commit')
3146.1.2 by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists
573
        graph = tree.branch.repository.get_graph()
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
574
        parents = graph.get_parent_map(
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
575
            [_mod_revision.NULL_REVISION, rev1, rev2])
3146.1.2 by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists
576
        for value in parents.values():
577
            self.assertIsInstance(value, tuple)
3146.1.1 by Aaron Bentley
Fix bad ghost handling in KnitParentsProvider
578
2819.2.4 by Andrew Bennetts
Add a 'revision_graph_can_have_wrong_parents' method to repository.
579
    def test_implements_revision_graph_can_have_wrong_parents(self):
580
        """All repositories should implement
581
        revision_graph_can_have_wrong_parents, so that check and reconcile can
582
        work correctly.
583
        """
584
        repo = self.make_repository('.')
585
        # This should work, not raise NotImplementedError:
5766.1.2 by Jelmer Vernooij
Fix two more references to old method.
586
        if not repo._format.revision_graph_can_have_wrong_parents:
2592.3.214 by Robert Collins
Merge bzr.dev.
587
            return
588
        repo.lock_read()
589
        self.addCleanup(repo.unlock)
590
        # This repo must also implement
591
        # _find_inconsistent_revision_parents and
592
        # _check_for_inconsistent_revision_parents.  So calling these
593
        # should not raise NotImplementedError.
594
        list(repo._find_inconsistent_revision_parents())
595
        repo._check_for_inconsistent_revision_parents()
2819.2.4 by Andrew Bennetts
Add a 'revision_graph_can_have_wrong_parents' method to repository.
596
2996.2.4 by Aaron Bentley
Rename function to add_signature_text
597
    def test_add_signature_text(self):
5751.2.1 by Jelmer Vernooij
Add RepositoryFormat.supports_revision_signatures.
598
        builder = self.make_branch_builder('.')
599
        builder.start_series()
6819.1.2 by Jelmer Vernooij
Fix two revid-less tests.
600
        rev_a = builder.build_snapshot(None, [
6883.22.13 by Jelmer Vernooij
Actually pass in None file-ids to BranchBuilder.
601
            ('add', ('', None, 'directory', None))])
5751.2.2 by Jelmer Vernooij
Fix tests.
602
        builder.finish_series()
5751.2.1 by Jelmer Vernooij
Add RepositoryFormat.supports_revision_signatures.
603
        b = builder.get_branch()
5751.2.2 by Jelmer Vernooij
Fix tests.
604
        b.lock_write()
5751.2.4 by Jelmer Vernooij
Use addCleanup to call abort_write_group rather than try/finally.
605
        self.addCleanup(b.unlock)
606
        if b.repository._format.supports_revision_signatures:
6263.3.11 by Jelmer Vernooij
Fix get_signature_text test.
607
            b.repository.start_write_group()
7143.15.2 by Jelmer Vernooij
Run autopep8.
608
            b.repository.add_signature_text(
609
                rev_a, b'This might be a signature')
6263.3.11 by Jelmer Vernooij
Fix get_signature_text test.
610
            b.repository.commit_write_group()
7045.1.1 by Jelmer Vernooij
Fix another 300 tests.
611
            self.assertEqual(b'This might be a signature',
6819.1.2 by Jelmer Vernooij
Fix two revid-less tests.
612
                             b.repository.get_signature_text(rev_a))
5751.2.4 by Jelmer Vernooij
Use addCleanup to call abort_write_group rather than try/finally.
613
        else:
6263.3.11 by Jelmer Vernooij
Fix get_signature_text test.
614
            b.repository.start_write_group()
615
            self.addCleanup(b.repository.abort_write_group)
5751.2.4 by Jelmer Vernooij
Use addCleanup to call abort_write_group rather than try/finally.
616
            self.assertRaises(errors.UnsupportedOperation,
7143.15.2 by Jelmer Vernooij
Run autopep8.
617
                              b.repository.add_signature_text, rev_a,
618
                              b'This might be a signature')
2996.2.3 by Aaron Bentley
Add tests for install_revisions and add_signature
619
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
620
    # XXX: this helper duplicated from tests.test_repository
6164.2.2 by Jelmer Vernooij
Make shared argument default to 'None'.
621
    def make_remote_repository(self, path, shared=None):
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
622
        """Make a RemoteRepository object backed by a real repository that will
623
        be created at the given path."""
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
624
        repo = self.make_repository(path, shared=shared)
5017.3.42 by Vincent Ladeuil
-s bt.per_repository.test_repo passing
625
        smart_server = test_server.SmartTCPServer_for_testing()
4659.1.2 by Robert Collins
Refactor creation and shutdown of test servers to use a common helper,
626
        self.start_server(smart_server, self.get_server())
6083.1.1 by Jelmer Vernooij
Use get_transport_from_{url,path} in more places.
627
        remote_transport = transport.get_transport_from_url(
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
628
            smart_server.get_url()).clone(path)
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
629
        if not repo.controldir._format.supports_transport(remote_transport):
6205.3.2 by Jelmer Vernooij
Use supports_transport in per_repository.test_repository.
630
            raise tests.TestNotApplicable(
631
                "format does not support transport")
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
632
        remote_bzrdir = controldir.ControlDir.open_from_transport(
633
            remote_transport)
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
634
        remote_repo = remote_bzrdir.open_repository()
635
        return remote_repo
636
3047.1.2 by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format.
637
    def test_sprout_from_hpss_preserves_format(self):
638
        """repo.sprout from a smart server preserves the repository format."""
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
639
        remote_repo = self.make_remote_repository('remote')
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
640
        local_bzrdir = self.make_controldir('local')
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
641
        try:
642
            local_repo = remote_repo.sprout(local_bzrdir)
643
        except errors.TransportNotPossible:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
644
            raise tests.TestNotApplicable(
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
645
                "Cannot lock_read old formats like AllInOne over HPSS.")
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
646
        remote_backing_repo = controldir.ControlDir.open(
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
647
            self.get_vfs_only_url('remote')).open_repository()
6267.1.4 by Jelmer Vernooij
Fix test
648
        self.assertEqual(
649
            remote_backing_repo._format.network_name(),
650
            local_repo._format.network_name())
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
651
3047.1.2 by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format.
652
    def test_sprout_branch_from_hpss_preserves_repo_format(self):
653
        """branch.sprout from a smart server preserves the repository format.
654
        """
5674.1.1 by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat.
655
        if not self.repository_format.supports_leaving_lock:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
656
            raise tests.TestNotApplicable(
5674.1.1 by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat.
657
                "Format can not be used over HPSS")
3047.1.2 by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format.
658
        remote_repo = self.make_remote_repository('remote')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
659
        remote_branch = remote_repo.controldir.create_branch()
3047.1.2 by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format.
660
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
661
            local_bzrdir = remote_branch.controldir.sprout('local')
3047.1.2 by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format.
662
        except errors.TransportNotPossible:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
663
            raise tests.TestNotApplicable(
3047.1.2 by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format.
664
                "Cannot lock_read old formats like AllInOne over HPSS.")
665
        local_repo = local_bzrdir.open_repository()
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
666
        remote_backing_repo = controldir.ControlDir.open(
3047.1.2 by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format.
667
            self.get_vfs_only_url('remote')).open_repository()
668
        self.assertEqual(remote_backing_repo._format, local_repo._format)
669
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
670
    def test_sprout_branch_from_hpss_preserves_shared_repo_format(self):
671
        """branch.sprout from a smart server preserves the repository format of
672
        a branch from a shared repository.
673
        """
5674.1.1 by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat.
674
        if not self.repository_format.supports_leaving_lock:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
675
            raise tests.TestNotApplicable(
5674.1.1 by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat.
676
                "Format can not be used over HPSS")
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
677
        # Make a shared repo
678
        remote_repo = self.make_remote_repository('remote', shared=True)
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
679
        remote_backing_repo = controldir.ControlDir.open(
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
680
            self.get_vfs_only_url('remote')).open_repository()
681
        # Make a branch in that repo in an old format that isn't the default
682
        # branch format for the repo.
6670.4.1 by Jelmer Vernooij
Update imports.
683
        from breezy.bzr.fullhistory import BzrBranchFormat5
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
684
        format = remote_backing_repo.controldir.cloning_metadir()
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
685
        format._branch_format = BzrBranchFormat5()
7143.15.2 by Jelmer Vernooij
Run autopep8.
686
        remote_transport = remote_repo.controldir.root_transport.clone(
687
            'branch')
6207.3.3 by jelmer at samba
Fix tests and the like.
688
        controldir.ControlDir.create_branch_convenience(
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
689
            remote_transport.base, force_new_repo=False, format=format)
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
690
        remote_branch = controldir.ControlDir.open_from_transport(
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
691
            remote_transport).open_branch()
692
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
693
            local_bzrdir = remote_branch.controldir.sprout('local')
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
694
        except errors.TransportNotPossible:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
695
            raise tests.TestNotApplicable(
3697.6.2 by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server.
696
                "Cannot lock_read old formats like AllInOne over HPSS.")
697
        local_repo = local_bzrdir.open_repository()
698
        self.assertEqual(remote_backing_repo._format, local_repo._format)
699
4118.1.1 by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests.
700
    def test_clone_to_hpss(self):
5674.1.1 by Jelmer Vernooij
Add supports_leave_lock flag to BranchFormat and RepositoryFormat.
701
        if not self.repository_format.supports_leaving_lock:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
702
            raise tests.TestNotApplicable(
4118.1.1 by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests.
703
                "Cannot lock pre_metadir_formats remotely.")
704
        remote_transport = self.make_smart_server('remote')
705
        local_branch = self.make_branch('local')
7143.15.2 by Jelmer Vernooij
Run autopep8.
706
        remote_branch = local_branch.create_clone_on_transport(
707
            remote_transport)
4118.1.1 by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests.
708
        self.assertEqual(
709
            local_branch.repository._format.supports_external_lookups,
710
            remote_branch.repository._format.supports_external_lookups)
711
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
712
    def test_clone_stacking_policy_upgrades(self):
713
        """Cloning an unstackable branch format to somewhere with a default
714
        stack-on branch upgrades branch and repo to match the target and honour
715
        the policy.
3904.3.8 by Andrew Bennetts
Add test requested by John, and fix whitespace nit.
716
        """
717
        try:
718
            repo = self.make_repository('repo', shared=True)
719
        except errors.IncompatibleFormat:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
720
            raise tests.TestNotApplicable('Cannot make a shared repository')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
721
        if repo.controldir._format.fixed_components:
6050.1.2 by Martin
Make tests raising KnownFailure use the knownFailure method instead
722
            self.knownFailure(
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
723
                "pre metadir branches do not upgrade on push "
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
724
                "with stacking policy")
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
725
        if isinstance(repo._format,
5757.1.5 by Jelmer Vernooij
Fix import.
726
                      knitpack_repo.RepositoryFormatKnitPack5RichRootBroken):
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
727
            raise tests.TestNotApplicable("unsupported format")
3904.3.8 by Andrew Bennetts
Add test requested by John, and fix whitespace nit.
728
        # Make a source branch in 'repo' in an unstackable branch format
6746.2.1 by Jelmer Vernooij
Rename matchingbzrdir to matchingcontroldir.
729
        bzrdir_format = self.repository_format._matchingcontroldir
3904.3.8 by Andrew Bennetts
Add test requested by John, and fix whitespace nit.
730
        transport = self.get_transport('repo/branch')
731
        transport.mkdir('.')
732
        target_bzrdir = bzrdir_format.initialize_on_transport(transport)
6653.1.2 by Jelmer Vernooij
Fix imports.
733
        branch = _mod_bzrbranch.BzrBranchFormat6().initialize(target_bzrdir)
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
734
        # Ensure that stack_on will be stackable and match the serializer of
735
        # repo.
736
        if isinstance(repo, remote.RemoteRepository):
737
            repo._ensure_real()
738
            info_repo = repo._real_repository
4599.4.40 by Robert Collins
Fix formats for per_repository upgrade-to-stacking test.
739
        else:
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
740
            info_repo = repo
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
741
        format_description = info.describe_format(info_repo.controldir,
7143.15.2 by Jelmer Vernooij
Run autopep8.
742
                                                  info_repo, None, None)
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
743
        formats = format_description.split(' or ')
744
        stack_on_format = formats[0]
745
        if stack_on_format in ["pack-0.92", "dirstate", "metaweave"]:
746
            stack_on_format = "1.9"
747
        elif stack_on_format in ["dirstate-with-subtree", "rich-root",
7143.15.2 by Jelmer Vernooij
Run autopep8.
748
                                 "rich-root-pack", "pack-0.92-subtree"]:
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
749
            stack_on_format = "1.9-rich-root"
750
        # formats not tested for above are already stackable, so we can use the
751
        # format as-is.
752
        stack_on = self.make_branch('stack-on-me', format=stack_on_format)
7143.15.2 by Jelmer Vernooij
Run autopep8.
753
        self.make_controldir('.').get_config(
754
        ).set_default_stack_on('stack-on-me')
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
755
        target = branch.controldir.clone(self.get_url('target'))
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
756
        # The target branch supports stacking.
757
        self.assertTrue(target.open_branch()._format.supports_stacking())
3904.3.8 by Andrew Bennetts
Add test requested by John, and fix whitespace nit.
758
        if isinstance(repo, remote.RemoteRepository):
759
            repo._ensure_real()
760
            repo = repo._real_repository
4005.2.1 by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test.
761
        target_repo = target.open_repository()
762
        if isinstance(target_repo, remote.RemoteRepository):
763
            target_repo._ensure_real()
764
            target_repo = target_repo._real_repository
4599.4.45 by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests.
765
        # The repository format is unchanged if it could already stack, or the
766
        # same as the stack on.
767
        if repo._format.supports_external_lookups:
768
            self.assertEqual(repo._format, target_repo._format)
769
        else:
770
            self.assertEqual(stack_on.repository._format, target_repo._format)
3904.3.8 by Andrew Bennetts
Add test requested by John, and fix whitespace nit.
771
3089.2.1 by Andrew Bennetts
Implement RemoteRepository._make_parents_provider.
772
    def test__make_parents_provider(self):
773
        """Repositories must have a _make_parents_provider method that returns
3099.3.5 by John Arbash Meinel
Update the last couple of places that referred to Provider.get_parents() directly.
774
        an object with a get_parent_map method.
3089.2.1 by Andrew Bennetts
Implement RemoteRepository._make_parents_provider.
775
        """
776
        repo = self.make_repository('repo')
3099.3.5 by John Arbash Meinel
Update the last couple of places that referred to Provider.get_parents() directly.
777
        repo._make_parents_provider().get_parent_map
3089.2.1 by Andrew Bennetts
Implement RemoteRepository._make_parents_provider.
778
6150.2.2 by Jelmer Vernooij
Make various make_repository methods default their shared setting to None.
779
    def make_repository_and_foo_bar(self, shared=None):
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
780
        made_control = self.make_controldir('repository')
3140.1.2 by Aaron Bentley
Add ability to find branches inside repositories
781
        repo = made_control.create_repository(shared=shared)
6145.2.1 by Jelmer Vernooij
Add RepositoryFormat.supports_nesting_repositories.
782
        if not repo._format.supports_nesting_repositories:
783
            raise tests.TestNotApplicable("repository does not support "
7143.15.2 by Jelmer Vernooij
Run autopep8.
784
                                          "nesting repositories")
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
785
        controldir.ControlDir.create_branch_convenience(
786
            self.get_url('repository/foo'), force_new_repo=False)
787
        controldir.ControlDir.create_branch_convenience(
788
            self.get_url('repository/bar'), force_new_repo=True)
6653.6.5 by Jelmer Vernooij
Rename make_bzrdir to make_controldir.
789
        baz = self.make_controldir('repository/baz')
3140.1.3 by Aaron Bentley
Add support for finding branches to BzrDir
790
        qux = self.make_branch('repository/baz/qux')
3140.1.6 by Aaron Bentley
Add test that nested branches are returned
791
        quxx = self.make_branch('repository/baz/qux/quxx')
3140.1.2 by Aaron Bentley
Add ability to find branches inside repositories
792
        return repo
793
794
    def test_find_branches(self):
6150.2.2 by Jelmer Vernooij
Make various make_repository methods default their shared setting to None.
795
        repo = self.make_repository_and_foo_bar()
7358.5.1 by Jelmer Vernooij
Make Repository.find_branches an iterator.
796
        branches = list(repo.find_branches())
3140.1.2 by Aaron Bentley
Add ability to find branches inside repositories
797
        self.assertContainsRe(branches[-1].base, 'repository/foo/$')
3140.1.6 by Aaron Bentley
Add test that nested branches are returned
798
        self.assertContainsRe(branches[-3].base, 'repository/baz/qux/$')
799
        self.assertContainsRe(branches[-2].base, 'repository/baz/qux/quxx/$')
3140.1.2 by Aaron Bentley
Add ability to find branches inside repositories
800
        # in some formats, creating a repo creates a branch
3140.1.6 by Aaron Bentley
Add test that nested branches are returned
801
        if len(branches) == 6:
802
            self.assertContainsRe(branches[-4].base, 'repository/baz/$')
803
            self.assertContainsRe(branches[-5].base, 'repository/bar/$')
804
            self.assertContainsRe(branches[-6].base, 'repository/$')
805
        else:
806
            self.assertEqual(4, len(branches))
3140.1.3 by Aaron Bentley
Add support for finding branches to BzrDir
807
            self.assertContainsRe(branches[-4].base, 'repository/bar/$')
3140.1.2 by Aaron Bentley
Add ability to find branches inside repositories
808
809
    def test_find_branches_using(self):
810
        try:
811
            repo = self.make_repository_and_foo_bar(shared=True)
812
        except errors.IncompatibleFormat:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
813
            raise tests.TestNotApplicable
7358.5.1 by Jelmer Vernooij
Make Repository.find_branches an iterator.
814
        branches = list(repo.find_branches(using=True))
3140.1.2 by Aaron Bentley
Add ability to find branches inside repositories
815
        self.assertContainsRe(branches[-1].base, 'repository/foo/$')
816
        # in some formats, creating a repo creates a branch
817
        if len(branches) == 2:
818
            self.assertContainsRe(branches[-2].base, 'repository/$')
819
        else:
820
            self.assertEqual(1, len(branches))
821
3140.1.9 by Aaron Bentley
Optimize find_branches for standalone repositories
822
    def test_find_branches_using_standalone(self):
823
        branch = self.make_branch('branch')
6145.2.1 by Jelmer Vernooij
Add RepositoryFormat.supports_nesting_repositories.
824
        if not branch.repository._format.supports_nesting_repositories:
825
            raise tests.TestNotApplicable("format does not support nesting "
7143.15.2 by Jelmer Vernooij
Run autopep8.
826
                                          "repositories")
3140.1.9 by Aaron Bentley
Optimize find_branches for standalone repositories
827
        contained = self.make_branch('branch/contained')
828
        branches = branch.repository.find_branches(using=True)
829
        self.assertEqual([branch.base], [b.base for b in branches])
830
        branches = branch.repository.find_branches(using=False)
831
        self.assertEqual([branch.base, contained.base],
832
                         [b.base for b in branches])
833
834
    def test_find_branches_using_empty_standalone_repo(self):
6164.2.2 by Jelmer Vernooij
Make shared argument default to 'None'.
835
        try:
836
            repo = self.make_repository('repo', shared=False)
837
        except errors.IncompatibleFormat:
838
            raise tests.TestNotApplicable("format does not support standalone "
7143.15.2 by Jelmer Vernooij
Run autopep8.
839
                                          "repositories")
3140.1.9 by Aaron Bentley
Optimize find_branches for standalone repositories
840
        try:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
841
            repo.controldir.open_branch()
3140.1.9 by Aaron Bentley
Optimize find_branches for standalone repositories
842
        except errors.NotBranchError:
7358.5.1 by Jelmer Vernooij
Make Repository.find_branches an iterator.
843
            self.assertEqual([], list(repo.find_branches(using=True)))
3140.1.9 by Aaron Bentley
Optimize find_branches for standalone repositories
844
        else:
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
845
            self.assertEqual([repo.controldir.root_transport.base],
3140.1.9 by Aaron Bentley
Optimize find_branches for standalone repositories
846
                             [b.base for b in repo.find_branches(using=True)])
847
3349.1.1 by Aaron Bentley
Enable setting and getting make_working_trees for all repositories
848
    def test_set_get_make_working_trees_true(self):
849
        repo = self.make_repository('repo')
3349.1.2 by Aaron Bentley
Change ValueError to RepositoryUpgradeRequired
850
        try:
851
            repo.set_make_working_trees(True)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
852
        except (errors.RepositoryUpgradeRequired, errors.UnsupportedOperation) as e:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
853
            raise tests.TestNotApplicable('Format does not support this flag.')
3349.1.1 by Aaron Bentley
Enable setting and getting make_working_trees for all repositories
854
        self.assertTrue(repo.make_working_trees())
855
856
    def test_set_get_make_working_trees_false(self):
857
        repo = self.make_repository('repo')
858
        try:
859
            repo.set_make_working_trees(False)
6619.3.2 by Jelmer Vernooij
Apply 2to3 except fix.
860
        except (errors.RepositoryUpgradeRequired, errors.UnsupportedOperation) as e:
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
861
            raise tests.TestNotApplicable('Format does not support this flag.')
3349.1.2 by Aaron Bentley
Change ValueError to RepositoryUpgradeRequired
862
        self.assertFalse(repo.make_working_trees())
3349.1.1 by Aaron Bentley
Enable setting and getting make_working_trees for all repositories
863
3047.1.1 by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format.
864
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
865
class TestRepositoryLocking(per_repository.TestCaseWithRepository):
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
866
867
    def test_leave_lock_in_place(self):
868
        repo = self.make_repository('r')
869
        # Lock the repository, then use leave_lock_in_place so that when we
870
        # unlock the repository the lock is still held on disk.
5200.3.3 by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
871
        token = repo.lock_write().repository_token
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
872
        try:
2018.5.76 by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None.
873
            if token is None:
874
                # This test does not apply, because this repository refuses lock
875
                # tokens.
7143.15.2 by Jelmer Vernooij
Run autopep8.
876
                self.assertRaises(NotImplementedError,
877
                                  repo.leave_lock_in_place)
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
878
                return
2018.5.76 by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None.
879
            repo.leave_lock_in_place()
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
880
        finally:
881
            repo.unlock()
882
        # We should be unable to relock the repo.
883
        self.assertRaises(errors.LockContention, repo.lock_write)
4327.1.8 by Vincent Ladeuil
Fix 4 more lock-related test failures.
884
        # Cleanup
885
        repo.lock_write(token)
886
        repo.dont_leave_lock_in_place()
887
        repo.unlock()
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
888
889
    def test_dont_leave_lock_in_place(self):
890
        repo = self.make_repository('r')
891
        # Create a lock on disk.
5200.3.3 by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
892
        token = repo.lock_write().repository_token
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
893
        try:
894
            if token is None:
895
                # This test does not apply, because this repository refuses lock
896
                # tokens.
2018.5.76 by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None.
897
                self.assertRaises(NotImplementedError,
898
                                  repo.dont_leave_lock_in_place)
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
899
                return
900
            try:
901
                repo.leave_lock_in_place()
902
            except NotImplementedError:
903
                # This repository doesn't support this API.
904
                return
905
        finally:
906
            repo.unlock()
907
        # Reacquire the lock (with a different repository object) by using the
908
        # token.
6653.6.1 by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir.
909
        new_repo = repo.controldir.open_repository()
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
910
        new_repo.lock_write(token=token)
911
        # Call dont_leave_lock_in_place, so that the lock will be released by
912
        # this instance, even though the lock wasn't originally acquired by it.
913
        new_repo.dont_leave_lock_in_place()
914
        new_repo.unlock()
915
        # Now the repository is unlocked.  Test this by locking it (without a
916
        # token).
917
        repo.lock_write()
918
        repo.unlock()
919
2018.5.78 by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the
920
    def test_lock_read_then_unlock(self):
921
        # Calling lock_read then unlocking should work without errors.
922
        repo = self.make_repository('r')
923
        repo.lock_read()
924
        repo.unlock()
925
5200.3.3 by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now
926
    def test_lock_read_returns_unlockable(self):
927
        repo = self.make_repository('r')
928
        self.assertThat(repo.lock_read, ReturnsUnlockable(repo))
929
930
    def test_lock_write_returns_unlockable(self):
931
        repo = self.make_repository('r')
932
        self.assertThat(repo.lock_write, ReturnsUnlockable(repo))
933
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
934
2018.5.29 by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point.
935
# FIXME: document why this is a TestCaseWithTransport rather than a
936
#        TestCaseWithRepository
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
937
class TestEscaping(tests.TestCaseWithTransport):
1986.1.1 by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat.
938
    """Test that repositories can be stored correctly on VFAT transports.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
939
1986.1.1 by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat.
940
    Makes sure we have proper escaping of invalid characters, etc.
941
942
    It'd be better to test all operations on the FakeVFATTransportDecorator,
943
    but working trees go straight to the os not through the Transport layer.
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
944
    Therefore we build some history first in the regular way and then
1986.1.1 by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat.
945
    check it's safe to access for vfat.
946
    """
947
948
    def test_on_vfat(self):
2018.5.29 by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point.
949
        # dont bother with remote repository testing, because this test is
950
        # about local disk layout/support.
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
951
        if isinstance(self.repository_format, remote.RemoteRepositoryFormat):
2018.5.29 by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point.
952
            return
5017.3.42 by Vincent Ladeuil
-s bt.per_repository.test_repo passing
953
        self.transport_server = test_server.FakeVFATServer
6973.6.1 by Jelmer Vernooij
More bees.
954
        FOO_ID = b'foo<:>ID'
3943.8.1 by Marius Kruger
remove all trailing whitespace from bzr source
955
        # this makes a default format repository always, which is wrong:
956
        # it should be a TestCaseWithRepository in order to get the
2018.5.29 by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point.
957
        # default format.
1986.1.1 by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat.
958
        wt = self.make_branch_and_tree('repo')
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
959
        if not wt.supports_setting_file_ids():
960
            self.skip("format does not support setting file ids")
2052.2.1 by Alexander Belchenko
test_on_vfat win32 fix: use binary line-endings
961
        self.build_tree(["repo/foo"], line_endings='binary')
1986.1.1 by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat.
962
        # add file with id containing wierd characters
963
        wt.add(['foo'], [FOO_ID])
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
964
        rev1 = wt.commit('this is my new commit')
1986.1.1 by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat.
965
        # now access over vfat; should be safe
6207.3.8 by Jelmer Vernooij
Fix a bunch of tests.
966
        branch = controldir.ControlDir.open(self.get_url('repo')).open_branch()
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
967
        revtree = branch.repository.revision_tree(rev1)
3015.2.13 by Robert Collins
More lock correctness for the use of get_file_text in repository_implementations.
968
        revtree.lock_read()
969
        self.addCleanup(revtree.unlock)
7141.7.1 by Jelmer Vernooij
Get rid of file_ids in most of Tree.
970
        contents = revtree.get_file_text('foo')
6973.6.1 by Jelmer Vernooij
More bees.
971
        self.assertEqual(contents, b'contents of repo/foo\n')
2520.4.54 by Aaron Bentley
Hang a create_bundle method off repository
972
973
    def test_create_bundle(self):
974
        wt = self.make_branch_and_tree('repo')
975
        self.build_tree(['repo/file1'])
976
        wt.add('file1')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
977
        rev1 = wt.commit('file1')
6621.22.2 by Martin
Use BytesIO or StringIO from bzrlib.sixish
978
        fileobj = BytesIO()
5010.2.6 by Vincent Ladeuil
Fix per_repository/test_repository.py imports.
979
        wt.branch.repository.create_bundle(
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
980
            rev1, _mod_revision.NULL_REVISION, fileobj)
5158.6.4 by Martin Pool
Repository implements ControlComponent too
981
982
983
class TestRepositoryControlComponent(per_repository.TestCaseWithRepository):
984
    """Repository implementations adequately implement ControlComponent."""
5673.1.1 by Jelmer Vernooij
Add flexible_components boolean to ControlDir if the
985
5158.6.4 by Martin Pool
Repository implements ControlComponent too
986
    def test_urls(self):
987
        repo = self.make_repository('repo')
988
        self.assertIsInstance(repo.user_url, str)
989
        self.assertEqual(repo.user_url, repo.user_transport.base)
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
990
        # for all current bzrdir implementations the user dir must be
5158.6.4 by Martin Pool
Repository implements ControlComponent too
991
        # above the control dir but we might need to relax that?
992
        self.assertEqual(repo.control_url.find(repo.user_url), 0)
993
        self.assertEqual(repo.control_url, repo.control_transport.base)
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
994
995
996
class TestDeltaRevisionFiltered(per_repository.TestCaseWithRepository):
997
998
    def setUp(self):
999
        super(TestDeltaRevisionFiltered, self).setUp()
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
1000
        self.tree_a = self.make_branch_and_tree('a')
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1001
        self.build_tree(['a/foo', 'a/bar/', 'a/bar/b1', 'a/bar/b2', 'a/baz'])
6772.2.1 by Jelmer Vernooij
Avoid setting file ids in a few more cases.
1002
        self.tree_a.add(['foo', 'bar', 'bar/b1', 'bar/b2', 'baz'])
1003
        self.bar_id = self.tree_a.path2id('bar')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
1004
        self.rev1 = self.tree_a.commit('rev1')
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1005
        self.build_tree(['a/bar/b3'])
6772.2.1 by Jelmer Vernooij
Avoid setting file ids in a few more cases.
1006
        self.tree_a.add('bar/b3')
6747.3.1 by Jelmer Vernooij
Avoid more uses of revision_id.
1007
        self.rev2 = self.tree_a.commit('rev2')
6745.1.1 by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking
1008
        self.repository = self.tree_a.branch.repository
7358.15.3 by Jelmer Vernooij
Fix tests.
1009
        self.addCleanup(self.repository.lock_read().unlock)
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1010
1011
    def test_multiple_files(self):
1012
        # Test multiple files
7358.15.1 by Jelmer Vernooij
Remove speciic_fileids argument from Repository.get_revision_delta.
1013
        delta = list(self.repository.get_deltas_for_revisions(
7358.15.3 by Jelmer Vernooij
Fix tests.
1014
            [self.repository.get_revision(self.rev1)], specific_fileids=[
7143.15.2 by Jelmer Vernooij
Run autopep8.
1015
                self.tree_a.path2id('foo'),
7358.15.1 by Jelmer Vernooij
Remove speciic_fileids argument from Repository.get_revision_delta.
1016
                self.tree_a.path2id('baz')]))[0]
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1017
        self.assertIsInstance(delta, _mod_delta.TreeDelta)
1018
        self.assertEqual([
7358.11.3 by Jelmer Vernooij
TreeDelta holds TreeChange objects rather than tuples of various sizes.
1019
            ('baz', 'file'),
1020
            ('foo', 'file'),
1021
            ], [(c.path[1], c.kind[1]) for c in delta.added])
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1022
1023
    def test_directory(self):
1024
        # Test a directory
7358.15.1 by Jelmer Vernooij
Remove speciic_fileids argument from Repository.get_revision_delta.
1025
        delta = list(self.repository.get_deltas_for_revisions(
7358.15.3 by Jelmer Vernooij
Fix tests.
1026
            [self.repository.get_revision(self.rev1)],
1027
            specific_fileids=[self.bar_id]))[0]
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1028
        self.assertIsInstance(delta, _mod_delta.TreeDelta)
1029
        self.assertEqual([
7358.11.3 by Jelmer Vernooij
TreeDelta holds TreeChange objects rather than tuples of various sizes.
1030
            ('bar', 'directory'),
1031
            ('bar/b1', 'file'),
1032
            ('bar/b2', 'file'),
1033
            ], [(c.path[1], c.kind[1]) for c in delta.added])
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1034
1035
    def test_unrelated(self):
1036
        # Try another revision
7358.15.1 by Jelmer Vernooij
Remove speciic_fileids argument from Repository.get_revision_delta.
1037
        delta = list(self.repository.get_deltas_for_revisions(
7358.15.3 by Jelmer Vernooij
Fix tests.
1038
            [self.repository.get_revision(self.rev2)],
1039
            specific_fileids=[self.tree_a.path2id('foo')]))[0]
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1040
        self.assertIsInstance(delta, _mod_delta.TreeDelta)
1041
        self.assertEqual([], delta.added)
1042
1043
    def test_file_in_directory(self):
1044
        # Test a file in a directory, both of which were added
7358.15.1 by Jelmer Vernooij
Remove speciic_fileids argument from Repository.get_revision_delta.
1045
        delta = list(self.repository.get_deltas_for_revisions(
7358.15.3 by Jelmer Vernooij
Fix tests.
1046
            [self.repository.get_revision(self.rev1)],
1047
            specific_fileids=[self.tree_a.path2id('bar/b2')]))[0]
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1048
        self.assertIsInstance(delta, _mod_delta.TreeDelta)
1049
        self.assertEqual([
7358.11.3 by Jelmer Vernooij
TreeDelta holds TreeChange objects rather than tuples of various sizes.
1050
            ('bar', 'directory'),
1051
            ('bar/b2', 'file'),
1052
            ], [(c.path[1], c.kind[1]) for c in delta.added])
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1053
1054
    def test_file_in_unchanged_directory(self):
7358.15.1 by Jelmer Vernooij
Remove speciic_fileids argument from Repository.get_revision_delta.
1055
        delta = list(self.repository.get_deltas_for_revisions(
7358.15.3 by Jelmer Vernooij
Fix tests.
1056
            [self.repository.get_revision(self.rev2)],
1057
            specific_fileids=[self.tree_a.path2id('bar/b3')]))[0]
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1058
        self.assertIsInstance(delta, _mod_delta.TreeDelta)
7358.11.3 by Jelmer Vernooij
TreeDelta holds TreeChange objects rather than tuples of various sizes.
1059
        if [(c.path[1], c.kind[1]) for c in delta.added] == [
1060
                ('bar', 'directory'), ('bar/b3', 'file')]:
6227.1.1 by Jelmer Vernooij
Add knownFailure for incorrect behaviour in Repository.get_revision_delta().
1061
            self.knownFailure("bzr incorrectly reports 'bar' as added - "
1062
                              "bug 878217")
1063
        self.assertEqual([
7358.11.3 by Jelmer Vernooij
TreeDelta holds TreeChange objects rather than tuples of various sizes.
1064
            ('bar/b3', 'file'),
1065
            ], [(c.path[1], c.kind[1]) for c in delta.added])