~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Author(s): Mark Hammond
  • Date: 2008-09-09 17:02:21 UTC
  • mto: This revision was merged to the branch mainline in revision 3697.
  • Revision ID: john@arbash-meinel.com-20080909170221-svim3jw2mrz0amp3
An updated transparent icon for bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
18
import sys
19
19
 
 
20
import bzrlib
20
21
from bzrlib import (
21
22
    errors,
22
 
    inventory,
 
23
    repository,
23
24
    osutils,
24
 
    repository,
25
 
    versionedfile,
26
25
    )
27
26
from bzrlib.errors import (
28
27
    NoSuchRevision,
29
28
    )
30
 
from bzrlib.vf_search import (
31
 
    SearchResult,
32
 
    )
33
29
from bzrlib.revision import (
34
30
    NULL_REVISION,
35
31
    Revision,
37
33
from bzrlib.tests import (
38
34
    TestNotApplicable,
39
35
    )
40
 
from bzrlib.tests.per_interrepository import (
 
36
from bzrlib.tests.interrepository_implementations import (
41
37
    TestCaseWithInterRepository,
42
38
    )
43
 
from bzrlib.tests.per_interrepository.test_interrepository import (
 
39
from bzrlib.tests.interrepository_implementations.test_interrepository import (
44
40
    check_repo_format_for_funky_id_on_win32
45
41
    )
46
42
 
47
43
 
48
 
 
49
44
class TestInterRepository(TestCaseWithInterRepository):
50
45
 
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
 
 
58
46
    def test_fetch(self):
59
47
        tree_a = self.make_branch_and_tree('a')
60
48
        self.build_tree(['a/foo'])
63
51
        def check_push_rev1(repo):
64
52
            # ensure the revision is missing.
65
53
            self.assertRaises(NoSuchRevision, repo.get_revision, 'rev1')
66
 
            # fetch with a limit of NULL_REVISION
 
54
            # fetch with a limit of NULL_REVISION and an explicit progress bar.
67
55
            repo.fetch(tree_a.branch.repository,
68
 
                       revision_id=NULL_REVISION)
 
56
                       revision_id=NULL_REVISION,
 
57
                       pb=bzrlib.progress.DummyProgress())
69
58
            # nothing should have been pushed
70
59
            self.assertFalse(repo.has_revision('rev1'))
71
60
            # fetch with a default limit (grab everything)
76
65
            tree.lock_read()
77
66
            self.addCleanup(tree.unlock)
78
67
            tree.get_file_text('file1')
79
 
            for file_id in tree.all_file_ids():
80
 
                if tree.kind(file_id) == "file":
 
68
            for file_id in tree:
 
69
                if tree.inventory[file_id].kind == "file":
81
70
                    tree.get_file(file_id).read()
82
71
 
83
 
        # makes a target version repo
 
72
        # makes a target version repo 
84
73
        repo_b = self.make_to_repository('b')
85
74
        check_push_rev1(repo_b)
86
75
 
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
 
        try:
183
 
            self.test_fetch_parent_inventories_at_stacking_boundary()
184
 
        except errors.ConnectionReset:
185
 
            self.knownFailure("Random spurious failure, see bug 874153")
186
 
 
187
 
    def test_fetch_parent_inventories_at_stacking_boundary(self):
188
 
        """Fetch to a stacked branch copies inventories for parents of
189
 
        revisions at the stacking boundary.
190
 
 
191
 
        This is necessary so that the server is able to determine the file-ids
192
 
        altered by all revisions it contains, which means that it needs both
193
 
        the inventory for any revision it has, and the inventories of all that
194
 
        revision's parents.
195
 
 
196
 
        However, we should also skip any revisions which are ghosts in the
197
 
        parents.
198
 
        """
199
 
        if not self.repository_format_to.supports_external_lookups:
200
 
            raise TestNotApplicable("Need stacking support in the target.")
201
 
        builder = self.make_branch_builder('branch')
202
 
        builder.start_series()
203
 
        builder.build_snapshot('base', None, [
204
 
            ('add', ('', 'root-id', 'directory', '')),
205
 
            ('add', ('file', 'file-id', 'file', 'content\n'))])
206
 
        builder.build_snapshot('left', ['base'], [
207
 
            ('modify', ('file-id', 'left content\n'))])
208
 
        builder.build_snapshot('right', ['base'], [
209
 
            ('modify', ('file-id', 'right content\n'))])
210
 
        builder.build_snapshot('merge', ['left', 'right'], [
211
 
            ('modify', ('file-id', 'left and right content\n'))])
212
 
        builder.finish_series()
213
 
        branch = builder.get_branch()
214
 
        repo = self.make_to_repository('trunk')
215
 
        trunk = repo.bzrdir.create_branch()
216
 
        trunk.repository.fetch(branch.repository, 'left')
217
 
        trunk.repository.fetch(branch.repository, 'right')
218
 
        repo = self.make_to_repository('stacked')
219
 
        stacked_branch = repo.bzrdir.create_branch()
220
 
        stacked_branch.set_stacked_on_url(trunk.base)
221
 
        stacked_branch.repository.fetch(branch.repository, 'merge')
222
 
        unstacked_repo = stacked_branch.bzrdir.open_repository()
223
 
        unstacked_repo.lock_read()
224
 
        self.addCleanup(unstacked_repo.unlock)
225
 
        self.assertFalse(unstacked_repo.has_revision('left'))
226
 
        self.assertFalse(unstacked_repo.has_revision('right'))
227
 
        self.assertEqual(
228
 
            set([('left',), ('right',), ('merge',)]),
229
 
            unstacked_repo.inventories.keys())
230
 
        # And the basis inventories have been copied correctly
231
 
        trunk.lock_read()
232
 
        self.addCleanup(trunk.unlock)
233
 
        left_tree, right_tree = trunk.repository.revision_trees(
234
 
            ['left', 'right'])
235
 
        stacked_branch.lock_read()
236
 
        self.addCleanup(stacked_branch.unlock)
237
 
        (stacked_left_tree,
238
 
         stacked_right_tree) = stacked_branch.repository.revision_trees(
239
 
            ['left', 'right'])
240
 
        self.assertEqual(
241
 
            left_tree.root_inventory, stacked_left_tree.root_inventory)
242
 
        self.assertEqual(
243
 
            right_tree.root_inventory, stacked_right_tree.root_inventory)
244
 
 
245
 
        # Finally, it's not enough to see that the basis inventories are
246
 
        # present.  The texts introduced in merge (and only those) should be
247
 
        # present, and also generating a stream should succeed without blowing
248
 
        # up.
249
 
        self.assertTrue(unstacked_repo.has_revision('merge'))
250
 
        expected_texts = set([('file-id', 'merge')])
251
 
        if stacked_branch.repository.texts.get_parent_map([('root-id',
252
 
            'merge')]):
253
 
            # If a (root-id,merge) text exists, it should be in the stacked
254
 
            # repo.
255
 
            expected_texts.add(('root-id', 'merge'))
256
 
        self.assertEqual(expected_texts, unstacked_repo.texts.keys())
257
 
        self.assertCanStreamRevision(unstacked_repo, 'merge')
258
 
 
259
 
    def assertCanStreamRevision(self, repo, revision_id):
260
 
        exclude_keys = set(repo.all_revision_ids()) - set([revision_id])
261
 
        search = SearchResult([revision_id], exclude_keys, 1, [revision_id])
262
 
        source = repo._get_source(repo._format)
263
 
        for substream_kind, substream in source.get_stream(search):
264
 
            # Consume the substream
265
 
            list(substream)
266
 
 
267
 
    def test_fetch_across_stacking_boundary_ignores_ghost(self):
268
 
        if not self.repository_format_to.supports_external_lookups:
269
 
            raise TestNotApplicable("Need stacking support in the target.")
270
 
        to_repo = self.make_to_repository('to')
271
 
        builder = self.make_branch_builder('branch')
272
 
        builder.start_series()
273
 
        builder.build_snapshot('base', None, [
274
 
            ('add', ('', 'root-id', 'directory', '')),
275
 
            ('add', ('file', 'file-id', 'file', 'content\n'))])
276
 
        builder.build_snapshot('second', ['base'], [
277
 
            ('modify', ('file-id', 'second content\n'))])
278
 
        builder.build_snapshot('third', ['second', 'ghost'], [
279
 
            ('modify', ('file-id', 'third content\n'))])
280
 
        builder.finish_series()
281
 
        branch = builder.get_branch()
282
 
        repo = self.make_to_repository('trunk')
283
 
        trunk = repo.bzrdir.create_branch()
284
 
        trunk.repository.fetch(branch.repository, 'second')
285
 
        repo = self.make_to_repository('stacked')
286
 
        stacked_branch = repo.bzrdir.create_branch()
287
 
        stacked_branch.set_stacked_on_url(trunk.base)
288
 
        stacked_branch.repository.fetch(branch.repository, 'third')
289
 
        unstacked_repo = stacked_branch.bzrdir.open_repository()
290
 
        unstacked_repo.lock_read()
291
 
        self.addCleanup(unstacked_repo.unlock)
292
 
        self.assertFalse(unstacked_repo.has_revision('second'))
293
 
        self.assertFalse(unstacked_repo.has_revision('ghost'))
294
 
        self.assertEqual(
295
 
            set([('second',), ('third',)]),
296
 
            unstacked_repo.inventories.keys())
297
 
        # And the basis inventories have been copied correctly
298
 
        trunk.lock_read()
299
 
        self.addCleanup(trunk.unlock)
300
 
        second_tree = trunk.repository.revision_tree('second')
301
 
        stacked_branch.lock_read()
302
 
        self.addCleanup(stacked_branch.unlock)
303
 
        stacked_second_tree = stacked_branch.repository.revision_tree('second')
304
 
        self.assertEqual(second_tree, stacked_second_tree)
305
 
        # Finally, it's not enough to see that the basis inventories are
306
 
        # present.  The texts introduced in merge (and only those) should be
307
 
        # present, and also generating a stream should succeed without blowing
308
 
        # up.
309
 
        self.assertTrue(unstacked_repo.has_revision('third'))
310
 
        expected_texts = set([('file-id', 'third')])
311
 
        if stacked_branch.repository.texts.get_parent_map([('root-id',
312
 
            'third')]):
313
 
            # If a (root-id,third) text exists, it should be in the stacked
314
 
            # repo.
315
 
            expected_texts.add(('root-id', 'third'))
316
 
        self.assertEqual(expected_texts, unstacked_repo.texts.keys())
317
 
        self.assertCanStreamRevision(unstacked_repo, 'third')
318
 
 
319
 
    def test_fetch_from_stacked_to_stacked_copies_parent_inventories(self):
320
 
        """Fetch from a stacked branch copies inventories for parents of
321
 
        revisions at the stacking boundary.
322
 
 
323
 
        Specifically, fetch will copy the parent inventories from the
324
 
        source for which the corresponding revisions are not present.  This
325
 
        will happen even when the source repository has no fallbacks configured
326
 
        (as is the case during upgrade).
327
 
        """
328
 
        if not self.repository_format.supports_external_lookups:
329
 
            raise TestNotApplicable("Need stacking support in the source.")
330
 
        if not self.repository_format_to.supports_external_lookups:
331
 
            raise TestNotApplicable("Need stacking support in the target.")
332
 
        builder = self.make_branch_builder('branch')
333
 
        builder.start_series()
334
 
        builder.build_snapshot('base', None, [
335
 
            ('add', ('', 'root-id', 'directory', '')),
336
 
            ('add', ('file', 'file-id', 'file', 'content\n'))])
337
 
        builder.build_snapshot('left', ['base'], [
338
 
            ('modify', ('file-id', 'left content\n'))])
339
 
        builder.build_snapshot('right', ['base'], [
340
 
            ('modify', ('file-id', 'right content\n'))])
341
 
        builder.build_snapshot('merge', ['left', 'right'], [
342
 
            ('modify', ('file-id', 'left and right content\n'))])
343
 
        builder.finish_series()
344
 
        branch = builder.get_branch()
345
 
        repo = self.make_repository('old-trunk')
346
 
        # Make a pair of equivalent trunk repos in the from and to formats.
347
 
        old_trunk = repo.bzrdir.create_branch()
348
 
        old_trunk.repository.fetch(branch.repository, 'left')
349
 
        old_trunk.repository.fetch(branch.repository, 'right')
350
 
        repo = self.make_to_repository('new-trunk')
351
 
        new_trunk = repo.bzrdir.create_branch()
352
 
        new_trunk.repository.fetch(branch.repository, 'left')
353
 
        new_trunk.repository.fetch(branch.repository, 'right')
354
 
        # Make the source; a repo stacked on old_trunk contained just the data
355
 
        # for 'merge'.
356
 
        repo = self.make_repository('old-stacked')
357
 
        old_stacked_branch = repo.bzrdir.create_branch()
358
 
        old_stacked_branch.set_stacked_on_url(old_trunk.base)
359
 
        old_stacked_branch.repository.fetch(branch.repository, 'merge')
360
 
        # Make the target, a repo stacked on new_trunk.
361
 
        repo = self.make_to_repository('new-stacked')
362
 
        new_stacked_branch = repo.bzrdir.create_branch()
363
 
        new_stacked_branch.set_stacked_on_url(new_trunk.base)
364
 
        old_unstacked_repo = old_stacked_branch.bzrdir.open_repository()
365
 
        new_unstacked_repo = new_stacked_branch.bzrdir.open_repository()
366
 
        # Reopen the source and target repos without any fallbacks, and fetch
367
 
        # 'merge'.
368
 
        new_unstacked_repo.fetch(old_unstacked_repo, 'merge')
369
 
        # Now check the results.  new_unstacked_repo should contain all the
370
 
        # data necessary to stream 'merge' (i.e. the parent inventories).
371
 
        new_unstacked_repo.lock_read()
372
 
        self.addCleanup(new_unstacked_repo.unlock)
373
 
        self.assertFalse(new_unstacked_repo.has_revision('left'))
374
 
        self.assertFalse(new_unstacked_repo.has_revision('right'))
375
 
        self.assertEqual(
376
 
            set([('left',), ('right',), ('merge',)]),
377
 
            new_unstacked_repo.inventories.keys())
378
 
        # And the basis inventories have been copied correctly
379
 
        new_trunk.lock_read()
380
 
        self.addCleanup(new_trunk.unlock)
381
 
        left_tree, right_tree = new_trunk.repository.revision_trees(
382
 
            ['left', 'right'])
383
 
        new_stacked_branch.lock_read()
384
 
        self.addCleanup(new_stacked_branch.unlock)
385
 
        (stacked_left_tree,
386
 
         stacked_right_tree) = new_stacked_branch.repository.revision_trees(
387
 
            ['left', 'right'])
388
 
        self.assertEqual(left_tree, stacked_left_tree)
389
 
        self.assertEqual(right_tree, stacked_right_tree)
390
 
        # Finally, it's not enough to see that the basis inventories are
391
 
        # present.  The texts introduced in merge (and only those) should be
392
 
        # present, and also generating a stream should succeed without blowing
393
 
        # up.
394
 
        self.assertTrue(new_unstacked_repo.has_revision('merge'))
395
 
        expected_texts = set([('file-id', 'merge')])
396
 
        if new_stacked_branch.repository.texts.get_parent_map([('root-id',
397
 
            'merge')]):
398
 
            # If a (root-id,merge) text exists, it should be in the stacked
399
 
            # repo.
400
 
            expected_texts.add(('root-id', 'merge'))
401
 
        self.assertEqual(expected_texts, new_unstacked_repo.texts.keys())
402
 
        self.assertCanStreamRevision(new_unstacked_repo, 'merge')
403
 
 
404
76
    def test_fetch_missing_basis_text(self):
405
77
        """If fetching a delta, we should die if a basis is not present."""
406
78
        tree = self.make_branch_and_tree('tree')
416
88
        to_repo.lock_write()
417
89
        try:
418
90
            to_repo.start_write_group()
419
 
            try:
420
 
                inv = tree.branch.repository.get_inventory('rev-one')
421
 
                to_repo.add_inventory('rev-one', inv, [])
422
 
                rev = tree.branch.repository.get_revision('rev-one')
423
 
                to_repo.add_revision('rev-one', rev, inv=inv)
424
 
                self.disable_commit_write_group_paranoia(to_repo)
425
 
                to_repo.commit_write_group()
426
 
            except:
427
 
                to_repo.abort_write_group(suppress_errors=True)
428
 
                raise
 
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()
429
96
        finally:
430
97
            to_repo.unlock()
431
98
 
434
101
        # generally do).
435
102
        try:
436
103
            to_repo.fetch(tree.branch.repository, 'rev-two')
437
 
        except (errors.BzrCheckError, errors.RevisionNotPresent), e:
 
104
        except errors.RevisionNotPresent, e:
438
105
            # If an exception is raised, the revision should not be in the
439
106
            # target.
440
 
            #
441
 
            # Can also just raise a generic check errors; stream insertion
442
 
            # does this to include all the missing data
443
107
            self.assertRaises((errors.NoSuchRevision, errors.RevisionNotPresent),
444
108
                              to_repo.revision_tree, 'rev-two')
445
109
        else:
456
120
    def test_fetch_missing_revision_same_location_fails(self):
457
121
        repo_a = self.make_repository('.')
458
122
        repo_b = repository.Repository.open('.')
459
 
        self.assertRaises(errors.NoSuchRevision,
460
 
            repo_b.fetch, repo_a, revision_id='XXX')
 
123
        try:
 
124
            self.assertRaises(errors.NoSuchRevision, repo_b.fetch, repo_a, revision_id='XXX')
 
125
        except errors.LockError, e:
 
126
            check_old_format_lock_error(self.repository_format)
461
127
 
462
128
    def test_fetch_same_location_trivial_works(self):
463
129
        repo_a = self.make_repository('.')
464
130
        repo_b = repository.Repository.open('.')
465
 
        repo_a.fetch(repo_b)
 
131
        try:
 
132
            repo_a.fetch(repo_b)
 
133
        except errors.LockError, e:
 
134
            check_old_format_lock_error(self.repository_format)
466
135
 
467
136
    def test_fetch_missing_text_other_location_fails(self):
468
137
        source_tree = self.make_branch_and_tree('source')
469
138
        source = source_tree.branch.repository
470
139
        target = self.make_to_repository('target')
471
 
 
 
140
    
472
141
        # start by adding a file so the data knit for the file exists in
473
142
        # repositories that have specific files for each fileid.
474
143
        self.build_tree(['source/id'])
475
144
        source_tree.add(['id'], ['id'])
476
145
        source_tree.commit('a', rev_id='a')
477
146
        # now we manually insert a revision with an inventory referencing
478
 
        # file 'id' at revision 'b', but we do not insert revision b.
 
147
        # 'id' at revision 'b', but we do not insert revision b.
479
148
        # this should ensure that the new versions of files are being checked
480
149
        # for during pull operations
481
150
        inv = source.get_inventory('a')
493
162
                       revision_id='b')
494
163
        rev.parent_ids = ['a']
495
164
        source.add_revision('b', rev)
496
 
        self.disable_commit_write_group_paranoia(source)
497
165
        source.commit_write_group()
498
166
        self.assertRaises(errors.RevisionNotPresent, target.fetch, source)
499
167
        self.assertFalse(target.has_revision('b'))
515
183
        from_tree.commit('foo', rev_id='foo-id')
516
184
        to_repo = self.make_to_repository('to')
517
185
        to_repo.fetch(from_tree.branch.repository)
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)
 
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)
525
189
        self.assertEqual(computed_inv_sha1, recorded_inv_sha1)
526
190
 
527
191