~jelmer/ubuntu/maverick/bzr/2.2.5

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2009-03-10 14:11:59 UTC
  • mfrom: (1.2.1 upstream) (3.1.68 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090310141159-lwzzo5c1fwrtzgj4
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
from bzrlib.tests.interrepository_implementations import (
37
37
    TestCaseWithInterRepository,
38
38
    )
 
39
from bzrlib.tests.interrepository_implementations.test_interrepository import (
 
40
    check_repo_format_for_funky_id_on_win32
 
41
    )
39
42
 
40
43
 
41
44
class TestInterRepository(TestCaseWithInterRepository):
66
69
                if tree.inventory[file_id].kind == "file":
67
70
                    tree.get_file(file_id).read()
68
71
 
69
 
        # makes a target version repo 
 
72
        # makes a target version repo
70
73
        repo_b = self.make_to_repository('b')
71
74
        check_push_rev1(repo_b)
72
75
 
93
96
        finally:
94
97
            to_repo.unlock()
95
98
 
96
 
        # Implementations can either copy the missing basis text, or raise an
97
 
        # exception
 
99
        # Implementations can either ensure that the target of the delta is
 
100
        # reconstructable, or raise an exception (which stream based copies
 
101
        # generally do).
98
102
        try:
99
103
            to_repo.fetch(tree.branch.repository, 'rev-two')
100
 
        except errors.RevisionNotPresent, e:
 
104
        except (errors.BzrCheckError, errors.RevisionNotPresent), e:
101
105
            # If an exception is raised, the revision should not be in the
102
106
            # target.
103
 
            self.assertRaises(
104
 
                (errors.NoSuchRevision, errors.RevisionNotPresent),
105
 
                 to_repo.revision_tree, 'rev-two')
 
107
            #
 
108
            # Can also just raise a generic check errors; stream insertion
 
109
            # does this to include all the missing data
 
110
            self.assertRaises((errors.NoSuchRevision, errors.RevisionNotPresent),
 
111
                              to_repo.revision_tree, 'rev-two')
106
112
        else:
107
 
            # If not exception is raised, then the basis text should be
 
113
            # If not exception is raised, then the text should be
108
114
            # available.
109
115
            to_repo.lock_read()
110
116
            try:
111
 
                rt = to_repo.revision_tree('rev-one')
112
 
                self.assertEqual('contents of tree/a\n',
 
117
                rt = to_repo.revision_tree('rev-two')
 
118
                self.assertEqual('new contents\n',
113
119
                                 rt.get_file_text('a-id'))
114
120
            finally:
115
121
                to_repo.unlock()
118
124
        repo_a = self.make_repository('.')
119
125
        repo_b = repository.Repository.open('.')
120
126
        try:
121
 
            self.assertRaises(errors.NoSuchRevision, repo_b.fetch, repo_a,
122
 
                              revision_id='XXX')
 
127
            self.assertRaises(errors.NoSuchRevision, repo_b.fetch, repo_a, revision_id='XXX')
123
128
        except errors.LockError, e:
124
129
            check_old_format_lock_error(self.repository_format)
125
130
 
135
140
        source_tree = self.make_branch_and_tree('source')
136
141
        source = source_tree.branch.repository
137
142
        target = self.make_to_repository('target')
138
 
    
 
143
 
139
144
        # start by adding a file so the data knit for the file exists in
140
145
        # repositories that have specific files for each fileid.
141
146
        self.build_tree(['source/id'])
173
178
        from_tree.add('filename', 'funky-chars<>%&;"\'')
174
179
        from_tree.commit('commit filename')
175
180
        to_repo = self.make_to_repository('to')
176
 
        to_repo.fetch(from_tree.branch.repository,
177
 
                      from_tree.get_parent_ids()[0])
 
181
        to_repo.fetch(from_tree.branch.repository, from_tree.get_parent_ids()[0])
178
182
 
179
183
    def test_fetch_revision_hash(self):
180
184
        """Ensure that inventory hashes are updated by fetch"""
207
211
        to_repo.fetch(from_tree.branch.repository, tree_rev)
208
212
        # to_repo should have a file_graph for from_tree.path2id('subtree') and
209
213
        # revid tree_rev.
 
214
        file_id = from_tree.path2id('subtree')
210
215
        to_repo.lock_read()
211
216
        try:
212
 
            file_vf = to_repo.weave_store.get_weave(
213
 
                from_tree.path2id('subtree'), to_repo.get_transaction())
214
 
            self.assertEqual([tree_rev], file_vf.get_ancestry([tree_rev]))
 
217
            self.assertEqual({(file_id, tree_rev):()},
 
218
                to_repo.texts.get_parent_map([(file_id, tree_rev)]))
215
219
        finally:
216
220
            to_repo.unlock()