~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-02 02:34:51 UTC
  • mfrom: (4392.2.3 quick-fix)
  • Revision ID: pqm@pqm.ubuntu.com-20090602023451-adrz7xhxr6qimtni
(jam) Fix some regressions w/ fetch+ghosts+stacking introduced by 4392

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    graph,
24
24
    remote,
25
25
    repository,
 
26
    tests,
26
27
    )
27
28
from bzrlib.inventory import ROOT_ID
28
29
from bzrlib.tests import TestSkipped
145
146
            ])
146
147
 
147
148
    def test_fetch_to_rich_root_set_parent_1_parent(self):
148
 
        # 1 parent rev -> 1 parent 
 
149
        # 1 parent rev -> 1 parent
149
150
        self.do_test_fetch_to_rich_root_sets_parents_correctly(
150
151
            ((ROOT_ID, 'base'),),
151
152
            [('base', None, [('add', ('', ROOT_ID, 'directory', ''))]),
300
301
        repo.fetch(tree.branch.repository)
301
302
        repo.fetch(tree.branch.repository)
302
303
 
 
304
    def make_simple_branch_with_ghost(self):
 
305
        builder = self.make_branch_builder('source')
 
306
        builder.start_series()
 
307
        builder.build_snapshot('A-id', None, [
 
308
            ('add', ('', 'root-id', 'directory', None)),
 
309
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
310
        builder.build_snapshot('B-id', ['A-id', 'ghost-id'], [])
 
311
        builder.finish_series()
 
312
        source_b = builder.get_branch()
 
313
        source_b.lock_read()
 
314
        self.addCleanup(source_b.unlock)
 
315
        return source_b
 
316
 
 
317
    def test_fetch_with_ghost(self):
 
318
        source_b = self.make_simple_branch_with_ghost()
 
319
        target = self.make_repository('target')
 
320
        target.lock_write()
 
321
        self.addCleanup(target.unlock)
 
322
        target.fetch(source_b.repository, revision_id='B-id')
 
323
 
 
324
    def test_fetch_into_smart_with_ghost(self):
 
325
        trans = self.make_smart_server('target')
 
326
        source_b = self.make_simple_branch_with_ghost()
 
327
        target = self.make_repository('target')
 
328
        # Re-open the repository over the smart protocol
 
329
        target = repository.Repository.open(trans.base)
 
330
        target.lock_write()
 
331
        self.addCleanup(target.unlock)
 
332
        try:
 
333
            target.fetch(source_b.repository, revision_id='B-id')
 
334
        except errors.TokenLockingNotSupported:
 
335
            # The code inside fetch() that tries to lock and then fails, also
 
336
            # causes weird problems with 'lock_not_held' later on...
 
337
            target.lock_read()
 
338
            raise tests.KnownFailure('some repositories fail to fetch'
 
339
                ' via the smart server because of locking issues.')
 
340
 
 
341
    def test_fetch_from_smart_with_ghost(self):
 
342
        trans = self.make_smart_server('source')
 
343
        source_b = self.make_simple_branch_with_ghost()
 
344
        target = self.make_repository('target')
 
345
        target.lock_write()
 
346
        self.addCleanup(target.unlock)
 
347
        # Re-open the repository over the smart protocol
 
348
        source = repository.Repository.open(trans.base)
 
349
        source.lock_read()
 
350
        self.addCleanup(source.unlock)
 
351
        target.fetch(source, revision_id='B-id')
 
352
 
303
353
 
304
354
class TestSource(TestCaseWithRepository):
305
355
    """Tests for/about the results of Repository._get_source."""