bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
1 |
# Copyright (C) 2005, 2006, 2008 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
16 |
|
17 |
||
18 |
import sys |
|
19 |
||
20 |
import bzrlib |
|
21 |
from bzrlib import ( |
|
22 |
errors, |
|
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
23 |
inventory, |
24 |
osutils, |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
25 |
repository, |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
26 |
versionedfile, |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
27 |
)
|
28 |
from bzrlib.errors import ( |
|
29 |
NoSuchRevision, |
|
30 |
)
|
|
|
4476.3.11
by Andrew Bennetts
All fetch and interrepo tests passing. |
31 |
from bzrlib.graph import ( |
32 |
SearchResult, |
|
33 |
)
|
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
34 |
from bzrlib.revision import ( |
35 |
NULL_REVISION, |
|
36 |
Revision, |
|
37 |
)
|
|
38 |
from bzrlib.tests import ( |
|
39 |
TestNotApplicable, |
|
40 |
)
|
|
|
4523.1.3
by Martin Pool
Rename to per_interrepository |
41 |
from bzrlib.tests.per_interrepository import ( |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
42 |
TestCaseWithInterRepository, |
43 |
)
|
|
|
4523.1.3
by Martin Pool
Rename to per_interrepository |
44 |
from bzrlib.tests.per_interrepository.test_interrepository import ( |
|
3616.2.3
by Mark Hammond
Fix test failures due to missing check_repo_format_for_funky_id_on_win32 |
45 |
check_repo_format_for_funky_id_on_win32
|
46 |
)
|
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
47 |
|
48 |
||
49 |
class TestInterRepository(TestCaseWithInterRepository): |
|
50 |
||
51 |
def test_fetch(self): |
|
52 |
tree_a = self.make_branch_and_tree('a') |
|
53 |
self.build_tree(['a/foo']) |
|
54 |
tree_a.add('foo', 'file1') |
|
55 |
tree_a.commit('rev1', rev_id='rev1') |
|
56 |
def check_push_rev1(repo): |
|
57 |
# ensure the revision is missing.
|
|
58 |
self.assertRaises(NoSuchRevision, repo.get_revision, 'rev1') |
|
|
4110.2.5
by Martin Pool
Deprecate passing pbs in to fetch() |
59 |
# fetch with a limit of NULL_REVISION
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
60 |
repo.fetch(tree_a.branch.repository, |
|
4110.2.5
by Martin Pool
Deprecate passing pbs in to fetch() |
61 |
revision_id=NULL_REVISION) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
62 |
# nothing should have been pushed
|
63 |
self.assertFalse(repo.has_revision('rev1')) |
|
64 |
# fetch with a default limit (grab everything)
|
|
65 |
repo.fetch(tree_a.branch.repository) |
|
66 |
# check that b now has all the data from a's first commit.
|
|
67 |
rev = repo.get_revision('rev1') |
|
68 |
tree = repo.revision_tree('rev1') |
|
69 |
tree.lock_read() |
|
70 |
self.addCleanup(tree.unlock) |
|
71 |
tree.get_file_text('file1') |
|
72 |
for file_id in tree: |
|
73 |
if tree.inventory[file_id].kind == "file": |
|
74 |
tree.get_file(file_id).read() |
|
75 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
76 |
# makes a target version repo
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
77 |
repo_b = self.make_to_repository('b') |
78 |
check_push_rev1(repo_b) |
|
79 |
||
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
80 |
def test_fetch_inconsistent_last_changed_entries(self): |
81 |
"""If an inventory has odd data we should still get what it references. |
|
|
3735.31.2
by John Arbash Meinel
Cleanup trailing whitespace, get test_source to pass by removing asserts. |
82 |
|
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
83 |
This test tests that we do fetch a file text created in a revision not
|
84 |
being fetched, but referenced from the revision we are fetching when the
|
|
85 |
adjacent revisions to the one being fetched do not reference that text.
|
|
86 |
"""
|
|
87 |
tree = self.make_branch_and_tree('source') |
|
88 |
revid = tree.commit('old') |
|
89 |
to_repo = self.make_to_repository('to_repo') |
|
90 |
to_repo.fetch(tree.branch.repository, revid) |
|
91 |
# Make a broken revision and fetch it.
|
|
92 |
source = tree.branch.repository |
|
93 |
source.lock_write() |
|
94 |
self.addCleanup(source.unlock) |
|
95 |
source.start_write_group() |
|
96 |
try: |
|
97 |
# We need two revisions: OLD and NEW. NEW will claim to need a file
|
|
98 |
# 'FOO' changed in 'OLD'. OLD will not have that file at all.
|
|
99 |
source.texts.insert_record_stream([ |
|
100 |
versionedfile.FulltextContentFactory(('foo', revid), (), None, |
|
101 |
'contents')]) |
|
102 |
basis = source.revision_tree(revid) |
|
103 |
parent_id = basis.path2id('') |
|
104 |
entry = inventory.make_entry('file', 'foo-path', parent_id, 'foo') |
|
105 |
entry.revision = revid |
|
106 |
entry.text_size = len('contents') |
|
107 |
entry.text_sha1 = osutils.sha_string('contents') |
|
108 |
inv_sha1, _ = source.add_inventory_by_delta(revid, [ |
|
109 |
(None, 'foo-path', 'foo', entry)], 'new', [revid]) |
|
110 |
rev = Revision(timestamp=0, |
|
111 |
timezone=None, |
|
112 |
committer="Foo Bar <foo@example.com>", |
|
113 |
message="Message", |
|
114 |
inventory_sha1=inv_sha1, |
|
115 |
revision_id='new', |
|
116 |
parent_ids=[revid]) |
|
117 |
source.add_revision(rev.revision_id, rev) |
|
118 |
except: |
|
119 |
source.abort_write_group() |
|
120 |
raise
|
|
121 |
else: |
|
122 |
source.commit_write_group() |
|
123 |
to_repo.fetch(source, 'new') |
|
124 |
to_repo.lock_read() |
|
125 |
self.addCleanup(to_repo.unlock) |
|
126 |
self.assertEqual('contents', |
|
127 |
to_repo.texts.get_record_stream([('foo', revid)], |
|
128 |
'unordered', True).next().get_bytes_as('fulltext')) |
|
129 |
||
|
4476.3.15
by Andrew Bennetts
Partially working fallback for pre-1.17 servers. |
130 |
def test_fetch_parent_inventories_at_stacking_boundary_smart(self): |
131 |
self.setup_smart_server_with_call_log() |
|
132 |
self.test_fetch_parent_inventories_at_stacking_boundary() |
|
133 |
||
134 |
def test_fetch_parent_inventories_at_stacking_boundary_smart_old(self): |
|
135 |
self.setup_smart_server_with_call_log() |
|
|
4476.3.82
by Andrew Bennetts
Mention another bug fix in NEWS, and update verb name, comments, and NEWS additions for landing on 1.19 rather than 1.18. |
136 |
self.disable_verb('Repository.insert_stream_1.19') |
|
4476.3.15
by Andrew Bennetts
Partially working fallback for pre-1.17 servers. |
137 |
self.test_fetch_parent_inventories_at_stacking_boundary() |
138 |
||
|
4257.3.1
by Andrew Bennetts
Add failing test. |
139 |
def test_fetch_parent_inventories_at_stacking_boundary(self): |
|
4257.3.9
by Andrew Bennetts
Add fix to InterDifferingSerializer too, although it's pretty ugly. |
140 |
"""Fetch to a stacked branch copies inventories for parents of |
141 |
revisions at the stacking boundary.
|
|
142 |
||
143 |
This is necessary so that the server is able to determine the file-ids
|
|
144 |
altered by all revisions it contains, which means that it needs both
|
|
145 |
the inventory for any revision it has, and the inventories of all that
|
|
146 |
revision's parents.
|
|
|
4597.1.2
by John Arbash Meinel
Fix the second half of bug #402778 |
147 |
|
148 |
However, we should also skip any revisions which are ghosts in the
|
|
149 |
parents.
|
|
|
4257.3.9
by Andrew Bennetts
Add fix to InterDifferingSerializer too, although it's pretty ugly. |
150 |
"""
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
151 |
if not self.repository_format_to.supports_external_lookups: |
|
4257.3.1
by Andrew Bennetts
Add failing test. |
152 |
raise TestNotApplicable("Need stacking support in the target.") |
153 |
builder = self.make_branch_builder('branch') |
|
154 |
builder.start_series() |
|
155 |
builder.build_snapshot('base', None, [ |
|
|
4597.1.1
by John Arbash Meinel
fix a critical bug #402778 |
156 |
('add', ('', 'root-id', 'directory', '')), |
157 |
('add', ('file', 'file-id', 'file', 'content\n'))]) |
|
158 |
builder.build_snapshot('left', ['base'], [ |
|
159 |
('modify', ('file-id', 'left content\n'))]) |
|
160 |
builder.build_snapshot('right', ['base'], [ |
|
161 |
('modify', ('file-id', 'right content\n'))]) |
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
162 |
builder.build_snapshot('merge', ['left', 'right'], [ |
|
4597.1.1
by John Arbash Meinel
fix a critical bug #402778 |
163 |
('modify', ('file-id', 'left and right content\n'))]) |
|
4257.3.1
by Andrew Bennetts
Add failing test. |
164 |
builder.finish_series() |
165 |
branch = builder.get_branch() |
|
166 |
repo = self.make_to_repository('trunk') |
|
167 |
trunk = repo.bzrdir.create_branch() |
|
168 |
trunk.repository.fetch(branch.repository, 'left') |
|
169 |
trunk.repository.fetch(branch.repository, 'right') |
|
170 |
repo = self.make_to_repository('stacked') |
|
171 |
stacked_branch = repo.bzrdir.create_branch() |
|
172 |
stacked_branch.set_stacked_on_url(trunk.base) |
|
173 |
stacked_branch.repository.fetch(branch.repository, 'merge') |
|
174 |
unstacked_repo = stacked_branch.bzrdir.open_repository() |
|
175 |
unstacked_repo.lock_read() |
|
176 |
self.addCleanup(unstacked_repo.unlock) |
|
|
4476.3.73
by Andrew Bennetts
Remove smelly if guard from interrepo fetch stacking test, it's not necessary. |
177 |
self.assertFalse(unstacked_repo.has_revision('left')) |
178 |
self.assertFalse(unstacked_repo.has_revision('right')) |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
179 |
self.assertEqual( |
|
4257.3.2
by Andrew Bennetts
Check during fetch if we are going to be missing data necessary to calculate altered fileids for stacked revisions. |
180 |
set([('left',), ('right',), ('merge',)]), |
|
4257.3.1
by Andrew Bennetts
Add failing test. |
181 |
unstacked_repo.inventories.keys()) |
|
4597.1.1
by John Arbash Meinel
fix a critical bug #402778 |
182 |
# And the basis inventories have been copied correctly
|
183 |
trunk.lock_read() |
|
184 |
self.addCleanup(trunk.unlock) |
|
185 |
left_tree, right_tree = trunk.repository.revision_trees( |
|
186 |
['left', 'right']) |
|
187 |
stacked_branch.lock_read() |
|
188 |
self.addCleanup(stacked_branch.unlock) |
|
189 |
(stacked_left_tree, |
|
190 |
stacked_right_tree) = stacked_branch.repository.revision_trees( |
|
191 |
['left', 'right']) |
|
192 |
self.assertEqual(left_tree.inventory, stacked_left_tree.inventory) |
|
193 |
self.assertEqual(right_tree.inventory, stacked_right_tree.inventory) |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
194 |
|
|
4476.3.81
by Andrew Bennetts
Merge bzr.dev. Fix some minor fallout. per_interrepository/test_fetch.py has some duplicated assertions as a first pass at resolving conflicts. |
195 |
# Finally, it's not enough to see that the basis inventories are
|
196 |
# present. The texts introduced in merge (and only those) should be
|
|
197 |
# present, and also generating a stream should succeed without blowing
|
|
198 |
# up.
|
|
|
4476.3.11
by Andrew Bennetts
All fetch and interrepo tests passing. |
199 |
self.assertTrue(unstacked_repo.has_revision('merge')) |
|
4476.3.81
by Andrew Bennetts
Merge bzr.dev. Fix some minor fallout. per_interrepository/test_fetch.py has some duplicated assertions as a first pass at resolving conflicts. |
200 |
expected_texts = set([('file-id', 'merge')]) |
201 |
if stacked_branch.repository.texts.get_parent_map([('root-id', |
|
202 |
'merge')]): |
|
203 |
# If a (root-id,merge) text exists, it should be in the stacked
|
|
204 |
# repo.
|
|
205 |
expected_texts.add(('root-id', 'merge')) |
|
206 |
self.assertEqual(expected_texts, unstacked_repo.texts.keys()) |
|
|
4476.3.11
by Andrew Bennetts
All fetch and interrepo tests passing. |
207 |
self.assertCanStreamRevision(unstacked_repo, 'merge') |
208 |
||
209 |
def assertCanStreamRevision(self, repo, revision_id): |
|
210 |
exclude_keys = set(repo.all_revision_ids()) - set([revision_id]) |
|
211 |
search = SearchResult([revision_id], exclude_keys, 1, [revision_id]) |
|
212 |
source = repo._get_source(repo._format) |
|
213 |
for substream_kind, substream in source.get_stream(search): |
|
214 |
# Consume the substream
|
|
215 |
list(substream) |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
216 |
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
217 |
def test_fetch_across_stacking_boundary_ignores_ghost(self): |
218 |
if not self.repository_format_to.supports_external_lookups: |
|
219 |
raise TestNotApplicable("Need stacking support in the target.") |
|
220 |
to_repo = self.make_to_repository('to') |
|
221 |
builder = self.make_branch_builder('branch') |
|
222 |
builder.start_series() |
|
223 |
builder.build_snapshot('base', None, [ |
|
224 |
('add', ('', 'root-id', 'directory', '')), |
|
225 |
('add', ('file', 'file-id', 'file', 'content\n'))]) |
|
226 |
builder.build_snapshot('second', ['base'], [ |
|
227 |
('modify', ('file-id', 'second content\n'))]) |
|
228 |
builder.build_snapshot('third', ['second', 'ghost'], [ |
|
229 |
('modify', ('file-id', 'third content\n'))]) |
|
230 |
builder.finish_series() |
|
231 |
branch = builder.get_branch() |
|
232 |
repo = self.make_to_repository('trunk') |
|
233 |
trunk = repo.bzrdir.create_branch() |
|
234 |
trunk.repository.fetch(branch.repository, 'second') |
|
235 |
repo = self.make_to_repository('stacked') |
|
236 |
stacked_branch = repo.bzrdir.create_branch() |
|
237 |
stacked_branch.set_stacked_on_url(trunk.base) |
|
238 |
stacked_branch.repository.fetch(branch.repository, 'third') |
|
239 |
unstacked_repo = stacked_branch.bzrdir.open_repository() |
|
240 |
unstacked_repo.lock_read() |
|
241 |
self.addCleanup(unstacked_repo.unlock) |
|
242 |
self.assertFalse(unstacked_repo.has_revision('second')) |
|
243 |
self.assertFalse(unstacked_repo.has_revision('ghost')) |
|
244 |
self.assertEqual( |
|
245 |
set([('second',), ('third',)]), |
|
246 |
unstacked_repo.inventories.keys()) |
|
247 |
# And the basis inventories have been copied correctly
|
|
248 |
trunk.lock_read() |
|
249 |
self.addCleanup(trunk.unlock) |
|
250 |
second_tree = trunk.repository.revision_tree('second') |
|
251 |
stacked_branch.lock_read() |
|
252 |
self.addCleanup(stacked_branch.unlock) |
|
253 |
stacked_second_tree = stacked_branch.repository.revision_tree('second') |
|
254 |
self.assertEqual(second_tree.inventory, stacked_second_tree.inventory) |
|
|
4476.3.81
by Andrew Bennetts
Merge bzr.dev. Fix some minor fallout. per_interrepository/test_fetch.py has some duplicated assertions as a first pass at resolving conflicts. |
255 |
# Finally, it's not enough to see that the basis inventories are
|
256 |
# present. The texts introduced in merge (and only those) should be
|
|
257 |
# present, and also generating a stream should succeed without blowing
|
|
258 |
# up.
|
|
259 |
self.assertTrue(unstacked_repo.has_revision('third')) |
|
260 |
expected_texts = set([('file-id', 'third')]) |
|
261 |
if stacked_branch.repository.texts.get_parent_map([('root-id', |
|
262 |
'third')]): |
|
263 |
# If a (root-id,third) text exists, it should be in the stacked
|
|
264 |
# repo.
|
|
265 |
expected_texts.add(('root-id', 'third')) |
|
266 |
self.assertEqual(expected_texts, unstacked_repo.texts.keys()) |
|
267 |
self.assertCanStreamRevision(unstacked_repo, 'third') |
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
268 |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
269 |
def test_fetch_missing_basis_text(self): |
270 |
"""If fetching a delta, we should die if a basis is not present.""" |
|
271 |
tree = self.make_branch_and_tree('tree') |
|
272 |
self.build_tree(['tree/a']) |
|
273 |
tree.add(['a'], ['a-id']) |
|
274 |
tree.commit('one', rev_id='rev-one') |
|
275 |
self.build_tree_contents([('tree/a', 'new contents\n')]) |
|
276 |
tree.commit('two', rev_id='rev-two') |
|
277 |
||
278 |
to_repo = self.make_to_repository('to_repo') |
|
279 |
# We build a broken revision so that we can test the fetch code dies
|
|
280 |
# properly. So copy the inventory and revision, but not the text.
|
|
281 |
to_repo.lock_write() |
|
282 |
try: |
|
283 |
to_repo.start_write_group() |
|
284 |
inv = tree.branch.repository.get_inventory('rev-one') |
|
285 |
to_repo.add_inventory('rev-one', inv, []) |
|
286 |
rev = tree.branch.repository.get_revision('rev-one') |
|
287 |
to_repo.add_revision('rev-one', rev, inv=inv) |
|
288 |
to_repo.commit_write_group() |
|
289 |
finally: |
|
290 |
to_repo.unlock() |
|
291 |
||
|
3350.3.21
by Robert Collins
Merge bzr.dev. |
292 |
# Implementations can either ensure that the target of the delta is
|
293 |
# reconstructable, or raise an exception (which stream based copies
|
|
294 |
# generally do).
|
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
295 |
try: |
296 |
to_repo.fetch(tree.branch.repository, 'rev-two') |
|
|
3830.3.12
by Martin Pool
Review cleanups: unify has_key impls, add missing_keys(), clean up exception blocks |
297 |
except (errors.BzrCheckError, errors.RevisionNotPresent), e: |
298 |
# If an exception is raised, the revision should not be in the
|
|
299 |
# target.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
300 |
#
|
|
3830.3.9
by Martin Pool
Simplify kvf insert_record_stream; add has_key shorthand methods; update stacking effort tests |
301 |
# Can also just raise a generic check errors; stream insertion
|
302 |
# does this to include all the missing data
|
|
303 |
self.assertRaises((errors.NoSuchRevision, errors.RevisionNotPresent), |
|
304 |
to_repo.revision_tree, 'rev-two') |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
305 |
else: |
|
3350.3.21
by Robert Collins
Merge bzr.dev. |
306 |
# If not exception is raised, then the text should be
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
307 |
# available.
|
308 |
to_repo.lock_read() |
|
309 |
try: |
|
|
3350.3.21
by Robert Collins
Merge bzr.dev. |
310 |
rt = to_repo.revision_tree('rev-two') |
311 |
self.assertEqual('new contents\n', |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
312 |
rt.get_file_text('a-id')) |
313 |
finally: |
|
314 |
to_repo.unlock() |
|
315 |
||
316 |
def test_fetch_missing_revision_same_location_fails(self): |
|
317 |
repo_a = self.make_repository('.') |
|
318 |
repo_b = repository.Repository.open('.') |
|
319 |
try: |
|
|
3350.3.21
by Robert Collins
Merge bzr.dev. |
320 |
self.assertRaises(errors.NoSuchRevision, repo_b.fetch, repo_a, revision_id='XXX') |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
321 |
except errors.LockError, e: |
322 |
check_old_format_lock_error(self.repository_format) |
|
323 |
||
324 |
def test_fetch_same_location_trivial_works(self): |
|
325 |
repo_a = self.make_repository('.') |
|
326 |
repo_b = repository.Repository.open('.') |
|
327 |
try: |
|
328 |
repo_a.fetch(repo_b) |
|
329 |
except errors.LockError, e: |
|
330 |
check_old_format_lock_error(self.repository_format) |
|
331 |
||
332 |
def test_fetch_missing_text_other_location_fails(self): |
|
333 |
source_tree = self.make_branch_and_tree('source') |
|
334 |
source = source_tree.branch.repository |
|
335 |
target = self.make_to_repository('target') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
336 |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
337 |
# start by adding a file so the data knit for the file exists in
|
338 |
# repositories that have specific files for each fileid.
|
|
339 |
self.build_tree(['source/id']) |
|
340 |
source_tree.add(['id'], ['id']) |
|
341 |
source_tree.commit('a', rev_id='a') |
|
342 |
# now we manually insert a revision with an inventory referencing
|
|
343 |
# 'id' at revision 'b', but we do not insert revision b.
|
|
344 |
# this should ensure that the new versions of files are being checked
|
|
345 |
# for during pull operations
|
|
346 |
inv = source.get_inventory('a') |
|
347 |
source.lock_write() |
|
|
3380.1.5
by Aaron Bentley
Merge with make-it-work |
348 |
self.addCleanup(source.unlock) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
349 |
source.start_write_group() |
350 |
inv['id'].revision = 'b' |
|
351 |
inv.revision_id = 'b' |
|
352 |
sha1 = source.add_inventory('b', inv, ['a']) |
|
353 |
rev = Revision(timestamp=0, |
|
354 |
timezone=None, |
|
355 |
committer="Foo Bar <foo@example.com>", |
|
356 |
message="Message", |
|
357 |
inventory_sha1=sha1, |
|
358 |
revision_id='b') |
|
359 |
rev.parent_ids = ['a'] |
|
360 |
source.add_revision('b', rev) |
|
361 |
source.commit_write_group() |
|
362 |
self.assertRaises(errors.RevisionNotPresent, target.fetch, source) |
|
363 |
self.assertFalse(target.has_revision('b')) |
|
364 |
||
365 |
def test_fetch_funky_file_id(self): |
|
366 |
from_tree = self.make_branch_and_tree('tree') |
|
367 |
if sys.platform == 'win32': |
|
368 |
from_repo = from_tree.branch.repository |
|
369 |
check_repo_format_for_funky_id_on_win32(from_repo) |
|
370 |
self.build_tree(['tree/filename']) |
|
371 |
from_tree.add('filename', 'funky-chars<>%&;"\'') |
|
372 |
from_tree.commit('commit filename') |
|
373 |
to_repo = self.make_to_repository('to') |
|
|
3350.3.21
by Robert Collins
Merge bzr.dev. |
374 |
to_repo.fetch(from_tree.branch.repository, from_tree.get_parent_ids()[0]) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
375 |
|
|
3380.1.6
by Aaron Bentley
Ensure fetching munges sha1s |
376 |
def test_fetch_revision_hash(self): |
377 |
"""Ensure that inventory hashes are updated by fetch""" |
|
378 |
from_tree = self.make_branch_and_tree('tree') |
|
379 |
from_tree.commit('foo', rev_id='foo-id') |
|
380 |
to_repo = self.make_to_repository('to') |
|
381 |
to_repo.fetch(from_tree.branch.repository) |
|
382 |
recorded_inv_sha1 = to_repo.get_inventory_sha1('foo-id') |
|
|
4597.1.4
by John Arbash Meinel
Fix one test that assumed get_inventory_xml worked. |
383 |
to_repo.lock_read() |
384 |
self.addCleanup(to_repo.unlock) |
|
385 |
stream = to_repo.inventories.get_record_stream([('foo-id',)], |
|
386 |
'unordered', True) |
|
387 |
bytes = stream.next().get_bytes_as('fulltext') |
|
388 |
computed_inv_sha1 = osutils.sha_string(bytes) |
|
|
3380.1.6
by Aaron Bentley
Ensure fetching munges sha1s |
389 |
self.assertEqual(computed_inv_sha1, recorded_inv_sha1) |
390 |
||
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
391 |
|
392 |
class TestFetchDependentData(TestCaseWithInterRepository): |
|
393 |
||
394 |
def test_reference(self): |
|
395 |
from_tree = self.make_branch_and_tree('tree') |
|
396 |
to_repo = self.make_to_repository('to') |
|
397 |
if (not from_tree.supports_tree_reference() or |
|
398 |
not from_tree.branch.repository._format.supports_tree_reference or |
|
399 |
not to_repo._format.supports_tree_reference): |
|
400 |
raise TestNotApplicable("Need subtree support.") |
|
401 |
subtree = self.make_branch_and_tree('tree/subtree') |
|
402 |
subtree.commit('subrev 1') |
|
403 |
from_tree.add_reference(subtree) |
|
404 |
tree_rev = from_tree.commit('foo') |
|
405 |
# now from_tree has a last-modified of subtree of the rev id of the
|
|
406 |
# commit for foo, and a reference revision of the rev id of the commit
|
|
407 |
# for subrev 1
|
|
408 |
to_repo.fetch(from_tree.branch.repository, tree_rev) |
|
409 |
# to_repo should have a file_graph for from_tree.path2id('subtree') and
|
|
410 |
# revid tree_rev.
|
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
411 |
file_id = from_tree.path2id('subtree') |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
412 |
to_repo.lock_read() |
413 |
try: |
|
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
414 |
self.assertEqual({(file_id, tree_rev):()}, |
415 |
to_repo.texts.get_parent_map([(file_id, tree_rev)])) |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
416 |
finally: |
417 |
to_repo.unlock() |