/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Andrew Bennetts
  • Date: 2010-04-13 04:33:55 UTC
  • mfrom: (5147 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5149.
  • Revision ID: andrew.bennetts@canonical.com-20100413043355-lg3id0uwtju0k3zs
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
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
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
import sys
19
19
 
20
 
import bzrlib
21
20
from bzrlib import (
22
21
    errors,
 
22
    inventory,
 
23
    osutils,
23
24
    repository,
24
 
    osutils,
 
25
    versionedfile,
25
26
    )
26
27
from bzrlib.errors import (
27
28
    NoSuchRevision,
28
29
    )
 
30
from bzrlib.graph import (
 
31
    SearchResult,
 
32
    )
29
33
from bzrlib.revision import (
30
34
    NULL_REVISION,
31
35
    Revision,
33
37
from bzrlib.tests import (
34
38
    TestNotApplicable,
35
39
    )
36
 
from bzrlib.tests.interrepository_implementations import (
 
40
from bzrlib.tests.per_interrepository import (
37
41
    TestCaseWithInterRepository,
38
42
    )
39
 
from bzrlib.tests.interrepository_implementations.test_interrepository import (
 
43
from bzrlib.tests.per_interrepository.test_interrepository import (
40
44
    check_repo_format_for_funky_id_on_win32
41
45
    )
42
46
 
43
47
 
 
48
 
44
49
class TestInterRepository(TestCaseWithInterRepository):
45
50
 
 
51
    def disable_commit_write_group_paranoia(self, repo):
 
52
        pack_coll = getattr(repo, '_pack_collection', None)
 
53
        if pack_coll is not None:
 
54
            # Monkey-patch the pack collection instance to allow storing
 
55
            # incomplete revisions.
 
56
            pack_coll._check_new_inventories = lambda: []
 
57
 
46
58
    def test_fetch(self):
47
59
        tree_a = self.make_branch_and_tree('a')
48
60
        self.build_tree(['a/foo'])
51
63
        def check_push_rev1(repo):
52
64
            # ensure the revision is missing.
53
65
            self.assertRaises(NoSuchRevision, repo.get_revision, 'rev1')
54
 
            # fetch with a limit of NULL_REVISION and an explicit progress bar.
 
66
            # fetch with a limit of NULL_REVISION
55
67
            repo.fetch(tree_a.branch.repository,
56
 
                       revision_id=NULL_REVISION,
57
 
                       pb=bzrlib.progress.DummyProgress())
 
68
                       revision_id=NULL_REVISION)
58
69
            # nothing should have been pushed
59
70
            self.assertFalse(repo.has_revision('rev1'))
60
71
            # fetch with a default limit (grab everything)
69
80
                if tree.inventory[file_id].kind == "file":
70
81
                    tree.get_file(file_id).read()
71
82
 
72
 
        # makes a target version repo 
 
83
        # makes a target version repo
73
84
        repo_b = self.make_to_repository('b')
74
85
        check_push_rev1(repo_b)
75
86
 
 
87
    def test_fetch_inconsistent_last_changed_entries(self):
 
88
        """If an inventory has odd data we should still get what it references.
 
89
 
 
90
        This test tests that we do fetch a file text created in a revision not
 
91
        being fetched, but referenced from the revision we are fetching when the
 
92
        adjacent revisions to the one being fetched do not reference that text.
 
93
        """
 
94
        tree = self.make_branch_and_tree('source')
 
95
        revid = tree.commit('old')
 
96
        to_repo = self.make_to_repository('to_repo')
 
97
        to_repo.fetch(tree.branch.repository, revid)
 
98
        # Make a broken revision and fetch it.
 
99
        source = tree.branch.repository
 
100
        source.lock_write()
 
101
        self.addCleanup(source.unlock)
 
102
        source.start_write_group()
 
103
        try:
 
104
            # We need two revisions: OLD and NEW. NEW will claim to need a file
 
105
            # 'FOO' changed in 'OLD'. OLD will not have that file at all.
 
106
            source.texts.insert_record_stream([
 
107
                versionedfile.FulltextContentFactory(('foo', revid), (), None,
 
108
                'contents')])
 
109
            basis = source.revision_tree(revid)
 
110
            parent_id = basis.path2id('')
 
111
            entry = inventory.make_entry('file', 'foo-path', parent_id, 'foo')
 
112
            entry.revision = revid
 
113
            entry.text_size = len('contents')
 
114
            entry.text_sha1 = osutils.sha_string('contents')
 
115
            inv_sha1, _ = source.add_inventory_by_delta(revid, [
 
116
                (None, 'foo-path', 'foo', entry)], 'new', [revid])
 
117
            rev = Revision(timestamp=0,
 
118
                           timezone=None,
 
119
                           committer="Foo Bar <foo@example.com>",
 
120
                           message="Message",
 
121
                           inventory_sha1=inv_sha1,
 
122
                           revision_id='new',
 
123
                           parent_ids=[revid])
 
124
            source.add_revision(rev.revision_id, rev)
 
125
        except:
 
126
            source.abort_write_group()
 
127
            raise
 
128
        else:
 
129
            source.commit_write_group()
 
130
        to_repo.fetch(source, 'new')
 
131
        to_repo.lock_read()
 
132
        self.addCleanup(to_repo.unlock)
 
133
        self.assertEqual('contents',
 
134
            to_repo.texts.get_record_stream([('foo', revid)],
 
135
            'unordered', True).next().get_bytes_as('fulltext'))
 
136
 
 
137
    def test_fetch_from_stacked_smart(self):
 
138
        self.setup_smart_server_with_call_log()
 
139
        self.test_fetch_from_stacked()
 
140
 
 
141
    def test_fetch_from_stacked_smart_old(self):
 
142
        self.setup_smart_server_with_call_log()
 
143
        self.disable_verb('Repository.get_stream_1.19')
 
144
        self.test_fetch_from_stacked()
 
145
 
 
146
    def test_fetch_from_stacked(self):
 
147
        """Fetch from a stacked branch succeeds."""
 
148
        if not self.repository_format.supports_external_lookups:
 
149
            raise TestNotApplicable("Need stacking support in the source.")
 
150
        builder = self.make_branch_builder('full-branch')
 
151
        builder.start_series()
 
152
        builder.build_snapshot('first', None, [
 
153
            ('add', ('', 'root-id', 'directory', '')),
 
154
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
155
        builder.build_snapshot('second', ['first'], [
 
156
            ('modify', ('file-id', 'second content\n'))])
 
157
        builder.build_snapshot('third', ['second'], [
 
158
            ('modify', ('file-id', 'third content\n'))])
 
159
        builder.finish_series()
 
160
        branch = builder.get_branch()
 
161
        repo = self.make_repository('stacking-base')
 
162
        trunk = repo.bzrdir.create_branch()
 
163
        trunk.repository.fetch(branch.repository, 'second')
 
164
        repo = self.make_repository('stacked')
 
165
        stacked_branch = repo.bzrdir.create_branch()
 
166
        stacked_branch.set_stacked_on_url(trunk.base)
 
167
        stacked_branch.repository.fetch(branch.repository, 'third')
 
168
        target = self.make_to_repository('target')
 
169
        target.fetch(stacked_branch.repository, 'third')
 
170
        target.lock_read()
 
171
        self.addCleanup(target.unlock)
 
172
        all_revs = set(['first', 'second', 'third'])
 
173
        self.assertEqual(all_revs, set(target.get_parent_map(all_revs)))
 
174
 
 
175
    def test_fetch_parent_inventories_at_stacking_boundary_smart(self):
 
176
        self.setup_smart_server_with_call_log()
 
177
        self.test_fetch_parent_inventories_at_stacking_boundary()
 
178
 
 
179
    def test_fetch_parent_inventories_at_stacking_boundary_smart_old(self):
 
180
        self.setup_smart_server_with_call_log()
 
181
        self.disable_verb('Repository.insert_stream_1.19')
 
182
        self.test_fetch_parent_inventories_at_stacking_boundary()
 
183
 
 
184
    def test_fetch_parent_inventories_at_stacking_boundary(self):
 
185
        """Fetch to a stacked branch copies inventories for parents of
 
186
        revisions at the stacking boundary.
 
187
 
 
188
        This is necessary so that the server is able to determine the file-ids
 
189
        altered by all revisions it contains, which means that it needs both
 
190
        the inventory for any revision it has, and the inventories of all that
 
191
        revision's parents.
 
192
 
 
193
        However, we should also skip any revisions which are ghosts in the
 
194
        parents.
 
195
        """
 
196
        if not self.repository_format_to.supports_external_lookups:
 
197
            raise TestNotApplicable("Need stacking support in the target.")
 
198
        builder = self.make_branch_builder('branch')
 
199
        builder.start_series()
 
200
        builder.build_snapshot('base', None, [
 
201
            ('add', ('', 'root-id', 'directory', '')),
 
202
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
203
        builder.build_snapshot('left', ['base'], [
 
204
            ('modify', ('file-id', 'left content\n'))])
 
205
        builder.build_snapshot('right', ['base'], [
 
206
            ('modify', ('file-id', 'right content\n'))])
 
207
        builder.build_snapshot('merge', ['left', 'right'], [
 
208
            ('modify', ('file-id', 'left and right content\n'))])
 
209
        builder.finish_series()
 
210
        branch = builder.get_branch()
 
211
        repo = self.make_to_repository('trunk')
 
212
        trunk = repo.bzrdir.create_branch()
 
213
        trunk.repository.fetch(branch.repository, 'left')
 
214
        trunk.repository.fetch(branch.repository, 'right')
 
215
        repo = self.make_to_repository('stacked')
 
216
        stacked_branch = repo.bzrdir.create_branch()
 
217
        stacked_branch.set_stacked_on_url(trunk.base)
 
218
        stacked_branch.repository.fetch(branch.repository, 'merge')
 
219
        unstacked_repo = stacked_branch.bzrdir.open_repository()
 
220
        unstacked_repo.lock_read()
 
221
        self.addCleanup(unstacked_repo.unlock)
 
222
        self.assertFalse(unstacked_repo.has_revision('left'))
 
223
        self.assertFalse(unstacked_repo.has_revision('right'))
 
224
        self.assertEqual(
 
225
            set([('left',), ('right',), ('merge',)]),
 
226
            unstacked_repo.inventories.keys())
 
227
        # And the basis inventories have been copied correctly
 
228
        trunk.lock_read()
 
229
        self.addCleanup(trunk.unlock)
 
230
        left_tree, right_tree = trunk.repository.revision_trees(
 
231
            ['left', 'right'])
 
232
        stacked_branch.lock_read()
 
233
        self.addCleanup(stacked_branch.unlock)
 
234
        (stacked_left_tree,
 
235
         stacked_right_tree) = stacked_branch.repository.revision_trees(
 
236
            ['left', 'right'])
 
237
        self.assertEqual(left_tree.inventory, stacked_left_tree.inventory)
 
238
        self.assertEqual(right_tree.inventory, stacked_right_tree.inventory)
 
239
 
 
240
        # Finally, it's not enough to see that the basis inventories are
 
241
        # present.  The texts introduced in merge (and only those) should be
 
242
        # present, and also generating a stream should succeed without blowing
 
243
        # up.
 
244
        self.assertTrue(unstacked_repo.has_revision('merge'))
 
245
        expected_texts = set([('file-id', 'merge')])
 
246
        if stacked_branch.repository.texts.get_parent_map([('root-id',
 
247
            'merge')]):
 
248
            # If a (root-id,merge) text exists, it should be in the stacked
 
249
            # repo.
 
250
            expected_texts.add(('root-id', 'merge'))
 
251
        self.assertEqual(expected_texts, unstacked_repo.texts.keys())
 
252
        self.assertCanStreamRevision(unstacked_repo, 'merge')
 
253
 
 
254
    def assertCanStreamRevision(self, repo, revision_id):
 
255
        exclude_keys = set(repo.all_revision_ids()) - set([revision_id])
 
256
        search = SearchResult([revision_id], exclude_keys, 1, [revision_id])
 
257
        source = repo._get_source(repo._format)
 
258
        for substream_kind, substream in source.get_stream(search):
 
259
            # Consume the substream
 
260
            list(substream)
 
261
 
 
262
    def test_fetch_across_stacking_boundary_ignores_ghost(self):
 
263
        if not self.repository_format_to.supports_external_lookups:
 
264
            raise TestNotApplicable("Need stacking support in the target.")
 
265
        to_repo = self.make_to_repository('to')
 
266
        builder = self.make_branch_builder('branch')
 
267
        builder.start_series()
 
268
        builder.build_snapshot('base', None, [
 
269
            ('add', ('', 'root-id', 'directory', '')),
 
270
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
271
        builder.build_snapshot('second', ['base'], [
 
272
            ('modify', ('file-id', 'second content\n'))])
 
273
        builder.build_snapshot('third', ['second', 'ghost'], [
 
274
            ('modify', ('file-id', 'third content\n'))])
 
275
        builder.finish_series()
 
276
        branch = builder.get_branch()
 
277
        repo = self.make_to_repository('trunk')
 
278
        trunk = repo.bzrdir.create_branch()
 
279
        trunk.repository.fetch(branch.repository, 'second')
 
280
        repo = self.make_to_repository('stacked')
 
281
        stacked_branch = repo.bzrdir.create_branch()
 
282
        stacked_branch.set_stacked_on_url(trunk.base)
 
283
        stacked_branch.repository.fetch(branch.repository, 'third')
 
284
        unstacked_repo = stacked_branch.bzrdir.open_repository()
 
285
        unstacked_repo.lock_read()
 
286
        self.addCleanup(unstacked_repo.unlock)
 
287
        self.assertFalse(unstacked_repo.has_revision('second'))
 
288
        self.assertFalse(unstacked_repo.has_revision('ghost'))
 
289
        self.assertEqual(
 
290
            set([('second',), ('third',)]),
 
291
            unstacked_repo.inventories.keys())
 
292
        # And the basis inventories have been copied correctly
 
293
        trunk.lock_read()
 
294
        self.addCleanup(trunk.unlock)
 
295
        second_tree = trunk.repository.revision_tree('second')
 
296
        stacked_branch.lock_read()
 
297
        self.addCleanup(stacked_branch.unlock)
 
298
        stacked_second_tree = stacked_branch.repository.revision_tree('second')
 
299
        self.assertEqual(second_tree.inventory, stacked_second_tree.inventory)
 
300
        # Finally, it's not enough to see that the basis inventories are
 
301
        # present.  The texts introduced in merge (and only those) should be
 
302
        # present, and also generating a stream should succeed without blowing
 
303
        # up.
 
304
        self.assertTrue(unstacked_repo.has_revision('third'))
 
305
        expected_texts = set([('file-id', 'third')])
 
306
        if stacked_branch.repository.texts.get_parent_map([('root-id',
 
307
            'third')]):
 
308
            # If a (root-id,third) text exists, it should be in the stacked
 
309
            # repo.
 
310
            expected_texts.add(('root-id', 'third'))
 
311
        self.assertEqual(expected_texts, unstacked_repo.texts.keys())
 
312
        self.assertCanStreamRevision(unstacked_repo, 'third')
 
313
 
 
314
    def test_fetch_from_stacked_to_stacked_copies_parent_inventories(self):
 
315
        """Fetch from a stacked branch copies inventories for parents of
 
316
        revisions at the stacking boundary.
 
317
 
 
318
        Specifically, fetch will copy the parent inventories from the
 
319
        source for which the corresponding revisions are not present.  This
 
320
        will happen even when the source repository has no fallbacks configured
 
321
        (as is the case during upgrade).
 
322
        """
 
323
        if not self.repository_format.supports_external_lookups:
 
324
            raise TestNotApplicable("Need stacking support in the source.")
 
325
        if not self.repository_format_to.supports_external_lookups:
 
326
            raise TestNotApplicable("Need stacking support in the target.")
 
327
        builder = self.make_branch_builder('branch')
 
328
        builder.start_series()
 
329
        builder.build_snapshot('base', None, [
 
330
            ('add', ('', 'root-id', 'directory', '')),
 
331
            ('add', ('file', 'file-id', 'file', 'content\n'))])
 
332
        builder.build_snapshot('left', ['base'], [
 
333
            ('modify', ('file-id', 'left content\n'))])
 
334
        builder.build_snapshot('right', ['base'], [
 
335
            ('modify', ('file-id', 'right content\n'))])
 
336
        builder.build_snapshot('merge', ['left', 'right'], [
 
337
            ('modify', ('file-id', 'left and right content\n'))])
 
338
        builder.finish_series()
 
339
        branch = builder.get_branch()
 
340
        repo = self.make_repository('old-trunk')
 
341
        # Make a pair of equivalent trunk repos in the from and to formats.
 
342
        old_trunk = repo.bzrdir.create_branch()
 
343
        old_trunk.repository.fetch(branch.repository, 'left')
 
344
        old_trunk.repository.fetch(branch.repository, 'right')
 
345
        repo = self.make_to_repository('new-trunk')
 
346
        new_trunk = repo.bzrdir.create_branch()
 
347
        new_trunk.repository.fetch(branch.repository, 'left')
 
348
        new_trunk.repository.fetch(branch.repository, 'right')
 
349
        # Make the source; a repo stacked on old_trunk contained just the data
 
350
        # for 'merge'.
 
351
        repo = self.make_repository('old-stacked')
 
352
        old_stacked_branch = repo.bzrdir.create_branch()
 
353
        old_stacked_branch.set_stacked_on_url(old_trunk.base)
 
354
        old_stacked_branch.repository.fetch(branch.repository, 'merge')
 
355
        # Make the target, a repo stacked on new_trunk.
 
356
        repo = self.make_to_repository('new-stacked')
 
357
        new_stacked_branch = repo.bzrdir.create_branch()
 
358
        new_stacked_branch.set_stacked_on_url(new_trunk.base)
 
359
        old_unstacked_repo = old_stacked_branch.bzrdir.open_repository()
 
360
        new_unstacked_repo = new_stacked_branch.bzrdir.open_repository()
 
361
        # Reopen the source and target repos without any fallbacks, and fetch
 
362
        # 'merge'.
 
363
        new_unstacked_repo.fetch(old_unstacked_repo, 'merge')
 
364
        # Now check the results.  new_unstacked_repo should contain all the
 
365
        # data necessary to stream 'merge' (i.e. the parent inventories).
 
366
        new_unstacked_repo.lock_read()
 
367
        self.addCleanup(new_unstacked_repo.unlock)
 
368
        self.assertFalse(new_unstacked_repo.has_revision('left'))
 
369
        self.assertFalse(new_unstacked_repo.has_revision('right'))
 
370
        self.assertEqual(
 
371
            set([('left',), ('right',), ('merge',)]),
 
372
            new_unstacked_repo.inventories.keys())
 
373
        # And the basis inventories have been copied correctly
 
374
        new_trunk.lock_read()
 
375
        self.addCleanup(new_trunk.unlock)
 
376
        left_tree, right_tree = new_trunk.repository.revision_trees(
 
377
            ['left', 'right'])
 
378
        new_stacked_branch.lock_read()
 
379
        self.addCleanup(new_stacked_branch.unlock)
 
380
        (stacked_left_tree,
 
381
         stacked_right_tree) = new_stacked_branch.repository.revision_trees(
 
382
            ['left', 'right'])
 
383
        self.assertEqual(left_tree.inventory, stacked_left_tree.inventory)
 
384
        self.assertEqual(right_tree.inventory, stacked_right_tree.inventory)
 
385
        # Finally, it's not enough to see that the basis inventories are
 
386
        # present.  The texts introduced in merge (and only those) should be
 
387
        # present, and also generating a stream should succeed without blowing
 
388
        # up.
 
389
        self.assertTrue(new_unstacked_repo.has_revision('merge'))
 
390
        expected_texts = set([('file-id', 'merge')])
 
391
        if new_stacked_branch.repository.texts.get_parent_map([('root-id',
 
392
            'merge')]):
 
393
            # If a (root-id,merge) text exists, it should be in the stacked
 
394
            # repo.
 
395
            expected_texts.add(('root-id', 'merge'))
 
396
        self.assertEqual(expected_texts, new_unstacked_repo.texts.keys())
 
397
        self.assertCanStreamRevision(new_unstacked_repo, 'merge')
 
398
 
76
399
    def test_fetch_missing_basis_text(self):
77
400
        """If fetching a delta, we should die if a basis is not present."""
78
401
        tree = self.make_branch_and_tree('tree')
88
411
        to_repo.lock_write()
89
412
        try:
90
413
            to_repo.start_write_group()
91
 
            inv = tree.branch.repository.get_inventory('rev-one')
92
 
            to_repo.add_inventory('rev-one', inv, [])
93
 
            rev = tree.branch.repository.get_revision('rev-one')
94
 
            to_repo.add_revision('rev-one', rev, inv=inv)
95
 
            to_repo.commit_write_group()
 
414
            try:
 
415
                inv = tree.branch.repository.get_inventory('rev-one')
 
416
                to_repo.add_inventory('rev-one', inv, [])
 
417
                rev = tree.branch.repository.get_revision('rev-one')
 
418
                to_repo.add_revision('rev-one', rev, inv=inv)
 
419
                self.disable_commit_write_group_paranoia(to_repo)
 
420
                to_repo.commit_write_group()
 
421
            except:
 
422
                to_repo.abort_write_group(suppress_errors=True)
 
423
                raise
96
424
        finally:
97
425
            to_repo.unlock()
98
426
 
101
429
        # generally do).
102
430
        try:
103
431
            to_repo.fetch(tree.branch.repository, 'rev-two')
104
 
        except errors.RevisionNotPresent, e:
 
432
        except (errors.BzrCheckError, errors.RevisionNotPresent), e:
105
433
            # If an exception is raised, the revision should not be in the
106
434
            # target.
 
435
            #
 
436
            # Can also just raise a generic check errors; stream insertion
 
437
            # does this to include all the missing data
107
438
            self.assertRaises((errors.NoSuchRevision, errors.RevisionNotPresent),
108
439
                              to_repo.revision_tree, 'rev-two')
109
440
        else:
137
468
        source_tree = self.make_branch_and_tree('source')
138
469
        source = source_tree.branch.repository
139
470
        target = self.make_to_repository('target')
140
 
    
 
471
 
141
472
        # start by adding a file so the data knit for the file exists in
142
473
        # repositories that have specific files for each fileid.
143
474
        self.build_tree(['source/id'])
144
475
        source_tree.add(['id'], ['id'])
145
476
        source_tree.commit('a', rev_id='a')
146
477
        # now we manually insert a revision with an inventory referencing
147
 
        # 'id' at revision 'b', but we do not insert revision b.
 
478
        # file 'id' at revision 'b', but we do not insert revision b.
148
479
        # this should ensure that the new versions of files are being checked
149
480
        # for during pull operations
150
481
        inv = source.get_inventory('a')
162
493
                       revision_id='b')
163
494
        rev.parent_ids = ['a']
164
495
        source.add_revision('b', rev)
 
496
        self.disable_commit_write_group_paranoia(source)
165
497
        source.commit_write_group()
166
498
        self.assertRaises(errors.RevisionNotPresent, target.fetch, source)
167
499
        self.assertFalse(target.has_revision('b'))
183
515
        from_tree.commit('foo', rev_id='foo-id')
184
516
        to_repo = self.make_to_repository('to')
185
517
        to_repo.fetch(from_tree.branch.repository)
186
 
        recorded_inv_sha1 = to_repo.get_inventory_sha1('foo-id')
187
 
        xml = to_repo.get_inventory_xml('foo-id')
188
 
        computed_inv_sha1 = osutils.sha_string(xml)
 
518
        recorded_inv_sha1 = to_repo.get_revision('foo-id').inventory_sha1
 
519
        to_repo.lock_read()
 
520
        self.addCleanup(to_repo.unlock)
 
521
        stream = to_repo.inventories.get_record_stream([('foo-id',)],
 
522
                                                       'unordered', True)
 
523
        bytes = stream.next().get_bytes_as('fulltext')
 
524
        computed_inv_sha1 = osutils.sha_string(bytes)
189
525
        self.assertEqual(computed_inv_sha1, recorded_inv_sha1)
190
526
 
191
527