~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository/test_fetch.py

Merge bzr.dev, update to use new hooks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
    bzrdir,
21
21
    errors,
22
22
    gpg,
23
 
    graph,
24
23
    remote,
25
24
    repository,
26
 
    tests,
27
25
    )
28
26
from bzrlib.inventory import ROOT_ID
29
 
from bzrlib.tests import TestSkipped
 
27
from bzrlib.tests import (
 
28
    TestNotApplicable,
 
29
    TestSkipped,
 
30
    )
30
31
from bzrlib.tests.per_repository import TestCaseWithRepository
31
32
 
32
33
 
135
136
        repo.lock_write()
136
137
        self.addCleanup(repo.unlock)
137
138
        repo.fetch(source.repository)
 
139
        graph = repo.get_file_graph()
138
140
        self.assertEqual(result,
139
 
            repo.texts.get_parent_map([(root_id, 'tip')])[(root_id, 'tip')])
 
141
            graph.get_parent_map([(root_id, 'tip')])[(root_id, 'tip')])
140
142
 
141
143
    def test_fetch_to_rich_root_set_parent_no_parents(self):
142
144
        # No parents rev -> No parents
154
156
 
155
157
    def test_fetch_to_rich_root_set_parent_1_ghost_parent(self):
156
158
        # 1 ghost parent -> No parents
 
159
        if not self.repository_format.supports_ghosts:
 
160
            raise TestNotApplicable("repository format does not support "
 
161
                 "ghosts")
157
162
        self.do_test_fetch_to_rich_root_sets_parents_correctly((),
158
163
            [('tip', ['ghost'], [('add', ('', ROOT_ID, 'directory', ''))]),
159
164
            ], allow_lefthand_ghost=True)
197
202
             ('base', None, []),
198
203
             ('tip', None, [('unversion', 'my-root'),
199
204
                            ('unversion', ROOT_ID),
 
205
                            ('flush', None),
200
206
                            ('add', ('', 'my-root', 'directory', '')),
201
207
                            ]),
202
208
            ], root_id='my-root')
225
231
            # 'my-root' at root
226
232
             ('right', None, [('unversion', 'my-root'),
227
233
                              ('unversion', ROOT_ID),
 
234
                              ('flush', None),
228
235
                              ('add', ('', 'my-root', 'directory', ''))]),
229
236
             ('tip', ['base', 'right'], [('unversion', 'my-root'),
230
237
                            ('unversion', ROOT_ID),
 
238
                            ('flush', None),
231
239
                            ('add', ('', 'my-root', 'directory', '')),
232
240
                            ]),
233
241
            ], root_id='my-root')
263
271
        repo = wt.branch.repository
264
272
        repo.lock_write()
265
273
        repo.start_write_group()
266
 
        repo.sign_revision('rev1', gpg.LoopbackGPGStrategy(None))
 
274
        try:
 
275
            repo.sign_revision('rev1', gpg.LoopbackGPGStrategy(None))
 
276
        except errors.UnsupportedOperation:
 
277
            self.assertFalse(repo._format.supports_revision_signatures)
 
278
            raise TestNotApplicable("repository format does not support signatures")
267
279
        repo.commit_write_group()
268
280
        repo.unlock()
269
281
        return repo
323
335
    def test_fetch_into_smart_with_ghost(self):
324
336
        trans = self.make_smart_server('target')
325
337
        source_b = self.make_simple_branch_with_ghost()
 
338
        if not source_b.bzrdir._format.supports_transport(trans):
 
339
            raise TestNotApplicable("format does not support transport")
326
340
        target = self.make_repository('target')
327
341
        # Re-open the repository over the smart protocol
328
342
        target = repository.Repository.open(trans.base)
334
348
            # The code inside fetch() that tries to lock and then fails, also
335
349
            # causes weird problems with 'lock_not_held' later on...
336
350
            target.lock_read()
337
 
            raise tests.KnownFailure('some repositories fail to fetch'
 
351
            self.knownFailure('some repositories fail to fetch'
338
352
                ' via the smart server because of locking issues.')
339
353
 
340
354
    def test_fetch_from_smart_with_ghost(self):
341
355
        trans = self.make_smart_server('source')
342
356
        source_b = self.make_simple_branch_with_ghost()
 
357
        if not source_b.bzrdir._format.supports_transport(trans):
 
358
            raise TestNotApplicable("format does not support transport")
343
359
        target = self.make_repository('target')
344
360
        target.lock_write()
345
361
        self.addCleanup(target.unlock)
349
365
        self.addCleanup(source.unlock)
350
366
        target.fetch(source, revision_id='B-id')
351
367
 
352
 
 
353
 
class TestSource(TestCaseWithRepository):
354
 
    """Tests for/about the results of Repository._get_source."""
355
 
 
356
 
    def test_no_absent_records_in_stream_with_ghosts(self):
357
 
        # XXX: Arguably should be in per_interrepository but
358
 
        # doesn't actually gain coverage there; need a specific set of
359
 
        # permutations to cover it.
360
 
        # bug lp:376255 was reported about this.
361
 
        builder = self.make_branch_builder('repo')
362
 
        builder.start_series()
363
 
        builder.build_snapshot('tip', ['ghost'],
364
 
            [('add', ('', 'ROOT_ID', 'directory', ''))],
365
 
            allow_leftmost_as_ghost=True)
366
 
        builder.finish_series()
367
 
        b = builder.get_branch()
368
 
        b.lock_read()
369
 
        self.addCleanup(b.unlock)
370
 
        repo = b.repository
371
 
        source = repo._get_source(repo._format)
372
 
        search = graph.PendingAncestryResult(['tip'], repo)
373
 
        stream = source.get_stream(search)
374
 
        for substream_type, substream in stream:
375
 
            for record in substream:
376
 
                self.assertNotEqual('absent', record.storage_kind,
377
 
                    "Absent record for %s" % (((substream_type,) + record.key),))