~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Robert Collins
  • Date: 2009-03-24 07:09:11 UTC
  • mto: This revision was merged to the branch mainline in revision 4199.
  • Revision ID: robertc@robertcollins.net-20090324070911-w59etn9q3f9xj4fu
Cache ghosts when we can get them from a RemoteRepository in get_parent_map.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    repository,
37
37
    smart,
38
38
    tests,
 
39
    treebuilder,
39
40
    urlutils,
40
41
    )
41
42
from bzrlib.branch import Branch
1648
1649
                'more-missing']))
1649
1650
        self.assertLength(1, self.hpss_calls)
1650
1651
 
 
1652
    def test_get_parent_map_gets_ghosts_from_result(self):
 
1653
        # asking for a revision should negatively cache close ghosts in its
 
1654
        # ancestry.
 
1655
        self.setup_smart_server_with_call_log()
 
1656
        tree = self.make_branch_and_memory_tree('foo')
 
1657
        tree.lock_write()
 
1658
        try:
 
1659
            builder = treebuilder.TreeBuilder()
 
1660
            builder.start_tree(tree)
 
1661
            builder.build([])
 
1662
            builder.finish_tree()
 
1663
            tree.set_parent_ids(['non-existant'], allow_leftmost_as_ghost=True)
 
1664
            rev_id = tree.commit('')
 
1665
        finally:
 
1666
            tree.unlock()
 
1667
        tree.lock_read()
 
1668
        self.addCleanup(tree.unlock)
 
1669
        repo = tree.branch.repository
 
1670
        self.assertIsInstance(repo, RemoteRepository)
 
1671
        # ask for rev_id
 
1672
        repo.get_parent_map([rev_id])
 
1673
        self.reset_smart_call_log()
 
1674
        # Now asking for rev_id's ghost parent should not make calls
 
1675
        self.assertEqual({}, repo.get_parent_map(['non-existant']))
 
1676
        self.assertLength(0, self.hpss_calls)
 
1677
 
1651
1678
 
1652
1679
class TestGetParentMapAllowsNew(tests.TestCaseWithTransport):
1653
1680
 
2368
2395
        rev_ord, expected_revs = self.get_ordered_revs('knit', 'topological')
2369
2396
        self.assertEqual(expected_revs, rev_ord)
2370
2397
        # Getting topological sort requires VFS calls still
2371
 
        self.assertLength(14, self.hpss_calls)
 
2398
        self.assertLength(13, self.hpss_calls)
2372
2399
 
2373
2400
    def test_stacked_get_stream_groupcompress(self):
2374
2401
        # Repository._get_source.get_stream() from a stacked repository with