36
36
from bzrlib.tests.interrepository_implementations import (
37
37
TestCaseWithInterRepository,
39
from bzrlib.tests.interrepository_implementations.test_interrepository import (
40
check_repo_format_for_funky_id_on_win32
41
44
class TestInterRepository(TestCaseWithInterRepository):
66
69
if tree.inventory[file_id].kind == "file":
67
70
tree.get_file(file_id).read()
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)
96
# Implementations can either copy the missing basis text, or raise an
99
# Implementations can either ensure that the target of the delta is
100
# reconstructable, or raise an exception (which stream based copies
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
104
(errors.NoSuchRevision, errors.RevisionNotPresent),
105
to_repo.revision_tree, 'rev-two')
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')
107
# If not exception is raised, then the basis text should be
113
# If not exception is raised, then the text should be
109
115
to_repo.lock_read()
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'))
118
124
repo_a = self.make_repository('.')
119
125
repo_b = repository.Repository.open('.')
121
self.assertRaises(errors.NoSuchRevision, repo_b.fetch, repo_a,
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)
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')
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])
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()
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)]))