/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/interrepository_implementations/test_fetch.py

  • Committer: Robert Collins
  • Date: 2009-03-13 02:25:46 UTC
  • mfrom: (4133 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4183.
  • Revision ID: robertc@robertcollins.net-20090313022546-e7de5zsdkbay5okf
MergeĀ .dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import bzrlib
21
21
from bzrlib import (
22
22
    errors,
 
23
    inventory,
 
24
    osutils,
23
25
    repository,
24
 
    osutils,
 
26
    versionedfile,
25
27
    )
26
28
from bzrlib.errors import (
27
29
    NoSuchRevision,
69
71
                if tree.inventory[file_id].kind == "file":
70
72
                    tree.get_file(file_id).read()
71
73
 
72
 
        # makes a target version repo 
 
74
        # makes a target version repo
73
75
        repo_b = self.make_to_repository('b')
74
76
        check_push_rev1(repo_b)
75
77
 
 
78
    def test_fetch_inconsistent_last_changed_entries(self):
 
79
        """If an inventory has odd data we should still get what it references.
 
80
        
 
81
        This test tests that we do fetch a file text created in a revision not
 
82
        being fetched, but referenced from the revision we are fetching when the
 
83
        adjacent revisions to the one being fetched do not reference that text.
 
84
        """
 
85
        tree = self.make_branch_and_tree('source')
 
86
        revid = tree.commit('old')
 
87
        to_repo = self.make_to_repository('to_repo')
 
88
        to_repo.fetch(tree.branch.repository, revid)
 
89
        # Make a broken revision and fetch it.
 
90
        source = tree.branch.repository
 
91
        source.lock_write()
 
92
        self.addCleanup(source.unlock)
 
93
        source.start_write_group()
 
94
        try:
 
95
            # We need two revisions: OLD and NEW. NEW will claim to need a file
 
96
            # 'FOO' changed in 'OLD'. OLD will not have that file at all.
 
97
            source.texts.insert_record_stream([
 
98
                versionedfile.FulltextContentFactory(('foo', revid), (), None,
 
99
                'contents')])
 
100
            basis = source.revision_tree(revid)
 
101
            parent_id = basis.path2id('')
 
102
            entry = inventory.make_entry('file', 'foo-path', parent_id, 'foo')
 
103
            entry.revision = revid
 
104
            entry.text_size = len('contents')
 
105
            entry.text_sha1 = osutils.sha_string('contents')
 
106
            inv_sha1, _ = source.add_inventory_by_delta(revid, [
 
107
                (None, 'foo-path', 'foo', entry)], 'new', [revid])
 
108
            rev = Revision(timestamp=0,
 
109
                           timezone=None,
 
110
                           committer="Foo Bar <foo@example.com>",
 
111
                           message="Message",
 
112
                           inventory_sha1=inv_sha1,
 
113
                           revision_id='new',
 
114
                           parent_ids=[revid])
 
115
            source.add_revision(rev.revision_id, rev)
 
116
        except:
 
117
            source.abort_write_group()
 
118
            raise
 
119
        else:
 
120
            source.commit_write_group()
 
121
        to_repo.fetch(source, 'new')
 
122
        to_repo.lock_read()
 
123
        self.addCleanup(to_repo.unlock)
 
124
        self.assertEqual('contents',
 
125
            to_repo.texts.get_record_stream([('foo', revid)],
 
126
            'unordered', True).next().get_bytes_as('fulltext'))
 
127
 
76
128
    def test_fetch_missing_basis_text(self):
77
129
        """If fetching a delta, we should die if a basis is not present."""
78
130
        tree = self.make_branch_and_tree('tree')
101
153
        # generally do).
102
154
        try:
103
155
            to_repo.fetch(tree.branch.repository, 'rev-two')
104
 
        except errors.RevisionNotPresent, e:
 
156
        except (errors.BzrCheckError, errors.RevisionNotPresent), e:
105
157
            # If an exception is raised, the revision should not be in the
106
158
            # target.
 
159
            #
 
160
            # Can also just raise a generic check errors; stream insertion
 
161
            # does this to include all the missing data
107
162
            self.assertRaises((errors.NoSuchRevision, errors.RevisionNotPresent),
108
163
                              to_repo.revision_tree, 'rev-two')
109
164
        else:
137
192
        source_tree = self.make_branch_and_tree('source')
138
193
        source = source_tree.branch.repository
139
194
        target = self.make_to_repository('target')
140
 
    
 
195
 
141
196
        # start by adding a file so the data knit for the file exists in
142
197
        # repositories that have specific files for each fileid.
143
198
        self.build_tree(['source/id'])