/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2241.1.5 by Martin Pool
Move KnitFormat2 into repofmt
1
# Copyright (C) 2005, 2006, 2007 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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Tests for bzrdir implementations - tests a bzrdir format."""
18
1666.1.6 by Robert Collins
Make knit the default format.
19
import re
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
20
1534.1.31 by Robert Collins
Deprecated fetch.fetch and fetch.greedy_fetch for branch.fetch, and move the Repository.fetch internals to InterRepo and InterWeaveRepo.
21
import bzrlib
1752.2.87 by Andrew Bennetts
Make tests pass.
22
from bzrlib import (
23
    bzrdir,
24
    errors,
25
    remote,
26
    repository,
27
    )
1852.10.3 by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib.
28
from bzrlib.delta import TreeDelta
1731.1.33 by Aaron Bentley
Revert no-special-root changes
29
from bzrlib.inventory import Inventory, InventoryDirectory
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
30
from bzrlib.revision import NULL_REVISION
2279.7.9 by Andrew Bennetts
Remove some redundant code pointed out by Robert's review, and remove some unused imports while I'm there.
31
from bzrlib.tests import TestCaseWithTransport, TestSkipped
2485.7.1 by Robert Collins
Relocate TestCaseWithRepository to be more central.
32
from bzrlib.tests.repository_implementations import TestCaseWithRepository
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
33
from bzrlib.transport import get_transport
34
from bzrlib.upgrade import upgrade
35
from bzrlib.workingtree import WorkingTree
36
37
2018.5.66 by Wouter van Heyst
Fix repository test parameterization for RemoteRepository.
38
class TestRepositoryMakeBranchAndTree(TestCaseWithRepository):
39
40
    def test_repository_format(self):
2018.5.119 by Robert Collins
Unbreak TestRepositoryMakeBranchAndTree.
41
        # make sure the repository on tree.branch is of the desired format,
42
        # because developers use this api to setup the tree, branch and 
43
        # repository for their tests: having it now give the right repository
44
        # type would invalidate the tests.
2018.5.66 by Wouter van Heyst
Fix repository test parameterization for RemoteRepository.
45
        tree = self.make_branch_and_tree('repo')
46
        self.assertIsInstance(tree.branch.repository._format,
47
            self.repository_format.__class__)
2381.1.1 by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's.
48
49
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
50
class TestRepository(TestCaseWithRepository):
51
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.
52
    def test_clone_to_default_format(self):
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
53
        #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.
54
        # such as signatures[not tested yet] etc etc.
55
        # when changing to the current default format.
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
56
        tree_a = self.make_branch_and_tree('a')
2381.1.3 by Robert Collins
Review feedback.
57
        self.build_tree(['a/foo'])
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
58
        tree_a.add('foo', 'file1')
59
        tree_a.commit('rev1', rev_id='rev1')
60
        bzrdirb = self.make_bzrdir('b')
61
        repo_b = tree_a.branch.repository.clone(bzrdirb)
62
        tree_b = repo_b.revision_tree('rev1')
63
        tree_b.get_file_text('file1')
64
        rev1 = repo_b.get_revision('rev1')
65
1910.2.63 by Aaron Bentley
Add supports_rich_root member to repository
66
    def test_supports_rich_root(self):
67
        tree = self.make_branch_and_tree('a')
68
        tree.commit('')
69
        second_revision = tree.commit('')
70
        inv = tree.branch.repository.revision_tree(second_revision).inventory
71
        rich_root = (inv.root.revision != second_revision)
2018.5.113 by Robert Collins
Test only fixes from the ported-to-bzr.dev test-correctness branch.
72
        self.assertEqual(rich_root,
1910.2.63 by Aaron Bentley
Add supports_rich_root member to repository
73
                         tree.branch.repository.supports_rich_root())
74
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
75
    def test_clone_specific_format(self):
76
        """todo"""
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
77
78
    def test_format_initialize_find_open(self):
79
        # loopback test to check the current format initializes to itself.
80
        if not self.repository_format.is_supported():
81
            # unsupported formats are not loopback testable
82
            # because the default open will not open them and
83
            # they may not be initializable.
84
            return
85
        # supported formats must be able to init and open
86
        t = get_transport(self.get_url())
87
        readonly_t = get_transport(self.get_readonly_url())
88
        made_control = self.bzrdir_format.initialize(t.base)
89
        made_repo = self.repository_format.initialize(made_control)
90
        self.assertEqual(made_control, made_repo.bzrdir)
91
92
        # find it via bzrdir opening:
93
        opened_control = bzrdir.BzrDir.open(readonly_t.base)
94
        direct_opened_repo = opened_control.open_repository()
95
        self.assertEqual(direct_opened_repo.__class__, made_repo.__class__)
96
        self.assertEqual(opened_control, direct_opened_repo.bzrdir)
97
1752.2.52 by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories.
98
        self.assertIsInstance(direct_opened_repo._format,
99
                              self.repository_format.__class__)
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
100
        # find it via Repository.open
101
        opened_repo = repository.Repository.open(readonly_t.base)
102
        self.failUnless(isinstance(opened_repo, made_repo.__class__))
103
        self.assertEqual(made_repo._format.__class__,
104
                         opened_repo._format.__class__)
105
        # if it has a unique id string, can we probe for it ?
106
        try:
107
            self.repository_format.get_format_string()
108
        except NotImplementedError:
109
            return
110
        self.assertEqual(self.repository_format,
111
                         repository.RepositoryFormat.find_format(opened_control))
112
113
    def test_create_repository(self):
1534.6.1 by Robert Collins
allow API creation of shared repositories
114
        # 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.
115
        if not self.bzrdir_format.is_supported():
116
            # unsupported formats are not loopback testable
117
            # because the default open will not open them and
118
            # they may not be initializable.
119
            return
120
        t = get_transport(self.get_url())
121
        made_control = self.bzrdir_format.initialize(t.base)
122
        made_repo = made_control.create_repository()
1752.2.50 by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree}
123
        # Check that we have a repository object.
124
        made_repo.has_revision('foo')
1534.4.40 by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used.
125
        self.assertEqual(made_control, made_repo.bzrdir)
1534.6.1 by Robert Collins
allow API creation of shared repositories
126
        
127
    def test_create_repository_shared(self):
128
        # bzrdir can construct a shared repository.
129
        if not self.bzrdir_format.is_supported():
130
            # unsupported formats are not loopback testable
131
            # because the default open will not open them and
132
            # they may not be initializable.
133
            return
134
        t = get_transport(self.get_url())
135
        made_control = self.bzrdir_format.initialize(t.base)
136
        try:
137
            made_repo = made_control.create_repository(shared=True)
138
        except errors.IncompatibleFormat:
139
            # not all repository formats understand being shared, or
140
            # may only be shared in some circumstances.
141
            return
1752.2.50 by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree}
142
        # Check that we have a repository object.
143
        made_repo.has_revision('foo')
1534.6.1 by Robert Collins
allow API creation of shared repositories
144
        self.assertEqual(made_control, made_repo.bzrdir)
1534.6.3 by Robert Collins
find_repository sufficiently robust.
145
        self.assertTrue(made_repo.is_shared())
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
146
147
    def test_revision_tree(self):
148
        wt = self.make_branch_and_tree('.')
1731.1.33 by Aaron Bentley
Revert no-special-root changes
149
        wt.set_root_id('fixed-root')
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
150
        wt.commit('lala!', rev_id='revision-1', allow_pointless=True)
151
        tree = wt.branch.repository.revision_tree('revision-1')
1731.1.45 by Aaron Bentley
Merge bzr.dev
152
        self.assertEqual('revision-1', tree.inventory.root.revision) 
153
        expected = InventoryDirectory('fixed-root', '', None)
154
        expected.revision = 'revision-1'
155
        self.assertEqual([('', 'V', 'directory', 'fixed-root', expected)],
1731.1.54 by Aaron Bentley
Fix revision_tree tests
156
                         list(tree.list_files(include_root=True)))
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
157
        tree = wt.branch.repository.revision_tree(None)
1731.1.54 by Aaron Bentley
Fix revision_tree tests
158
        self.assertEqual([], list(tree.list_files(include_root=True)))
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
159
        tree = wt.branch.repository.revision_tree(NULL_REVISION)
1731.1.54 by Aaron Bentley
Fix revision_tree tests
160
        self.assertEqual([], list(tree.list_files(include_root=True)))
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
161
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.
162
    def test_fetch(self):
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
163
        # smoke test fetch to ensure that the convenience function works.
164
        # it is defined as a convenience function with the underlying 
165
        # functionality provided by an InterRepository
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
166
        tree_a = self.make_branch_and_tree('a')
2381.1.3 by Robert Collins
Review feedback.
167
        self.build_tree(['a/foo'])
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
168
        tree_a.add('foo', 'file1')
169
        tree_a.commit('rev1', rev_id='rev1')
1534.1.29 by Robert Collins
Add a test environment for InterRepository objects, and remove the fetch corner case tests from test_repository.
170
        # fetch with a default limit (grab everything)
171
        repo = bzrdir.BzrDir.create_repository(self.get_url('b'))
2305.2.1 by Andrew Bennetts
Use repo.supports_rich_root() everywhere rather than
172
        if (tree_a.branch.repository.supports_rich_root() and not
173
            repo.supports_rich_root()):
1910.2.26 by Aaron Bentley
Fix up some test cases
174
            raise TestSkipped('Cannot fetch from model2 to model1')
1534.1.31 by Robert Collins
Deprecated fetch.fetch and fetch.greedy_fetch for branch.fetch, and move the Repository.fetch internals to InterRepo and InterWeaveRepo.
175
        repo.fetch(tree_a.branch.repository,
176
                   revision_id=None,
177
                   pb=bzrlib.progress.DummyProgress())
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
178
2018.5.118 by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference.
179
    def test_fetch_knit3(self):
180
        # create a repository of the sort we are testing.
2100.3.20 by Aaron Bentley
Implement tree comparison for tree references
181
        tree_a = self.make_branch_and_tree('a', '')
2381.1.3 by Robert Collins
Review feedback.
182
        self.build_tree(['a/foo'])
1910.2.17 by Aaron Bentley
Get fetching from 1 to 2 under test
183
        tree_a.add('foo', 'file1')
184
        tree_a.commit('rev1', rev_id='rev1')
2018.5.118 by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference.
185
        # create a knit-3 based format to fetch into
2255.2.208 by Robert Collins
Remove more references to 'experimental' formats.
186
        f = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
2100.3.20 by Aaron Bentley
Implement tree comparison for tree references
187
        try:
188
            format = tree_a.branch.repository._format
189
            format.check_conversion_target(f.repository_format)
2018.5.118 by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference.
190
            # if we cannot convert data to knit3, skip the test.
2100.3.20 by Aaron Bentley
Implement tree comparison for tree references
191
        except errors.BadConversionTarget, e:
192
            raise TestSkipped(str(e))
2018.5.82 by Andrew Bennetts
Merge from bzr.dev. Breaks a few tests because there are new methods not yet implemented.
193
        self.get_transport().mkdir('b')
1910.2.17 by Aaron Bentley
Get fetching from 1 to 2 under test
194
        b_bzrdir = f.initialize(self.get_url('b'))
2018.5.118 by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference.
195
        knit3_repo = b_bzrdir.create_repository()
196
        # fetch with a default limit (grab everything)
197
        knit3_repo.fetch(tree_a.branch.repository, revision_id=None)
198
        rev1_tree = knit3_repo.revision_tree('rev1')
1910.2.19 by Aaron Bentley
Test whether revision id for root is retained
199
        lines = rev1_tree.get_file_lines(rev1_tree.inventory.root.file_id)
200
        self.assertEqual([], lines)
201
        b_branch = b_bzrdir.create_branch()
202
        b_branch.pull(tree_a.branch)
1752.2.87 by Andrew Bennetts
Make tests pass.
203
        try:
204
            tree_b = b_bzrdir.create_workingtree()
205
        except errors.NotLocalUrl:
206
            raise TestSkipped("cannot make working tree with transport %r"
207
                              % b_bzrdir.transport)
1910.2.19 by Aaron Bentley
Test whether revision id for root is retained
208
        tree_b.commit('no change', rev_id='rev2')
2018.5.118 by Robert Collins
Fix RemoteRepositoryFormat to have appropriate rich_root_data and support_tree_reference.
209
        rev2_tree = knit3_repo.revision_tree('rev2')
1910.2.22 by Aaron Bentley
Make commits preserve root entry data
210
        self.assertEqual('rev1', rev2_tree.inventory.root.revision)
1910.2.17 by Aaron Bentley
Get fetching from 1 to 2 under test
211
1770.3.3 by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta().
212
    def test_get_revision_delta(self):
213
        tree_a = self.make_branch_and_tree('a')
2381.1.3 by Robert Collins
Review feedback.
214
        self.build_tree(['a/foo'])
1770.3.3 by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta().
215
        tree_a.add('foo', 'file1')
216
        tree_a.commit('rev1', rev_id='rev1')
2381.1.3 by Robert Collins
Review feedback.
217
        self.build_tree(['a/vla'])
1770.3.3 by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta().
218
        tree_a.add('vla', 'file2')
219
        tree_a.commit('rev2', rev_id='rev2')
220
221
        delta = tree_a.branch.repository.get_revision_delta('rev1')
222
        self.assertIsInstance(delta, TreeDelta)
223
        self.assertEqual([('foo', 'file1', 'file')], delta.added)
224
        delta = tree_a.branch.repository.get_revision_delta('rev2')
225
        self.assertIsInstance(delta, TreeDelta)
226
        self.assertEqual([('vla', 'file2', 'file')], delta.added)
227
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.
228
    def test_clone_bzrdir_repository_revision(self):
229
        # make a repository with some revisions,
230
        # and clone it, this should not have unreferenced revisions.
231
        # also: test cloning with a revision id of NULL_REVISION -> empty repo.
232
        raise TestSkipped('revision limiting is not implemented yet.')
233
234
    def test_clone_repository_basis_revision(self):
235
        raise TestSkipped('the use of a basis should not add noise data to the result.')
236
1534.6.5 by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes.
237
    def test_clone_shared_no_tree(self):
238
        # cloning a shared repository keeps it shared
239
        # and preserves the make_working_tree setting.
240
        made_control = self.make_bzrdir('source')
241
        try:
242
            made_repo = made_control.create_repository(shared=True)
243
        except errors.IncompatibleFormat:
244
            # not all repository formats understand being shared, or
245
            # may only be shared in some circumstances.
246
            return
2018.14.2 by Andrew Bennetts
All but one repository_implementation tests for RemoteRepository passing.
247
        try:
248
            made_repo.set_make_working_trees(False)
249
        except NotImplementedError:
2018.5.120 by Robert Collins
The Repository API ``make_working_trees`` is now permitted to return
250
            # the repository does not support having its tree-making flag
251
            # toggled.
252
            return
1534.6.5 by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes.
253
        result = made_control.clone(self.get_url('target'))
1752.2.55 by Andrew Bennetts
Replace another isinstance(made_repo, Repository) check.
254
        # Check that we have a repository object.
255
        made_repo.has_revision('foo')
256
1534.6.5 by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes.
257
        self.assertEqual(made_control, made_repo.bzrdir)
258
        self.assertTrue(result.open_repository().is_shared())
259
        self.assertFalse(result.open_repository().make_working_trees())
260
2018.5.90 by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository.
261
    def test_upgrade_preserves_signatures(self):
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.
262
        wt = self.make_branch_and_tree('source')
263
        wt.commit('A', allow_pointless=True, rev_id='A')
2018.5.90 by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository.
264
        repo = wt.branch.repository
265
        repo.sign_revision('A', bzrlib.gpg.LoopbackGPGStrategy(None))
266
        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.
267
        try:
268
            old_format = bzrdir.BzrDirFormat.get_default_format()
269
            # This gives metadir branches something they can convert to.
270
            # it would be nice to have a 'latest' vs 'default' concept.
2255.2.208 by Robert Collins
Remove more references to 'experimental' formats.
271
            format = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
2018.5.90 by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository.
272
            upgrade(repo.bzrdir.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.
273
        except errors.UpToDateFormat:
274
            # this is in the most current format already.
275
            return
1910.2.12 by Aaron Bentley
Implement knit repo format 2
276
        except errors.BadConversionTarget, e:
277
            raise TestSkipped(str(e))
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.
278
        wt = WorkingTree.open(wt.basedir)
1563.2.31 by Robert Collins
Convert Knit repositories to use knits.
279
        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.
280
        self.assertEqual(old_signature, new_signature)
281
1594.2.23 by Robert Collins
Test versioned file storage handling of clean/dirty status for accessed versioned files.
282
    def test_exposed_versioned_files_are_marked_dirty(self):
283
        repo = self.make_repository('.')
284
        repo.lock_write()
285
        inv = repo.get_inventory_weave()
286
        repo.unlock()
287
        self.assertRaises(errors.OutSideTransaction, inv.add_lines, 'foo', [], [])
288
1624.3.19 by Olaf Conradi
New call get_format_description to give a user-friendly description of a
289
    def test_format_description(self):
290
        repo = self.make_repository('.')
291
        text = repo._format.get_format_description()
292
        self.failUnless(len(text))
293
1666.1.6 by Robert Collins
Make knit the default format.
294
    def assertMessageRoundtrips(self, message):
295
        """Assert that message roundtrips to a repository and back intact."""
296
        tree = self.make_branch_and_tree('.')
297
        tree.commit(message, rev_id='a', allow_pointless=True)
298
        rev = tree.branch.repository.get_revision('a')
299
        # we have to manually escape this as we dont try to
300
        # roundtrip xml invalid characters at this point.
301
        # when escaping is moved to the serialiser, this test
302
        # can check against the literal message rather than
303
        # this escaped version.
304
        escaped_message, escape_count = re.subn(
305
            u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+',
306
            lambda match: match.group(0).encode('unicode_escape'),
307
            message)
308
        escaped_message= re.sub('\r', '\n', escaped_message)
309
        self.assertEqual(rev.message, escaped_message)
310
        # insist the class is unicode no matter what came in for 
311
        # consistency.
312
        self.assertIsInstance(rev.message, unicode)
313
314
    def test_commit_unicode_message(self):
315
        # a siple unicode message should be preserved
316
        self.assertMessageRoundtrips(u'foo bar gamm\xae plop')
317
318
    def test_commit_unicode_control_characters(self):
319
        # a unicode message with control characters should roundtrip too.
320
        self.assertMessageRoundtrips(
321
            "All 8-bit chars: " +  ''.join([unichr(x) for x in range(256)]))
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
322
1732.2.4 by Martin Pool
Split check into Branch.check and Repository.check
323
    def test_check_repository(self):
324
        """Check a fairly simple repository's history"""
325
        tree = self.make_branch_and_tree('.')
326
        tree.commit('initial empty commit', rev_id='a-rev',
327
                    allow_pointless=True)
328
        result = tree.branch.repository.check(['a-rev'])
329
        # writes to log; should accept both verbose or non-verbose
330
        result.report_results(verbose=True)
331
        result.report_results(verbose=False)
332
1756.1.5 by Aaron Bentley
Test get_revisions with all repository types (and fix bug...)
333
    def test_get_revisions(self):
334
        tree = self.make_branch_and_tree('.')
335
        tree.commit('initial empty commit', rev_id='a-rev',
336
                    allow_pointless=True)
337
        tree.commit('second empty commit', rev_id='b-rev',
338
                    allow_pointless=True)
339
        tree.commit('third empty commit', rev_id='c-rev',
340
                    allow_pointless=True)
341
        repo = tree.branch.repository
342
        revision_ids = ['a-rev', 'b-rev', 'c-rev']
343
        revisions = repo.get_revisions(revision_ids)
344
        assert len(revisions) == 3, repr(revisions)
345
        zipped = zip(revisions, revision_ids)
346
        self.assertEqual(len(zipped), 3)
347
        for revision, revision_id in zipped:
348
            self.assertEqual(revision.revision_id, revision_id)
349
            self.assertEqual(revision, repo.get_revision(revision_id))
1732.2.4 by Martin Pool
Split check into Branch.check and Repository.check
350
1910.2.1 by Aaron Bentley
Ensure root entry always has a revision
351
    def test_root_entry_has_revision(self):
352
        tree = self.make_branch_and_tree('.')
353
        tree.commit('message', rev_id='rev_id')
2255.7.65 by Robert Collins
Split test_root_revision_entry into tree and repository portions.
354
        rev_tree = tree.branch.repository.revision_tree(tree.last_revision())
1910.2.6 by Aaron Bentley
Update for merge review, handle deprecations
355
        self.assertEqual('rev_id', rev_tree.inventory.root.revision)
1910.2.1 by Aaron Bentley
Ensure root entry always has a revision
356
2255.7.64 by Robert Collins
Disabled test_repository.test_create_basis_inventory, a test that tests tree behaviour in the wrong place - its future is being discussed.
357
    def DISABLED_DELETE_OR_FIX_BEFORE_MERGE_test_create_basis_inventory(self):
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
358
        # Needs testing here because differences between repo and working tree
359
        # basis inventory formats can lead to bugs.
360
        t = self.make_branch_and_tree('.')
361
        b = t.branch
362
        open('a', 'wb').write('a\n')
363
        t.add('a')
364
        t.commit('a', rev_id='r1')
365
366
        t._control_files.get_utf8('basis-inventory-cache')
367
368
        basis_inv = t.basis_tree().inventory
369
        self.assertEquals('r1', basis_inv.revision_id)
370
        
371
        store_inv = b.repository.get_inventory('r1')
372
        self.assertEquals(store_inv._byid, basis_inv._byid)
373
374
        open('b', 'wb').write('b\n')
375
        t.add('b')
376
        t.commit('b', rev_id='r2')
377
378
        t._control_files.get_utf8('basis-inventory-cache')
379
380
        basis_inv_txt = t.read_basis_inventory()
2100.3.15 by Aaron Bentley
get test suite passing
381
        basis_inv = bzrlib.xml7.serializer_v7.read_inventory_from_string(basis_inv_txt)
1910.2.31 by Aaron Bentley
Fix bugs in basis inventory handling, change filename
382
        self.assertEquals('r2', basis_inv.revision_id)
383
        store_inv = b.repository.get_inventory('r2')
384
385
        self.assertEquals(store_inv._byid, basis_inv._byid)
386
1910.2.36 by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats
387
    def test_upgrade_from_format4(self):
388
        from bzrlib.tests.test_upgrade import _upgrade_dir_template
2241.1.4 by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo.
389
        if self.repository_format.get_format_description() \
390
            == "Repository format 4":
1910.2.36 by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats
391
            raise TestSkipped('Cannot convert format-4 to itself')
1752.2.89 by Andrew Bennetts
Skip test_upgrade_from_format4 for RemoteRepositoryFormat.
392
        if isinstance(self.repository_format, remote.RemoteRepositoryFormat):
393
            return # local conversion to/from RemoteObjects is irrelevant.
1910.2.36 by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats
394
        self.build_tree_contents(_upgrade_dir_template)
395
        old_repodir = bzrlib.bzrdir.BzrDir.open_unsupported('.')
396
        old_repo_format = old_repodir.open_repository()._format
397
        format = self.repository_format._matchingbzrdir
398
        try:
399
            format.repository_format = self.repository_format
400
        except AttributeError:
401
            pass
402
        upgrade('.', format)
403
1910.2.37 by Aaron Bentley
Handle empty commits, fix test
404
    def test_pointless_commit(self):
405
        tree = self.make_branch_and_tree('.')
406
        self.assertRaises(errors.PointlessCommit, tree.commit, 'pointless',
407
                          allow_pointless=False)
408
        tree.commit('pointless', allow_pointless=True)
409
2323.5.17 by Martin Pool
Add supports_tree_reference to all repo formats (robert)
410
    def test_format_attributes(self):
411
        """All repository formats should have some basic attributes."""
412
        # create a repository to get a real format instance, not the 
413
        # template from the test suite parameterisation.
414
        repo = self.make_repository('.')
415
        repo._format.rich_root_data
416
        repo._format.supports_tree_reference
417
1852.9.6 by Robert Collins
Merge the change from Tree.compare to Tree.changes_from.
418
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
419
class TestRepositoryLocking(TestCaseWithRepository):
420
421
    def test_leave_lock_in_place(self):
422
        repo = self.make_repository('r')
423
        # Lock the repository, then use leave_lock_in_place so that when we
424
        # unlock the repository the lock is still held on disk.
2018.5.76 by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None.
425
        token = repo.lock_write()
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
426
        try:
2018.5.76 by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None.
427
            if token is None:
428
                # This test does not apply, because this repository refuses lock
429
                # tokens.
430
                self.assertRaises(NotImplementedError, repo.leave_lock_in_place)
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
431
                return
2018.5.76 by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None.
432
            repo.leave_lock_in_place()
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
433
        finally:
434
            repo.unlock()
435
        # We should be unable to relock the repo.
436
        self.assertRaises(errors.LockContention, repo.lock_write)
437
438
    def test_dont_leave_lock_in_place(self):
439
        repo = self.make_repository('r')
440
        # Create a lock on disk.
441
        token = repo.lock_write()
442
        try:
443
            if token is None:
444
                # This test does not apply, because this repository refuses lock
445
                # tokens.
2018.5.76 by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None.
446
                self.assertRaises(NotImplementedError,
447
                                  repo.dont_leave_lock_in_place)
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
448
                return
449
            try:
450
                repo.leave_lock_in_place()
451
            except NotImplementedError:
452
                # This repository doesn't support this API.
453
                return
454
        finally:
455
            repo.unlock()
456
        # Reacquire the lock (with a different repository object) by using the
457
        # token.
458
        new_repo = repo.bzrdir.open_repository()
459
        new_repo.lock_write(token=token)
460
        # Call dont_leave_lock_in_place, so that the lock will be released by
461
        # this instance, even though the lock wasn't originally acquired by it.
462
        new_repo.dont_leave_lock_in_place()
463
        new_repo.unlock()
464
        # Now the repository is unlocked.  Test this by locking it (without a
465
        # token).
466
        repo.lock_write()
467
        repo.unlock()
468
2018.5.78 by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the
469
    def test_lock_read_then_unlock(self):
470
        # Calling lock_read then unlocking should work without errors.
471
        repo = self.make_repository('r')
472
        repo.lock_read()
473
        repo.unlock()
474
2018.5.75 by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place.
475
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
476
class TestCaseWithComplexRepository(TestCaseWithRepository):
477
478
    def setUp(self):
479
        super(TestCaseWithComplexRepository, self).setUp()
480
        tree_a = self.make_branch_and_tree('a')
481
        self.bzrdir = tree_a.branch.bzrdir
482
        # add a corrupt inventory 'orphan'
1534.1.34 by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method.
483
        # this may need some generalising for knits.
1563.2.10 by Robert Collins
Change weave store to be a versioned store, using WeaveFiles which maintain integrity without needing explicit 'put' operations.
484
        inv_file = tree_a.branch.repository.control_weaves.get_weave(
485
            'inventory', 
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
486
            tree_a.branch.repository.get_transaction())
1563.2.10 by Robert Collins
Change weave store to be a versioned store, using WeaveFiles which maintain integrity without needing explicit 'put' operations.
487
        inv_file.add_lines('orphan', [], [])
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
488
        # add a real revision 'rev1'
489
        tree_a.commit('rev1', rev_id='rev1', allow_pointless=True)
490
        # add a real revision 'rev2' based on rev1
491
        tree_a.commit('rev2', rev_id='rev2', allow_pointless=True)
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
492
        # add a reference to a ghost
1908.6.7 by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly.
493
        tree_a.add_parent_tree_id('ghost1')
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
494
        tree_a.commit('rev3', rev_id='rev3', allow_pointless=True)
495
        # add another reference to a ghost, and a second ghost.
1908.6.7 by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly.
496
        tree_a.add_parent_tree_id('ghost1')
497
        tree_a.add_parent_tree_id('ghost2')
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
498
        tree_a.commit('rev4', rev_id='rev4', allow_pointless=True)
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
499
1756.3.20 by Aaron Bentley
Tests for get_revision_deltas and revisions_trees
500
    def test_revision_trees(self):
501
        revision_ids = ['rev1', 'rev2', 'rev3', 'rev4']
502
        repository = self.bzrdir.open_repository()
503
        trees1 = list(repository.revision_trees(revision_ids))
504
        trees2 = [repository.revision_tree(t) for t in revision_ids]
505
        assert len(trees1) == len(trees2)
506
        for tree1, tree2 in zip(trees1, trees2):
1852.10.3 by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib.
507
            assert not tree2.changes_from(tree1).has_changed()
1756.3.20 by Aaron Bentley
Tests for get_revision_deltas and revisions_trees
508
1756.3.22 by Aaron Bentley
Tweaks from review
509
    def test_get_deltas_for_revisions(self):
1756.3.20 by Aaron Bentley
Tests for get_revision_deltas and revisions_trees
510
        repository = self.bzrdir.open_repository()
511
        revisions = [repository.get_revision(r) for r in 
512
                     ['rev1', 'rev2', 'rev3', 'rev4']]
1756.3.22 by Aaron Bentley
Tweaks from review
513
        deltas1 = list(repository.get_deltas_for_revisions(revisions))
1756.3.20 by Aaron Bentley
Tests for get_revision_deltas and revisions_trees
514
        deltas2 = [repository.get_revision_delta(r.revision_id) for r in
515
                   revisions]
516
        assert deltas1 == deltas2
517
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
518
    def test_all_revision_ids(self):
519
        # all_revision_ids -> all revisions
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
520
        self.assertEqual(['rev1', 'rev2', 'rev3', 'rev4'],
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.
521
                         self.bzrdir.open_repository().all_revision_ids())
522
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
523
    def test_get_ancestry_missing_revision(self):
1534.1.34 by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method.
524
        # get_ancestry(revision that is in some data but not fully installed
525
        # -> NoSuchRevision
1534.4.41 by Robert Collins
Branch now uses BzrDir reasonably sanely.
526
        self.assertRaises(errors.NoSuchRevision,
527
                          self.bzrdir.open_repository().get_ancestry, 'orphan')
1570.1.13 by Robert Collins
Check for incorrect revision parentage in the weave during revision access.
528
2530.1.1 by Aaron Bentley
Make topological sorting optional for get_ancestry
529
    def test_get_unsorted_ancestry(self):
530
        repo = self.bzrdir.open_repository()
531
        self.assertEqual(set(repo.get_ancestry('rev3')),
532
                         set(repo.get_ancestry('rev3', topo_sorted=False)))
533
1590.1.1 by Robert Collins
Improve common_ancestor performance.
534
    def test_get_revision_graph(self):
535
        # we can get a mapping of id->parents for the entire revision graph or bits thereof.
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
536
        self.assertEqual({'rev1':[],
537
                          'rev2':['rev1'],
538
                          'rev3':['rev2'],
539
                          'rev4':['rev3'],
540
                          },
1590.1.1 by Robert Collins
Improve common_ancestor performance.
541
                         self.bzrdir.open_repository().get_revision_graph(None))
542
        self.assertEqual({'rev1':[]},
543
                         self.bzrdir.open_repository().get_revision_graph('rev1'))
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
544
        self.assertEqual({'rev1':[],
545
                          'rev2':['rev1']},
1590.1.1 by Robert Collins
Improve common_ancestor performance.
546
                         self.bzrdir.open_repository().get_revision_graph('rev2'))
2279.7.9 by Andrew Bennetts
Remove some redundant code pointed out by Robert's review, and remove some unused imports while I'm there.
547
        self.assertRaises(errors.NoSuchRevision,
1590.1.1 by Robert Collins
Improve common_ancestor performance.
548
                          self.bzrdir.open_repository().get_revision_graph,
549
                          'orphan')
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
550
        # and ghosts are not mentioned
551
        self.assertEqual({'rev1':[],
552
                          'rev2':['rev1'],
553
                          'rev3':['rev2'],
554
                          },
555
                         self.bzrdir.open_repository().get_revision_graph('rev3'))
1836.3.1 by Robert Collins
(robertc) Teach repository.get_revision_graph, and revision.common_ancestor, about NULL_REVISION.
556
        # and we can ask for the NULLREVISION graph
557
        self.assertEqual({},
558
            self.bzrdir.open_repository().get_revision_graph(NULL_REVISION))
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
559
560
    def test_get_revision_graph_with_ghosts(self):
561
        # we can get a graph object with roots, ghosts, ancestors and
562
        # descendants.
563
        repo = self.bzrdir.open_repository()
564
        graph = repo.get_revision_graph_with_ghosts([])
565
        self.assertEqual(set(['rev1']), graph.roots)
566
        self.assertEqual(set(['ghost1', 'ghost2']), graph.ghosts)
567
        self.assertEqual({'rev1':[],
568
                          'rev2':['rev1'],
569
                          'rev3':['rev2', 'ghost1'],
570
                          'rev4':['rev3', 'ghost1', 'ghost2'],
571
                          },
572
                          graph.get_ancestors())
573
        self.assertEqual({'ghost1':{'rev3':1, 'rev4':1},
574
                          'ghost2':{'rev4':1},
575
                          'rev1':{'rev2':1},
576
                          'rev2':{'rev3':1},
577
                          'rev3':{'rev4':1},
578
                          'rev4':{},
579
                          },
580
                          graph.get_descendants())
1836.3.1 by Robert Collins
(robertc) Teach repository.get_revision_graph, and revision.common_ancestor, about NULL_REVISION.
581
        # and we can ask for the NULLREVISION graph
582
        graph = repo.get_revision_graph_with_ghosts([NULL_REVISION])
583
        self.assertEqual({}, graph.get_ancestors())
584
        self.assertEqual({}, graph.get_descendants())
1590.1.1 by Robert Collins
Improve common_ancestor performance.
585
2229.2.1 by Aaron Bentley
Reject reserved ids in versiondfile, tree, branch and repository
586
    def test_reserved_id(self):
587
        repo = self.make_repository('repository')
588
        self.assertRaises(errors.ReservedId, repo.add_inventory, 'reserved:',
589
                          None, None)
590
        self.assertRaises(errors.ReservedId, repo.add_revision, 'reserved:',
591
                          None)
2229.2.3 by Aaron Bentley
change reserved_id to is_reserved_id, add check_not_reserved for DRY
592
1570.1.13 by Robert Collins
Check for incorrect revision parentage in the weave during revision access.
593
594
class TestCaseWithCorruptRepository(TestCaseWithRepository):
595
596
    def setUp(self):
597
        super(TestCaseWithCorruptRepository, self).setUp()
598
        # a inventory with no parents and the revision has parents..
599
        # i.e. a ghost.
600
        repo = self.make_repository('inventory_with_unnecessary_ghost')
1910.2.23 by Aaron Bentley
Fix up test cases that manually construct inventories
601
        inv = Inventory(revision_id = 'ghost')
602
        inv.root.revision = 'ghost'
1907.1.1 by Aaron Bentley
Unshelved all changes except those related to removing RootEntry
603
        sha1 = repo.add_inventory('ghost', inv, [])
1570.1.13 by Robert Collins
Check for incorrect revision parentage in the weave during revision access.
604
        rev = bzrlib.revision.Revision(timestamp=0,
605
                                       timezone=None,
606
                                       committer="Foo Bar <foo@example.com>",
607
                                       message="Message",
608
                                       inventory_sha1=sha1,
609
                                       revision_id='ghost')
610
        rev.parent_ids = ['the_ghost']
611
        repo.add_revision('ghost', rev)
612
         
1910.2.23 by Aaron Bentley
Fix up test cases that manually construct inventories
613
        inv = Inventory(revision_id = 'the_ghost')
614
        inv.root.revision = 'the_ghost'
1907.1.1 by Aaron Bentley
Unshelved all changes except those related to removing RootEntry
615
        sha1 = repo.add_inventory('the_ghost', inv, [])
1570.1.13 by Robert Collins
Check for incorrect revision parentage in the weave during revision access.
616
        rev = bzrlib.revision.Revision(timestamp=0,
617
                                       timezone=None,
618
                                       committer="Foo Bar <foo@example.com>",
619
                                       message="Message",
620
                                       inventory_sha1=sha1,
621
                                       revision_id='the_ghost')
622
        rev.parent_ids = []
623
        repo.add_revision('the_ghost', rev)
624
        # check its setup usefully
625
        inv_weave = repo.get_inventory_weave()
1563.2.30 by Robert Collins
Remove all but fetch references to revision_store, making the repository references that are weave specific use the RevisionTextStore.text_store attribute.
626
        self.assertEqual(['ghost'], inv_weave.get_ancestry(['ghost']))
1570.1.13 by Robert Collins
Check for incorrect revision parentage in the weave during revision access.
627
1594.2.10 by Robert Collins
Teach knit fetching and branching to only duplicate relevant data avoiding unnecessary reconciles.
628
    def test_corrupt_revision_access_asserts_if_reported_wrong(self):
2018.14.1 by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures.
629
        repo_url = self.get_url('inventory_with_unnecessary_ghost')
630
        repo = repository.Repository.open(repo_url)
1594.2.10 by Robert Collins
Teach knit fetching and branching to only duplicate relevant data avoiding unnecessary reconciles.
631
        reported_wrong = False
632
        try:
633
            if repo.get_ancestry('ghost') != [None, 'the_ghost', 'ghost']:
634
                reported_wrong = True
635
        except errors.CorruptRepository:
636
            # caught the bad data:
637
            return
638
        if not reported_wrong:
639
            return
1570.1.13 by Robert Collins
Check for incorrect revision parentage in the weave during revision access.
640
        self.assertRaises(errors.CorruptRepository, repo.get_revision, 'ghost')
641
1594.2.3 by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits.
642
    def test_corrupt_revision_get_revision_reconcile(self):
2018.14.1 by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures.
643
        repo_url = self.get_url('inventory_with_unnecessary_ghost')
644
        repo = repository.Repository.open(repo_url)
1570.1.13 by Robert Collins
Check for incorrect revision parentage in the weave during revision access.
645
        repo.get_revision_reconcile('ghost')
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.
646
647
2018.5.29 by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point.
648
# FIXME: document why this is a TestCaseWithTransport rather than a
649
#        TestCaseWithRepository
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.
650
class TestEscaping(TestCaseWithTransport):
651
    """Test that repositories can be stored correctly on VFAT transports.
652
    
653
    Makes sure we have proper escaping of invalid characters, etc.
654
655
    It'd be better to test all operations on the FakeVFATTransportDecorator,
656
    but working trees go straight to the os not through the Transport layer.
657
    Therefore we build some history first in the regular way and then 
658
    check it's safe to access for vfat.
659
    """
660
661
    def test_on_vfat(self):
2018.5.29 by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point.
662
        # dont bother with remote repository testing, because this test is
663
        # about local disk layout/support.
664
        from bzrlib.remote import RemoteRepositoryFormat
665
        if isinstance(self.repository_format, RemoteRepositoryFormat):
666
            return
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.
667
        FOO_ID = 'foo<:>ID'
2018.5.29 by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point.
668
        REV_ID = 'revid-1' 
669
        # this makes a default format repository always, which is wrong: 
670
        # it should be a TestCaseWithRepository in order to get the 
671
        # 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.
672
        wt = self.make_branch_and_tree('repo')
2052.2.1 by Alexander Belchenko
test_on_vfat win32 fix: use binary line-endings
673
        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.
674
        # add file with id containing wierd characters
675
        wt.add(['foo'], [FOO_ID])
676
        wt.commit('this is my new commit', rev_id=REV_ID)
677
        # now access over vfat; should be safe
678
        branch = bzrdir.BzrDir.open('vfat+' + self.get_url('repo')).open_branch()
679
        revtree = branch.repository.revision_tree(REV_ID)
680
        contents = revtree.get_file_text(FOO_ID)
681
        self.assertEqual(contents, 'contents of repo/foo\n')