bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
4988.10.3
by John Arbash Meinel
Merge bzr.dev 5007, resolve conflict, update NEWS |
1 |
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
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 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
20 |
from breezy import ( |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
21 |
errors, |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
22 |
osutils, |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
23 |
repository, |
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
24 |
)
|
25 |
from breezy.bzr import ( |
|
26 |
inventory, |
|
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
27 |
versionedfile, |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
28 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
29 |
from breezy.errors import ( |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
30 |
NoSuchRevision, |
31 |
)
|
|
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
32 |
from breezy.bzr.vf_search import ( |
|
4476.3.11
by Andrew Bennetts
All fetch and interrepo tests passing. |
33 |
SearchResult, |
34 |
)
|
|
|
7143.21.1
by Jelmer Vernooij
Add WriteGroup contextmanager. |
35 |
from breezy.repository import WriteGroup |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
36 |
from breezy.revision import ( |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
37 |
NULL_REVISION, |
38 |
Revision, |
|
39 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
40 |
from breezy.tests import ( |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
41 |
TestNotApplicable, |
42 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
43 |
from breezy.tests.per_interrepository import ( |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
44 |
TestCaseWithInterRepository, |
45 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
46 |
from breezy.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 |
47 |
check_repo_format_for_funky_id_on_win32
|
48 |
)
|
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
49 |
|
50 |
||
51 |
class TestInterRepository(TestCaseWithInterRepository): |
|
52 |
||
|
4634.35.22
by Andrew Bennetts
Use monkey patching to avoid skipping (mostly) tests that try to create damaged repos on 2a. |
53 |
def disable_commit_write_group_paranoia(self, repo): |
54 |
pack_coll = getattr(repo, '_pack_collection', None) |
|
55 |
if pack_coll is not None: |
|
56 |
# Monkey-patch the pack collection instance to allow storing
|
|
57 |
# incomplete revisions.
|
|
58 |
pack_coll._check_new_inventories = lambda: [] |
|
59 |
||
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
60 |
def test_fetch(self): |
61 |
tree_a = self.make_branch_and_tree('a') |
|
62 |
self.build_tree(['a/foo']) |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
63 |
tree_a.add('foo') |
64 |
rev1 = tree_a.commit('rev1') |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
65 |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
66 |
def check_push_rev1(repo): |
67 |
# ensure the revision is missing.
|
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
68 |
self.assertRaises(NoSuchRevision, repo.get_revision, rev1) |
|
4110.2.5
by Martin Pool
Deprecate passing pbs in to fetch() |
69 |
# fetch with a limit of NULL_REVISION
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
70 |
repo.fetch(tree_a.branch.repository, |
|
4110.2.5
by Martin Pool
Deprecate passing pbs in to fetch() |
71 |
revision_id=NULL_REVISION) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
72 |
# nothing should have been pushed
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
73 |
self.assertFalse(repo.has_revision(rev1)) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
74 |
# fetch with a default limit (grab everything)
|
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
75 |
try: |
76 |
repo.fetch(tree_a.branch.repository) |
|
77 |
except errors.NoRoundtrippingSupport: |
|
78 |
raise TestNotApplicable('roundtripping not supported') |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
79 |
# check that b now has all the data from a's first commit.
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
80 |
rev = repo.get_revision(rev1) |
81 |
tree = repo.revision_tree(rev1) |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
82 |
tree.lock_read() |
83 |
self.addCleanup(tree.unlock) |
|
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
84 |
tree.get_file_text('foo') |
|
6825.5.1
by Jelmer Vernooij
Implement Tree.all_versioned_paths. |
85 |
for path in tree.all_versioned_paths(): |
86 |
if tree.kind(path) == "file": |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
87 |
with tree.get_file(path) as f: |
88 |
f.read() |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
89 |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
90 |
# makes a target version repo
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
91 |
repo_b = self.make_to_repository('b') |
92 |
check_push_rev1(repo_b) |
|
93 |
||
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
94 |
def test_fetch_inconsistent_last_changed_entries(self): |
95 |
"""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. |
96 |
|
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
97 |
This test tests that we do fetch a file text created in a revision not
|
98 |
being fetched, but referenced from the revision we are fetching when the
|
|
99 |
adjacent revisions to the one being fetched do not reference that text.
|
|
100 |
"""
|
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
101 |
if not self.repository_format.supports_full_versioned_files: |
102 |
raise TestNotApplicable('Need full versioned files') |
|
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
103 |
tree = self.make_branch_and_tree('source') |
104 |
revid = tree.commit('old') |
|
105 |
to_repo = self.make_to_repository('to_repo') |
|
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
106 |
try: |
107 |
to_repo.fetch(tree.branch.repository, revid) |
|
108 |
except errors.NoRoundtrippingSupport: |
|
109 |
raise TestNotApplicable('roundtripping not supported') |
|
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
110 |
# Make a broken revision and fetch it.
|
111 |
source = tree.branch.repository |
|
112 |
source.lock_write() |
|
113 |
self.addCleanup(source.unlock) |
|
|
7143.21.1
by Jelmer Vernooij
Add WriteGroup contextmanager. |
114 |
with WriteGroup(source): |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
115 |
# We need two revisions: OLD and NEW. NEW will claim to need a file
|
116 |
# 'FOO' changed in 'OLD'. OLD will not have that file at all.
|
|
117 |
source.texts.insert_record_stream([ |
|
|
6973.12.1
by Jelmer Vernooij
Fix more tests. |
118 |
versionedfile.FulltextContentFactory((b'foo', revid), (), None, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
119 |
b'contents')]) |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
120 |
basis = source.revision_tree(revid) |
121 |
parent_id = basis.path2id('') |
|
|
6973.12.1
by Jelmer Vernooij
Fix more tests. |
122 |
entry = inventory.make_entry('file', 'foo-path', parent_id, b'foo') |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
123 |
entry.revision = revid |
124 |
entry.text_size = len('contents') |
|
|
7045.1.1
by Jelmer Vernooij
Fix another 300 tests. |
125 |
entry.text_sha1 = osutils.sha_string(b'contents') |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
126 |
inv_sha1, _ = source.add_inventory_by_delta(revid, [ |
|
6973.12.1
by Jelmer Vernooij
Fix more tests. |
127 |
(None, 'foo-path', b'foo', entry)], b'new', [revid]) |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
128 |
rev = Revision(timestamp=0, |
129 |
timezone=None, |
|
130 |
committer="Foo Bar <foo@example.com>", |
|
131 |
message="Message", |
|
132 |
inventory_sha1=inv_sha1, |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
133 |
revision_id=b'new', |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
134 |
parent_ids=[revid]) |
135 |
source.add_revision(rev.revision_id, rev) |
|
|
6973.12.1
by Jelmer Vernooij
Fix more tests. |
136 |
to_repo.fetch(source, b'new') |
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
137 |
to_repo.lock_read() |
138 |
self.addCleanup(to_repo.unlock) |
|
|
6973.12.1
by Jelmer Vernooij
Fix more tests. |
139 |
self.assertEqual(b'contents', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
140 |
next(to_repo.texts.get_record_stream([(b'foo', revid)], |
141 |
'unordered', True)).get_bytes_as('fulltext')) |
|
|
3735.2.135
by Robert Collins
Permit fetching bzr.dev [deal with inconsistent inventories.] |
142 |
|
|
4634.61.1
by Andrew Bennetts
Fix cross-format pulls from stacked branches via smart server, add tests for same. |
143 |
def test_fetch_from_stacked_smart(self): |
144 |
self.setup_smart_server_with_call_log() |
|
145 |
self.test_fetch_from_stacked() |
|
146 |
||
147 |
def test_fetch_from_stacked_smart_old(self): |
|
148 |
self.setup_smart_server_with_call_log() |
|
|
6963.1.2
by Jelmer Vernooij
Fix some more tests. |
149 |
self.disable_verb(b'Repository.get_stream_1.19') |
|
4634.61.1
by Andrew Bennetts
Fix cross-format pulls from stacked branches via smart server, add tests for same. |
150 |
self.test_fetch_from_stacked() |
151 |
||
152 |
def test_fetch_from_stacked(self): |
|
153 |
"""Fetch from a stacked branch succeeds.""" |
|
154 |
if not self.repository_format.supports_external_lookups: |
|
155 |
raise TestNotApplicable("Need stacking support in the source.") |
|
156 |
builder = self.make_branch_builder('full-branch') |
|
157 |
builder.start_series() |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
158 |
builder.build_snapshot(None, [ |
|
6973.6.2
by Jelmer Vernooij
Fix more tests. |
159 |
('add', ('', b'root-id', 'directory', '')), |
160 |
('add', ('file', b'file-id', 'file', b'content\n'))], |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
161 |
revision_id=b'first') |
|
6973.6.2
by Jelmer Vernooij
Fix more tests. |
162 |
builder.build_snapshot([b'first'], [ |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
163 |
('modify', ('file', b'second content\n'))], |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
164 |
revision_id=b'second') |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
165 |
builder.build_snapshot([b'second'], [ |
166 |
('modify', ('file', b'third content\n'))], |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
167 |
revision_id=b'third') |
|
4634.61.1
by Andrew Bennetts
Fix cross-format pulls from stacked branches via smart server, add tests for same. |
168 |
builder.finish_series() |
169 |
branch = builder.get_branch() |
|
170 |
repo = self.make_repository('stacking-base') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
171 |
trunk = repo.controldir.create_branch() |
|
6973.6.2
by Jelmer Vernooij
Fix more tests. |
172 |
trunk.repository.fetch(branch.repository, b'second') |
|
4634.61.1
by Andrew Bennetts
Fix cross-format pulls from stacked branches via smart server, add tests for same. |
173 |
repo = self.make_repository('stacked') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
174 |
stacked_branch = repo.controldir.create_branch() |
|
4634.61.1
by Andrew Bennetts
Fix cross-format pulls from stacked branches via smart server, add tests for same. |
175 |
stacked_branch.set_stacked_on_url(trunk.base) |
|
6973.6.2
by Jelmer Vernooij
Fix more tests. |
176 |
stacked_branch.repository.fetch(branch.repository, b'third') |
|
4634.61.1
by Andrew Bennetts
Fix cross-format pulls from stacked branches via smart server, add tests for same. |
177 |
target = self.make_to_repository('target') |
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
178 |
try: |
|
6996
by Jelmer Vernooij
Merge lp:~jelmer/brz/python3-e |
179 |
target.fetch(stacked_branch.repository, b'third') |
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
180 |
except errors.NoRoundtrippingSupport: |
181 |
raise TestNotApplicable('roundtripping not supported') |
|
|
4634.61.1
by Andrew Bennetts
Fix cross-format pulls from stacked branches via smart server, add tests for same. |
182 |
target.lock_read() |
183 |
self.addCleanup(target.unlock) |
|
|
6973.6.2
by Jelmer Vernooij
Fix more tests. |
184 |
all_revs = {b'first', b'second', b'third'} |
|
4634.61.1
by Andrew Bennetts
Fix cross-format pulls from stacked branches via smart server, add tests for same. |
185 |
self.assertEqual(all_revs, set(target.get_parent_map(all_revs))) |
186 |
||
|
4476.3.15
by Andrew Bennetts
Partially working fallback for pre-1.17 servers. |
187 |
def test_fetch_parent_inventories_at_stacking_boundary_smart(self): |
188 |
self.setup_smart_server_with_call_log() |
|
189 |
self.test_fetch_parent_inventories_at_stacking_boundary() |
|
190 |
||
191 |
def test_fetch_parent_inventories_at_stacking_boundary_smart_old(self): |
|
192 |
self.setup_smart_server_with_call_log() |
|
|
6963.1.2
by Jelmer Vernooij
Fix some more tests. |
193 |
self.disable_verb(b'Repository.insert_stream_1.19') |
|
6437.59.1
by Martin Packman
Mark randomly failing test in per_interrepository using knownFailure when ConnectionReset is raised |
194 |
try: |
195 |
self.test_fetch_parent_inventories_at_stacking_boundary() |
|
196 |
except errors.ConnectionReset: |
|
197 |
self.knownFailure("Random spurious failure, see bug 874153") |
|
|
4476.3.15
by Andrew Bennetts
Partially working fallback for pre-1.17 servers. |
198 |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
199 |
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. |
200 |
"""Fetch to a stacked branch copies inventories for parents of |
201 |
revisions at the stacking boundary.
|
|
202 |
||
203 |
This is necessary so that the server is able to determine the file-ids
|
|
204 |
altered by all revisions it contains, which means that it needs both
|
|
205 |
the inventory for any revision it has, and the inventories of all that
|
|
206 |
revision's parents.
|
|
|
4597.1.2
by John Arbash Meinel
Fix the second half of bug #402778 |
207 |
|
208 |
However, we should also skip any revisions which are ghosts in the
|
|
209 |
parents.
|
|
|
4257.3.9
by Andrew Bennetts
Add fix to InterDifferingSerializer too, although it's pretty ugly. |
210 |
"""
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
211 |
if not self.repository_format_to.supports_external_lookups: |
|
4257.3.1
by Andrew Bennetts
Add failing test. |
212 |
raise TestNotApplicable("Need stacking support in the target.") |
213 |
builder = self.make_branch_builder('branch') |
|
214 |
builder.start_series() |
|
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
215 |
base = builder.build_snapshot(None, [ |
216 |
('add', ('', None, 'directory', '')), |
|
|
6992
by Jelmer Vernooij
Merge lp:~jelmer/brz/python3-c |
217 |
('add', ('file', None, 'file', b'content\n'))]) |
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
218 |
left = builder.build_snapshot([base], [ |
219 |
('modify', ('file', b'left content\n'))]) |
|
220 |
right = builder.build_snapshot([base], [ |
|
221 |
('modify', ('file', b'right content\n'))]) |
|
222 |
merge = builder.build_snapshot([left, right], [ |
|
223 |
('modify', ('file', b'left and right content\n'))]) |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
224 |
builder.finish_series() |
225 |
branch = builder.get_branch() |
|
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
226 |
revtree = branch.repository.revision_tree(merge) |
227 |
root_id = revtree.path2id('') |
|
228 |
file_id = revtree.path2id('file') |
|
229 |
||
|
4257.3.1
by Andrew Bennetts
Add failing test. |
230 |
repo = self.make_to_repository('trunk') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
231 |
trunk = repo.controldir.create_branch() |
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
232 |
trunk.repository.fetch(branch.repository, left) |
233 |
trunk.repository.fetch(branch.repository, right) |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
234 |
repo = self.make_to_repository('stacked') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
235 |
stacked_branch = repo.controldir.create_branch() |
|
4257.3.1
by Andrew Bennetts
Add failing test. |
236 |
stacked_branch.set_stacked_on_url(trunk.base) |
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
237 |
stacked_branch.repository.fetch(branch.repository, merge) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
238 |
unstacked_repo = stacked_branch.controldir.open_repository() |
|
4257.3.1
by Andrew Bennetts
Add failing test. |
239 |
unstacked_repo.lock_read() |
240 |
self.addCleanup(unstacked_repo.unlock) |
|
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
241 |
self.assertFalse(unstacked_repo.has_revision(left)) |
242 |
self.assertFalse(unstacked_repo.has_revision(right)) |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
243 |
self.assertEqual( |
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
244 |
{(left,), (right,), (merge,)}, |
|
4257.3.1
by Andrew Bennetts
Add failing test. |
245 |
unstacked_repo.inventories.keys()) |
|
4597.1.1
by John Arbash Meinel
fix a critical bug #402778 |
246 |
# And the basis inventories have been copied correctly
|
247 |
trunk.lock_read() |
|
248 |
self.addCleanup(trunk.unlock) |
|
249 |
left_tree, right_tree = trunk.repository.revision_trees( |
|
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
250 |
[left, right]) |
|
4597.1.1
by John Arbash Meinel
fix a critical bug #402778 |
251 |
stacked_branch.lock_read() |
252 |
self.addCleanup(stacked_branch.unlock) |
|
253 |
(stacked_left_tree, |
|
254 |
stacked_right_tree) = stacked_branch.repository.revision_trees( |
|
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
255 |
[left, right]) |
|
6405.2.7
by Jelmer Vernooij
Fix more tests. |
256 |
self.assertEqual( |
257 |
left_tree.root_inventory, stacked_left_tree.root_inventory) |
|
258 |
self.assertEqual( |
|
259 |
right_tree.root_inventory, stacked_right_tree.root_inventory) |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
260 |
|
|
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. |
261 |
# Finally, it's not enough to see that the basis inventories are
|
262 |
# present. The texts introduced in merge (and only those) should be
|
|
263 |
# present, and also generating a stream should succeed without blowing
|
|
264 |
# up.
|
|
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
265 |
self.assertTrue(unstacked_repo.has_revision(merge)) |
266 |
expected_texts = {(file_id, merge)} |
|
267 |
if stacked_branch.repository.texts.get_parent_map([(root_id, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
268 |
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. |
269 |
# If a (root-id,merge) text exists, it should be in the stacked
|
270 |
# repo.
|
|
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
271 |
expected_texts.add((root_id, 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. |
272 |
self.assertEqual(expected_texts, unstacked_repo.texts.keys()) |
|
6989.2.1
by Jelmer Vernooij
Avoid using custom file ids/revids. |
273 |
self.assertCanStreamRevision(unstacked_repo, merge) |
|
4476.3.11
by Andrew Bennetts
All fetch and interrepo tests passing. |
274 |
|
275 |
def assertCanStreamRevision(self, repo, revision_id): |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
276 |
exclude_keys = set(repo.all_revision_ids()) - {revision_id} |
|
4476.3.11
by Andrew Bennetts
All fetch and interrepo tests passing. |
277 |
search = SearchResult([revision_id], exclude_keys, 1, [revision_id]) |
278 |
source = repo._get_source(repo._format) |
|
279 |
for substream_kind, substream in source.get_stream(search): |
|
280 |
# Consume the substream
|
|
281 |
list(substream) |
|
|
4257.3.1
by Andrew Bennetts
Add failing test. |
282 |
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
283 |
def test_fetch_across_stacking_boundary_ignores_ghost(self): |
284 |
if not self.repository_format_to.supports_external_lookups: |
|
285 |
raise TestNotApplicable("Need stacking support in the target.") |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
286 |
if not self.repository_format.supports_ghosts: |
287 |
raise TestNotApplicable("Need ghost support in the source.") |
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
288 |
to_repo = self.make_to_repository('to') |
289 |
builder = self.make_branch_builder('branch') |
|
290 |
builder.start_series() |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
291 |
base = builder.build_snapshot(None, [ |
292 |
('add', ('', None, 'directory', '')), |
|
293 |
('add', ('file', None, 'file', b'content\n'))]) |
|
294 |
second = builder.build_snapshot([base], [ |
|
295 |
('modify', ('file', b'second content\n'))]) |
|
296 |
third = builder.build_snapshot([second, b'ghost'], [ |
|
297 |
('modify', ('file', b'third content\n'))]) |
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
298 |
builder.finish_series() |
299 |
branch = builder.get_branch() |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
300 |
revtree = branch.repository.revision_tree(base) |
301 |
root_id = revtree.path2id('') |
|
302 |
file_id = revtree.path2id('file') |
|
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
303 |
repo = self.make_to_repository('trunk') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
304 |
trunk = repo.controldir.create_branch() |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
305 |
trunk.repository.fetch(branch.repository, second) |
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
306 |
repo = self.make_to_repository('stacked') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
307 |
stacked_branch = repo.controldir.create_branch() |
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
308 |
stacked_branch.set_stacked_on_url(trunk.base) |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
309 |
stacked_branch.repository.fetch(branch.repository, third) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
310 |
unstacked_repo = stacked_branch.controldir.open_repository() |
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
311 |
unstacked_repo.lock_read() |
312 |
self.addCleanup(unstacked_repo.unlock) |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
313 |
self.assertFalse(unstacked_repo.has_revision(second)) |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
314 |
self.assertFalse(unstacked_repo.has_revision(b'ghost')) |
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
315 |
self.assertEqual( |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
316 |
{(second,), (third,)}, |
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
317 |
unstacked_repo.inventories.keys()) |
318 |
# And the basis inventories have been copied correctly
|
|
319 |
trunk.lock_read() |
|
320 |
self.addCleanup(trunk.unlock) |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
321 |
second_tree = trunk.repository.revision_tree(second) |
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
322 |
stacked_branch.lock_read() |
323 |
self.addCleanup(stacked_branch.unlock) |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
324 |
stacked_second_tree = stacked_branch.repository.revision_tree(second) |
|
6471.1.5
by Jelmer Vernooij
Compare trees rather than inventories. |
325 |
self.assertEqual(second_tree, stacked_second_tree) |
|
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. |
326 |
# Finally, it's not enough to see that the basis inventories are
|
327 |
# present. The texts introduced in merge (and only those) should be
|
|
328 |
# present, and also generating a stream should succeed without blowing
|
|
329 |
# up.
|
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
330 |
self.assertTrue(unstacked_repo.has_revision(third)) |
331 |
expected_texts = {(file_id, third)} |
|
332 |
if stacked_branch.repository.texts.get_parent_map([(root_id, |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
333 |
third)]): |
|
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. |
334 |
# If a (root-id,third) text exists, it should be in the stacked
|
335 |
# repo.
|
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
336 |
expected_texts.add((root_id, third)) |
|
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. |
337 |
self.assertEqual(expected_texts, unstacked_repo.texts.keys()) |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
338 |
self.assertCanStreamRevision(unstacked_repo, third) |
|
4597.1.5
by John Arbash Meinel
Split the 'ghost' test into a second test. |
339 |
|
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
340 |
def test_fetch_from_stacked_to_stacked_copies_parent_inventories(self): |
341 |
"""Fetch from a stacked branch copies inventories for parents of |
|
342 |
revisions at the stacking boundary.
|
|
343 |
||
344 |
Specifically, fetch will copy the parent inventories from the
|
|
345 |
source for which the corresponding revisions are not present. This
|
|
346 |
will happen even when the source repository has no fallbacks configured
|
|
347 |
(as is the case during upgrade).
|
|
348 |
"""
|
|
349 |
if not self.repository_format.supports_external_lookups: |
|
350 |
raise TestNotApplicable("Need stacking support in the source.") |
|
351 |
if not self.repository_format_to.supports_external_lookups: |
|
352 |
raise TestNotApplicable("Need stacking support in the target.") |
|
353 |
builder = self.make_branch_builder('branch') |
|
354 |
builder.start_series() |
|
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
355 |
builder.build_snapshot(None, [ |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
356 |
('add', ('', b'root-id', 'directory', '')), |
357 |
('add', ('file', b'file-id', 'file', b'content\n'))], |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
358 |
revision_id=b'base') |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
359 |
builder.build_snapshot([b'base'], [ |
360 |
('modify', ('file', b'left content\n'))], |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
361 |
revision_id=b'left') |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
362 |
builder.build_snapshot([b'base'], [ |
363 |
('modify', ('file', b'right content\n'))], |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
364 |
revision_id=b'right') |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
365 |
builder.build_snapshot([b'left', b'right'], [ |
366 |
('modify', ('file', b'left and right content\n'))], |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
367 |
revision_id=b'merge') |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
368 |
builder.finish_series() |
369 |
branch = builder.get_branch() |
|
370 |
repo = self.make_repository('old-trunk') |
|
371 |
# Make a pair of equivalent trunk repos in the from and to formats.
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
372 |
old_trunk = repo.controldir.create_branch() |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
373 |
old_trunk.repository.fetch(branch.repository, b'left') |
374 |
old_trunk.repository.fetch(branch.repository, b'right') |
|
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
375 |
repo = self.make_to_repository('new-trunk') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
376 |
new_trunk = repo.controldir.create_branch() |
|
6973.5.10
by Jelmer Vernooij
Random bunch of python3 bee-improvements. |
377 |
new_trunk.repository.fetch(branch.repository, b'left') |
378 |
new_trunk.repository.fetch(branch.repository, b'right') |
|
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
379 |
# Make the source; a repo stacked on old_trunk contained just the data
|
380 |
# for 'merge'.
|
|
381 |
repo = self.make_repository('old-stacked') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
382 |
old_stacked_branch = repo.controldir.create_branch() |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
383 |
old_stacked_branch.set_stacked_on_url(old_trunk.base) |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
384 |
old_stacked_branch.repository.fetch(branch.repository, b'merge') |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
385 |
# Make the target, a repo stacked on new_trunk.
|
386 |
repo = self.make_to_repository('new-stacked') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
387 |
new_stacked_branch = repo.controldir.create_branch() |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
388 |
new_stacked_branch.set_stacked_on_url(new_trunk.base) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
389 |
old_unstacked_repo = old_stacked_branch.controldir.open_repository() |
390 |
new_unstacked_repo = new_stacked_branch.controldir.open_repository() |
|
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
391 |
# Reopen the source and target repos without any fallbacks, and fetch
|
392 |
# 'merge'.
|
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
393 |
new_unstacked_repo.fetch(old_unstacked_repo, b'merge') |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
394 |
# Now check the results. new_unstacked_repo should contain all the
|
395 |
# data necessary to stream 'merge' (i.e. the parent inventories).
|
|
396 |
new_unstacked_repo.lock_read() |
|
397 |
self.addCleanup(new_unstacked_repo.unlock) |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
398 |
self.assertFalse(new_unstacked_repo.has_revision(b'left')) |
399 |
self.assertFalse(new_unstacked_repo.has_revision(b'right')) |
|
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
400 |
self.assertEqual( |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
401 |
{(b'left',), (b'right',), (b'merge',)}, |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
402 |
new_unstacked_repo.inventories.keys()) |
403 |
# And the basis inventories have been copied correctly
|
|
404 |
new_trunk.lock_read() |
|
405 |
self.addCleanup(new_trunk.unlock) |
|
406 |
left_tree, right_tree = new_trunk.repository.revision_trees( |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
407 |
[b'left', b'right']) |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
408 |
new_stacked_branch.lock_read() |
409 |
self.addCleanup(new_stacked_branch.unlock) |
|
410 |
(stacked_left_tree, |
|
411 |
stacked_right_tree) = new_stacked_branch.repository.revision_trees( |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
412 |
[b'left', b'right']) |
|
6470.1.1
by Jelmer Vernooij
Use inventories directly in fewer places. |
413 |
self.assertEqual(left_tree, stacked_left_tree) |
414 |
self.assertEqual(right_tree, stacked_right_tree) |
|
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
415 |
# Finally, it's not enough to see that the basis inventories are
|
416 |
# present. The texts introduced in merge (and only those) should be
|
|
417 |
# present, and also generating a stream should succeed without blowing
|
|
418 |
# up.
|
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
419 |
self.assertTrue(new_unstacked_repo.has_revision(b'merge')) |
420 |
expected_texts = {(b'file-id', b'merge')} |
|
421 |
if new_stacked_branch.repository.texts.get_parent_map([(b'root-id', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
422 |
b'merge')]): |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
423 |
# If a (root-id,merge) text exists, it should be in the stacked
|
424 |
# repo.
|
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
425 |
expected_texts.add((b'root-id', b'merge')) |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
426 |
self.assertEqual(expected_texts, new_unstacked_repo.texts.keys()) |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
427 |
self.assertCanStreamRevision(new_unstacked_repo, b'merge') |
|
4627.3.4
by Andrew Bennetts
Add a (long) test that fails without the fix. |
428 |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
429 |
def test_fetch_missing_basis_text(self): |
430 |
"""If fetching a delta, we should die if a basis is not present.""" |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
431 |
if not self.repository_format.supports_full_versioned_files: |
432 |
raise TestNotApplicable('Need full versioned files support') |
|
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
433 |
if not self.repository_format_to.supports_full_versioned_files: |
434 |
raise TestNotApplicable('Need full versioned files support') |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
435 |
tree = self.make_branch_and_tree('tree') |
436 |
self.build_tree(['tree/a']) |
|
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
437 |
tree.add(['a']) |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
438 |
rev1 = tree.commit('one') |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
439 |
self.build_tree_contents([('tree/a', b'new contents\n')]) |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
440 |
rev2 = tree.commit('two') |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
441 |
|
442 |
to_repo = self.make_to_repository('to_repo') |
|
443 |
# We build a broken revision so that we can test the fetch code dies
|
|
444 |
# properly. So copy the inventory and revision, but not the text.
|
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
445 |
with to_repo.lock_write(): |
|
7143.21.1
by Jelmer Vernooij
Add WriteGroup contextmanager. |
446 |
with WriteGroup(to_repo, suppress_errors=True): |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
447 |
inv = tree.branch.repository.get_inventory(rev1) |
448 |
to_repo.add_inventory(rev1, inv, []) |
|
449 |
rev = tree.branch.repository.get_revision(rev1) |
|
450 |
to_repo.add_revision(rev1, rev, inv=inv) |
|
|
4634.35.22
by Andrew Bennetts
Use monkey patching to avoid skipping (mostly) tests that try to create damaged repos on 2a. |
451 |
self.disable_commit_write_group_paranoia(to_repo) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
452 |
|
|
3350.3.21
by Robert Collins
Merge bzr.dev. |
453 |
# Implementations can either ensure that the target of the delta is
|
454 |
# reconstructable, or raise an exception (which stream based copies
|
|
455 |
# generally do).
|
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
456 |
try: |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
457 |
to_repo.fetch(tree.branch.repository, rev2) |
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
458 |
except (errors.BzrCheckError, errors.RevisionNotPresent) as e: |
|
3830.3.12
by Martin Pool
Review cleanups: unify has_key impls, add missing_keys(), clean up exception blocks |
459 |
# If an exception is raised, the revision should not be in the
|
460 |
# target.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
461 |
#
|
|
3830.3.9
by Martin Pool
Simplify kvf insert_record_stream; add has_key shorthand methods; update stacking effort tests |
462 |
# Can also just raise a generic check errors; stream insertion
|
463 |
# does this to include all the missing data
|
|
464 |
self.assertRaises((errors.NoSuchRevision, errors.RevisionNotPresent), |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
465 |
to_repo.revision_tree, rev2) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
466 |
else: |
|
3350.3.21
by Robert Collins
Merge bzr.dev. |
467 |
# If not exception is raised, then the text should be
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
468 |
# available.
|
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
469 |
with to_repo.lock_read(): |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
470 |
rt = to_repo.revision_tree(rev2) |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
471 |
self.assertEqual(b'new contents\n', |
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
472 |
rt.get_file_text('a')) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
473 |
|
474 |
def test_fetch_missing_revision_same_location_fails(self): |
|
475 |
repo_a = self.make_repository('.') |
|
476 |
repo_b = repository.Repository.open('.') |
|
|
5728.3.1
by Martin Pool
Remove apparently no-longer-called check_old_format_lock_error |
477 |
self.assertRaises(errors.NoSuchRevision, |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
478 |
repo_b.fetch, repo_a, revision_id=b'XXX') |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
479 |
|
480 |
def test_fetch_same_location_trivial_works(self): |
|
481 |
repo_a = self.make_repository('.') |
|
482 |
repo_b = repository.Repository.open('.') |
|
|
5728.3.1
by Martin Pool
Remove apparently no-longer-called check_old_format_lock_error |
483 |
repo_a.fetch(repo_b) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
484 |
|
485 |
def test_fetch_missing_text_other_location_fails(self): |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
486 |
if not self.repository_format.supports_full_versioned_files: |
487 |
raise TestNotApplicable('Need full versioned files') |
|
488 |
||
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
489 |
source_tree = self.make_branch_and_tree('source') |
490 |
source = source_tree.branch.repository |
|
491 |
target = self.make_to_repository('target') |
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
492 |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
493 |
# start by adding a file so the data knit for the file exists in
|
494 |
# repositories that have specific files for each fileid.
|
|
495 |
self.build_tree(['source/id']) |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
496 |
source_tree.add(['id'], [b'id']) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
497 |
source_tree.commit('a', rev_id=b'a') |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
498 |
# now we manually insert a revision with an inventory referencing
|
|
4634.35.14
by Andrew Bennetts
Fix more tests to cope with new commit_write_group strictness. |
499 |
# file 'id' at revision 'b', but we do not insert revision b.
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
500 |
# this should ensure that the new versions of files are being checked
|
501 |
# for during pull operations
|
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
502 |
inv = source.get_inventory(b'a') |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
503 |
source.lock_write() |
|
3380.1.5
by Aaron Bentley
Merge with make-it-work |
504 |
self.addCleanup(source.unlock) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
505 |
source.start_write_group() |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
506 |
inv.get_entry(b'id').revision = b'b' |
507 |
inv.revision_id = b'b' |
|
508 |
sha1 = source.add_inventory(b'b', inv, [b'a']) |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
509 |
rev = Revision(timestamp=0, |
510 |
timezone=None, |
|
511 |
committer="Foo Bar <foo@example.com>", |
|
512 |
message="Message", |
|
513 |
inventory_sha1=sha1, |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
514 |
revision_id=b'b') |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
515 |
rev.parent_ids = [b'a'] |
516 |
source.add_revision(b'b', rev) |
|
|
4634.35.22
by Andrew Bennetts
Use monkey patching to avoid skipping (mostly) tests that try to create damaged repos on 2a. |
517 |
self.disable_commit_write_group_paranoia(source) |
518 |
source.commit_write_group() |
|
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
519 |
try: |
520 |
self.assertRaises(errors.RevisionNotPresent, target.fetch, source) |
|
521 |
except errors.NoRoundtrippingSupport: |
|
522 |
raise TestNotApplicable('roundtripping not supported') |
|
|
7490.48.3
by Jelmer Vernooij
Fix tests. |
523 |
self.assertFalse(target.has_revision(b'b')) |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
524 |
|
525 |
def test_fetch_funky_file_id(self): |
|
526 |
from_tree = self.make_branch_and_tree('tree') |
|
527 |
if sys.platform == 'win32': |
|
528 |
from_repo = from_tree.branch.repository |
|
529 |
check_repo_format_for_funky_id_on_win32(from_repo) |
|
530 |
self.build_tree(['tree/filename']) |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
531 |
if not from_tree.supports_setting_file_ids(): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
532 |
raise TestNotApplicable( |
533 |
'from tree format can not create custom file ids') |
|
|
7045.2.15
by Jelmer Vernooij
Fix some per_pack_repository tests. |
534 |
from_tree.add('filename', b'funky-chars<>%&;"\'') |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
535 |
from_tree.commit('commit filename') |
536 |
to_repo = self.make_to_repository('to') |
|
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
537 |
try: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
538 |
to_repo.fetch(from_tree.branch.repository, |
539 |
from_tree.get_parent_ids()[0]) |
|
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
540 |
except errors.NoRoundtrippingSupport: |
541 |
raise TestNotApplicable('roundtripping not supported') |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
542 |
|
|
3380.1.6
by Aaron Bentley
Ensure fetching munges sha1s |
543 |
def test_fetch_revision_hash(self): |
544 |
"""Ensure that inventory hashes are updated by fetch""" |
|
|
6989.2.6
by Jelmer Vernooij
Run tests against brz-git interrepositories. |
545 |
if not self.repository_format_to.supports_full_versioned_files: |
546 |
raise TestNotApplicable('Need full versioned files') |
|
|
3380.1.6
by Aaron Bentley
Ensure fetching munges sha1s |
547 |
from_tree = self.make_branch_and_tree('tree') |
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
548 |
revid = from_tree.commit('foo') |
|
3380.1.6
by Aaron Bentley
Ensure fetching munges sha1s |
549 |
to_repo = self.make_to_repository('to') |
|
6989.2.3
by Jelmer Vernooij
Allow testing interrepo formats that don't support roundtripping. |
550 |
try: |
551 |
to_repo.fetch(from_tree.branch.repository) |
|
552 |
except errors.NoRoundtrippingSupport: |
|
553 |
raise TestNotApplicable('roundtripping not supported') |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
554 |
recorded_inv_sha1 = to_repo.get_revision(revid).inventory_sha1 |
|
4597.1.4
by John Arbash Meinel
Fix one test that assumed get_inventory_xml worked. |
555 |
to_repo.lock_read() |
556 |
self.addCleanup(to_repo.unlock) |
|
|
6989.2.2
by Jelmer Vernooij
Fix a few tests against git repositories. |
557 |
stream = to_repo.inventories.get_record_stream([(revid,)], |
|
4597.1.4
by John Arbash Meinel
Fix one test that assumed get_inventory_xml worked. |
558 |
'unordered', True) |
|
7018.3.10
by Jelmer Vernooij
Consistent return values in PreviewTree.list_files. |
559 |
bytes = next(stream).get_bytes_as('fulltext') |
|
4597.1.4
by John Arbash Meinel
Fix one test that assumed get_inventory_xml worked. |
560 |
computed_inv_sha1 = osutils.sha_string(bytes) |
|
3380.1.6
by Aaron Bentley
Ensure fetching munges sha1s |
561 |
self.assertEqual(computed_inv_sha1, recorded_inv_sha1) |
562 |
||
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
563 |
|
564 |
class TestFetchDependentData(TestCaseWithInterRepository): |
|
565 |
||
566 |
def test_reference(self): |
|
567 |
from_tree = self.make_branch_and_tree('tree') |
|
568 |
to_repo = self.make_to_repository('to') |
|
569 |
if (not from_tree.supports_tree_reference() or |
|
570 |
not from_tree.branch.repository._format.supports_tree_reference or |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
571 |
not to_repo._format.supports_tree_reference): |
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
572 |
raise TestNotApplicable("Need subtree support.") |
|
6989.2.6
by Jelmer Vernooij
Run tests against brz-git interrepositories. |
573 |
if not to_repo._format.supports_full_versioned_files: |
574 |
raise TestNotApplicable('Need full versioned files support.') |
|
|
3380.1.4
by Aaron Bentley
Split interrepository fetch tests into their own file |
575 |
subtree = self.make_branch_and_tree('tree/subtree') |
576 |
subtree.commit('subrev 1') |
|
577 |
from_tree.add_reference(subtree) |
|
578 |
tree_rev = from_tree.commit('foo') |
|
579 |
# now from_tree has a last-modified of subtree of the rev id of the
|
|
580 |
# commit for foo, and a reference revision of the rev id of the commit
|
|
581 |
# for subrev 1
|
|
582 |
to_repo.fetch(from_tree.branch.repository, tree_rev) |
|
583 |
# to_repo should have a file_graph for from_tree.path2id('subtree') and
|
|
584 |
# 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. |
585 |
file_id = from_tree.path2id('subtree') |
|
6989.2.6
by Jelmer Vernooij
Run tests against brz-git interrepositories. |
586 |
with to_repo.lock_read(): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
587 |
self.assertEqual({(file_id, tree_rev): ()}, |
588 |
to_repo.texts.get_parent_map([(file_id, tree_rev)])) |