~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-08-14 05:49:27 UTC
  • mfrom: (4476.3.86 inventory-delta)
  • Revision ID: pqm@pqm.ubuntu.com-20090814054927-k0k18dn46ax4b91f
(andrew) Add inventory-delta streaming for cross-format fetch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib.errors import (
29
29
    NoSuchRevision,
30
30
    )
 
31
from bzrlib.graph import (
 
32
    SearchResult,
 
33
    )
31
34
from bzrlib.revision import (
32
35
    NULL_REVISION,
33
36
    Revision,
124
127
            to_repo.texts.get_record_stream([('foo', revid)],
125
128
            'unordered', True).next().get_bytes_as('fulltext'))
126
129
 
 
130
    def test_fetch_parent_inventories_at_stacking_boundary_smart(self):
 
131
        self.setup_smart_server_with_call_log()
 
132
        self.test_fetch_parent_inventories_at_stacking_boundary()
 
133
 
 
134
    def test_fetch_parent_inventories_at_stacking_boundary_smart_old(self):
 
135
        self.setup_smart_server_with_call_log()
 
136
        self.disable_verb('Repository.insert_stream_1.19')
 
137
        self.test_fetch_parent_inventories_at_stacking_boundary()
 
138
 
127
139
    def test_fetch_parent_inventories_at_stacking_boundary(self):
128
140
        """Fetch to a stacked branch copies inventories for parents of
129
141
        revisions at the stacking boundary.
180
192
        self.assertEqual(left_tree.inventory, stacked_left_tree.inventory)
181
193
        self.assertEqual(right_tree.inventory, stacked_right_tree.inventory)
182
194
 
 
195
        # Finally, it's not enough to see that the basis inventories are
 
196
        # present.  The texts introduced in merge (and only those) should be
 
197
        # present, and also generating a stream should succeed without blowing
 
198
        # up.
 
199
        self.assertTrue(unstacked_repo.has_revision('merge'))
 
200
        expected_texts = set([('file-id', 'merge')])
 
201
        if stacked_branch.repository.texts.get_parent_map([('root-id',
 
202
            'merge')]):
 
203
            # If a (root-id,merge) text exists, it should be in the stacked
 
204
            # repo.
 
205
            expected_texts.add(('root-id', 'merge'))
 
206
        self.assertEqual(expected_texts, unstacked_repo.texts.keys())
 
207
        self.assertCanStreamRevision(unstacked_repo, 'merge')
 
208
 
 
209
    def assertCanStreamRevision(self, repo, revision_id):
 
210
        exclude_keys = set(repo.all_revision_ids()) - set([revision_id])
 
211
        search = SearchResult([revision_id], exclude_keys, 1, [revision_id])
 
212
        source = repo._get_source(repo._format)
 
213
        for substream_kind, substream in source.get_stream(search):
 
214
            # Consume the substream
 
215
            list(substream)
 
216
 
183
217
    def test_fetch_across_stacking_boundary_ignores_ghost(self):
184
218
        if not self.repository_format_to.supports_external_lookups:
185
219
            raise TestNotApplicable("Need stacking support in the target.")
218
252
        self.addCleanup(stacked_branch.unlock)
219
253
        stacked_second_tree = stacked_branch.repository.revision_tree('second')
220
254
        self.assertEqual(second_tree.inventory, stacked_second_tree.inventory)
 
255
        # Finally, it's not enough to see that the basis inventories are
 
256
        # present.  The texts introduced in merge (and only those) should be
 
257
        # present, and also generating a stream should succeed without blowing
 
258
        # up.
 
259
        self.assertTrue(unstacked_repo.has_revision('third'))
 
260
        expected_texts = set([('file-id', 'third')])
 
261
        if stacked_branch.repository.texts.get_parent_map([('root-id',
 
262
            'third')]):
 
263
            # If a (root-id,third) text exists, it should be in the stacked
 
264
            # repo.
 
265
            expected_texts.add(('root-id', 'third'))
 
266
        self.assertEqual(expected_texts, unstacked_repo.texts.keys())
 
267
        self.assertCanStreamRevision(unstacked_repo, 'third')
221
268
 
222
269
    def test_fetch_missing_basis_text(self):
223
270
        """If fetching a delta, we should die if a basis is not present."""