bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
5273.1.7
by Vincent Ladeuil
No more use of the get_transport imported *symbol*, all uses are through |
1 |
# Copyright (C) 2007-2010 Canonical Ltd
|
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
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
|
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
16 |
|
17 |
"""Tests for fetch between repositories of the same type."""
|
|
18 |
||
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
19 |
from breezy import ( |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
20 |
controldir, |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
21 |
errors, |
|
2696.3.10
by Martin Pool
Add missing import |
22 |
gpg, |
|
6670.4.14
by Jelmer Vernooij
Move remote to breezy.bzr. |
23 |
repository, |
24 |
)
|
|
25 |
from breezy.bzr import ( |
|
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
26 |
remote, |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
27 |
)
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
28 |
from breezy.bzr.inventory import ROOT_ID |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
29 |
from breezy.tests import ( |
|
5751.2.3
by Jelmer Vernooij
More tests |
30 |
TestNotApplicable, |
31 |
TestSkipped, |
|
32 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
33 |
from breezy.tests.per_repository import TestCaseWithRepository |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
34 |
|
35 |
||
36 |
class TestFetchSameRepository(TestCaseWithRepository): |
|
37 |
||
38 |
def test_fetch(self): |
|
39 |
# smoke test fetch to ensure that the convenience function works.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
40 |
# it is defined as a convenience function with the underlying
|
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
41 |
# functionality provided by an InterRepository
|
42 |
tree_a = self.make_branch_and_tree('a') |
|
43 |
self.build_tree(['a/foo']) |
|
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
44 |
tree_a.add('foo') |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
45 |
rev1 = tree_a.commit('rev1') |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
46 |
# fetch with a default limit (grab everything)
|
|
2711.2.6
by Martin Pool
Fix up conversion of create_repository to make_repository in test_fetch |
47 |
repo = self.make_repository('b') |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
48 |
if (tree_a.branch.repository.supports_rich_root() and not |
49 |
repo.supports_rich_root()): |
|
50 |
raise TestSkipped('Cannot fetch from model2 to model1') |
|
51 |
repo.fetch(tree_a.branch.repository, |
|
52 |
revision_id=None) |
|
53 |
||
|
4145.1.1
by Robert Collins
Explicitly prevent fetching while the target repository is in a write group. |
54 |
def test_fetch_fails_in_write_group(self): |
55 |
# fetch() manages a write group itself, fetching within one isn't safe.
|
|
56 |
repo = self.make_repository('a') |
|
57 |
repo.lock_write() |
|
58 |
self.addCleanup(repo.unlock) |
|
59 |
repo.start_write_group() |
|
60 |
self.addCleanup(repo.abort_write_group) |
|
61 |
# Don't need a specific class - not expecting flow control based on
|
|
62 |
# this.
|
|
63 |
self.assertRaises(errors.BzrError, repo.fetch, repo) |
|
64 |
||
|
4060.1.4
by Robert Collins
Streaming fetch from remote servers. |
65 |
def test_fetch_to_knit3(self): |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
66 |
# create a repository of the sort we are testing.
|
|
3242.2.17
by Aaron Bentley
Fix broken tests |
67 |
tree_a = self.make_branch_and_tree('a') |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
68 |
self.build_tree(['a/foo']) |
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
69 |
tree_a.add('foo') |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
70 |
rev1 = tree_a.commit('rev1') |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
71 |
# create a knit-3 based format to fetch into
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
72 |
f = controldir.format_registry.make_controldir('development-subtree') |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
73 |
try: |
74 |
format = tree_a.branch.repository._format |
|
75 |
format.check_conversion_target(f.repository_format) |
|
76 |
# if we cannot convert data to knit3, skip the test.
|
|
|
6619.3.2
by Jelmer Vernooij
Apply 2to3 except fix. |
77 |
except errors.BadConversionTarget as e: |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
78 |
raise TestSkipped(str(e)) |
79 |
self.get_transport().mkdir('b') |
|
80 |
b_bzrdir = f.initialize(self.get_url('b')) |
|
81 |
knit3_repo = b_bzrdir.create_repository() |
|
82 |
# fetch with a default limit (grab everything)
|
|
83 |
knit3_repo.fetch(tree_a.branch.repository, revision_id=None) |
|
|
2592.3.96
by Robert Collins
Merge index improvements (includes bzr.dev). |
84 |
# Reopen to avoid any in-memory caching - ensure its reading from
|
85 |
# disk.
|
|
86 |
knit3_repo = b_bzrdir.open_repository() |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
87 |
rev1_tree = knit3_repo.revision_tree(rev1) |
|
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. |
88 |
rev1_tree.lock_read() |
89 |
try: |
|
90 |
lines = rev1_tree.get_file_lines(rev1_tree.get_root_id()) |
|
91 |
finally: |
|
92 |
rev1_tree.unlock() |
|
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
93 |
self.assertEqual([], lines) |
94 |
b_branch = b_bzrdir.create_branch() |
|
95 |
b_branch.pull(tree_a.branch) |
|
96 |
try: |
|
97 |
tree_b = b_bzrdir.create_workingtree() |
|
98 |
except errors.NotLocalUrl: |
|
|
4060.1.4
by Robert Collins
Streaming fetch from remote servers. |
99 |
try: |
100 |
tree_b = b_branch.create_checkout('b', lightweight=True) |
|
101 |
except errors.NotLocalUrl: |
|
102 |
raise TestSkipped("cannot make working tree with transport %r" |
|
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
103 |
% b_bzrdir.transport) |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
104 |
rev2 = tree_b.commit('no change') |
105 |
rev2_tree = knit3_repo.revision_tree(rev2) |
|
|
6405.2.7
by Jelmer Vernooij
Fix more tests. |
106 |
self.assertEqual( |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
107 |
rev1, |
|
6405.2.7
by Jelmer Vernooij
Fix more tests. |
108 |
rev2_tree.get_file_revision(rev2_tree.get_root_id())) |
|
2696.3.9
by Martin Pool
merge trunk |
109 |
|
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
110 |
def do_test_fetch_to_rich_root_sets_parents_correctly(self, result, |
111 |
snapshots, root_id=ROOT_ID, allow_lefthand_ghost=False): |
|
112 |
"""Assert that result is the parents of 'tip' after fetching snapshots. |
|
113 |
||
114 |
This helper constructs a 1.9 format source, and a test-format target
|
|
115 |
and fetches the result of building snapshots in the source, then
|
|
116 |
asserts that the parents of tip are result.
|
|
117 |
||
118 |
:param result: A parents list for the inventories.get_parent_map call.
|
|
119 |
:param snapshots: An iterable of snapshot parameters for
|
|
120 |
BranchBuilder.build_snapshot.
|
|
121 |
'"""
|
|
122 |
# This overlaps slightly with the tests for commit builder about graph
|
|
123 |
# consistency.
|
|
124 |
# Cases:
|
|
125 |
repo = self.make_repository('target') |
|
|
4324.3.3
by Robert Collins
Fix silly typo. |
126 |
remote_format = isinstance(repo, remote.RemoteRepository) |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
127 |
if not repo._format.rich_root_data and not remote_format: |
128 |
return # not relevant |
|
129 |
builder = self.make_branch_builder('source', format='1.9') |
|
130 |
builder.start_series() |
|
131 |
for revision_id, parent_ids, actions in snapshots: |
|
132 |
builder.build_snapshot(revision_id, parent_ids, actions, |
|
133 |
allow_leftmost_as_ghost=allow_lefthand_ghost) |
|
134 |
builder.finish_series() |
|
135 |
source = builder.get_branch() |
|
136 |
if remote_format and not repo._format.rich_root_data: |
|
137 |
# use a manual rich root format to ensure the code path is tested.
|
|
138 |
repo = self.make_repository('remote-target', |
|
139 |
format='1.9-rich-root') |
|
140 |
repo.lock_write() |
|
141 |
self.addCleanup(repo.unlock) |
|
142 |
repo.fetch(source.repository) |
|
|
5815.5.10
by Jelmer Vernooij
Fix two issues pointed out by John. |
143 |
graph = repo.get_file_graph() |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
144 |
self.assertEqual(result, |
|
5815.5.10
by Jelmer Vernooij
Fix two issues pointed out by John. |
145 |
graph.get_parent_map([(root_id, 'tip')])[(root_id, 'tip')]) |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
146 |
|
147 |
def test_fetch_to_rich_root_set_parent_no_parents(self): |
|
148 |
# No parents rev -> No parents
|
|
149 |
self.do_test_fetch_to_rich_root_sets_parents_correctly((), |
|
150 |
[('tip', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
|
151 |
])
|
|
152 |
||
153 |
def test_fetch_to_rich_root_set_parent_1_parent(self): |
|
|
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
154 |
# 1 parent rev -> 1 parent
|
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
155 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
156 |
((ROOT_ID, 'base'),), |
|
157 |
[('base', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
|
158 |
('tip', None, []), |
|
159 |
])
|
|
160 |
||
161 |
def test_fetch_to_rich_root_set_parent_1_ghost_parent(self): |
|
162 |
# 1 ghost parent -> No parents
|
|
|
6162.2.1
by Jelmer Vernooij
Skip tests that require ghosts on repositories that don't support ghosts. |
163 |
if not self.repository_format.supports_ghosts: |
164 |
raise TestNotApplicable("repository format does not support " |
|
165 |
"ghosts") |
|
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
166 |
self.do_test_fetch_to_rich_root_sets_parents_correctly((), |
167 |
[('tip', ['ghost'], [('add', ('', ROOT_ID, 'directory', ''))]), |
|
168 |
], allow_lefthand_ghost=True) |
|
169 |
||
170 |
def test_fetch_to_rich_root_set_parent_2_head_parents(self): |
|
171 |
# 2 parents both heads -> 2 parents
|
|
172 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
173 |
((ROOT_ID, 'left'), (ROOT_ID, 'right')), |
|
174 |
[('base', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
|
175 |
('left', None, []), |
|
176 |
('right', ['base'], []), |
|
177 |
('tip', ['left', 'right'], []), |
|
178 |
])
|
|
179 |
||
180 |
def test_fetch_to_rich_root_set_parent_2_parents_1_head(self): |
|
181 |
# 2 parents one head -> 1 parent
|
|
182 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
183 |
((ROOT_ID, 'right'),), |
|
184 |
[('left', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
|
185 |
('right', None, []), |
|
186 |
('tip', ['left', 'right'], []), |
|
187 |
])
|
|
188 |
||
189 |
def test_fetch_to_rich_root_set_parent_1_parent_different_id_gone(self): |
|
190 |
# 1 parent different fileid, ours missing -> no parents
|
|
191 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
192 |
(),
|
|
193 |
[('base', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
|
194 |
('tip', None, [('unversion', ROOT_ID), |
|
195 |
('add', ('', 'my-root', 'directory', '')), |
|
196 |
]),
|
|
197 |
], root_id='my-root') |
|
198 |
||
199 |
def test_fetch_to_rich_root_set_parent_1_parent_different_id_moved(self): |
|
200 |
# 1 parent different fileid, ours moved -> 1 parent
|
|
201 |
# (and that parent honours the changing revid of the other location)
|
|
202 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
203 |
(('my-root', 'origin'),), |
|
204 |
[('origin', None, [('add', ('', ROOT_ID, 'directory', '')), |
|
205 |
('add', ('child', 'my-root', 'directory', ''))]), |
|
206 |
('base', None, []), |
|
207 |
('tip', None, [('unversion', 'my-root'), |
|
208 |
('unversion', ROOT_ID), |
|
|
6008.2.5
by Andrew Bennetts
Rename 'checkpoint' to 'flush', add some unit tests and more comments. |
209 |
('flush', None), |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
210 |
('add', ('', 'my-root', 'directory', '')), |
211 |
]),
|
|
212 |
], root_id='my-root') |
|
213 |
||
214 |
def test_fetch_to_rich_root_set_parent_2_parent_1_different_id_gone(self): |
|
215 |
# 2 parents, 1 different fileid, our second missing -> 1 parent
|
|
216 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
217 |
(('my-root', 'right'),), |
|
218 |
[('base', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
|
219 |
('right', None, [('unversion', ROOT_ID), |
|
220 |
('add', ('', 'my-root', 'directory', ''))]), |
|
221 |
('tip', ['base', 'right'], [('unversion', ROOT_ID), |
|
222 |
('add', ('', 'my-root', 'directory', '')), |
|
223 |
]),
|
|
224 |
], root_id='my-root') |
|
225 |
||
226 |
def test_fetch_to_rich_root_set_parent_2_parent_2_different_id_moved(self): |
|
227 |
# 2 parents, 1 different fileid, our second moved -> 2 parent
|
|
228 |
# (and that parent honours the changing revid of the other location)
|
|
229 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
230 |
(('my-root', 'right'),), |
|
231 |
# 'my-root' at 'child'.
|
|
232 |
[('origin', None, [('add', ('', ROOT_ID, 'directory', '')), |
|
233 |
('add', ('child', 'my-root', 'directory', ''))]), |
|
234 |
('base', None, []), |
|
235 |
# 'my-root' at root
|
|
236 |
('right', None, [('unversion', 'my-root'), |
|
237 |
('unversion', ROOT_ID), |
|
|
6008.2.5
by Andrew Bennetts
Rename 'checkpoint' to 'flush', add some unit tests and more comments. |
238 |
('flush', None), |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
239 |
('add', ('', 'my-root', 'directory', ''))]), |
240 |
('tip', ['base', 'right'], [('unversion', 'my-root'), |
|
241 |
('unversion', ROOT_ID), |
|
|
6008.2.5
by Andrew Bennetts
Rename 'checkpoint' to 'flush', add some unit tests and more comments. |
242 |
('flush', None), |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
243 |
('add', ('', 'my-root', 'directory', '')), |
244 |
]),
|
|
245 |
], root_id='my-root') |
|
246 |
||
|
2948.3.1
by John Arbash Meinel
Fix bug #158333, make sure that Repository.fetch(self) is properly a no-op for all Repository implementations. |
247 |
def test_fetch_all_from_self(self): |
248 |
tree = self.make_branch_and_tree('.') |
|
249 |
rev_id = tree.commit('one') |
|
250 |
# This needs to be a new copy of the repository, if this changes, the
|
|
251 |
# test needs to be rewritten
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
252 |
repo = tree.branch.repository.controldir.open_repository() |
|
2948.3.1
by John Arbash Meinel
Fix bug #158333, make sure that Repository.fetch(self) is properly a no-op for all Repository implementations. |
253 |
# This fetch should be a no-op see bug #158333
|
254 |
tree.branch.repository.fetch(repo, None) |
|
255 |
||
256 |
def test_fetch_from_self(self): |
|
257 |
tree = self.make_branch_and_tree('.') |
|
258 |
rev_id = tree.commit('one') |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
259 |
repo = tree.branch.repository.controldir.open_repository() |
|
2948.3.1
by John Arbash Meinel
Fix bug #158333, make sure that Repository.fetch(self) is properly a no-op for all Repository implementations. |
260 |
# This fetch should be a no-op see bug #158333
|
261 |
tree.branch.repository.fetch(repo, rev_id) |
|
262 |
||
263 |
def test_fetch_missing_from_self(self): |
|
264 |
tree = self.make_branch_and_tree('.') |
|
265 |
rev_id = tree.commit('one') |
|
266 |
# Even though the fetch() is a NO-OP it should assert the revision id
|
|
267 |
# is present
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
268 |
repo = tree.branch.repository.controldir.open_repository() |
|
2948.3.1
by John Arbash Meinel
Fix bug #158333, make sure that Repository.fetch(self) is properly a no-op for all Repository implementations. |
269 |
self.assertRaises(errors.NoSuchRevision, tree.branch.repository.fetch, |
270 |
repo, 'no-such-revision') |
|
271 |
||
|
2696.3.9
by Martin Pool
merge trunk |
272 |
def makeARepoWithSignatures(self): |
273 |
wt = self.make_branch_and_tree('a-repo-with-sigs') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
274 |
rev1 = wt.commit('rev1', allow_pointless=True) |
|
2696.3.9
by Martin Pool
merge trunk |
275 |
repo = wt.branch.repository |
|
2592.3.96
by Robert Collins
Merge index improvements (includes bzr.dev). |
276 |
repo.lock_write() |
277 |
repo.start_write_group() |
|
|
5751.2.3
by Jelmer Vernooij
More tests |
278 |
try: |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
279 |
repo.sign_revision(rev1, gpg.LoopbackGPGStrategy(None)) |
|
5751.2.3
by Jelmer Vernooij
More tests |
280 |
except errors.UnsupportedOperation: |
281 |
self.assertFalse(repo._format.supports_revision_signatures) |
|
282 |
raise TestNotApplicable("repository format does not support signatures") |
|
|
2592.3.96
by Robert Collins
Merge index improvements (includes bzr.dev). |
283 |
repo.commit_write_group() |
284 |
repo.unlock() |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
285 |
return repo, rev1 |
|
2696.3.9
by Martin Pool
merge trunk |
286 |
|
287 |
def test_fetch_copies_signatures(self): |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
288 |
source_repo, rev1 = self.makeARepoWithSignatures() |
|
2696.3.9
by Martin Pool
merge trunk |
289 |
target_repo = self.make_repository('target') |
290 |
target_repo.fetch(source_repo, revision_id=None) |
|
291 |
self.assertEqual( |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
292 |
source_repo.get_signature_text(rev1), |
293 |
target_repo.get_signature_text(rev1)) |
|
|
2535.3.48
by Andrew Bennetts
Merge from bzr.dev. |
294 |
|
295 |
def make_repository_with_one_revision(self): |
|
|
3242.2.17
by Aaron Bentley
Fix broken tests |
296 |
wt = self.make_branch_and_tree('source') |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
297 |
rev1 = wt.commit('rev1', allow_pointless=True) |
298 |
return wt.branch.repository, rev1 |
|
|
2535.3.48
by Andrew Bennetts
Merge from bzr.dev. |
299 |
|
300 |
def test_fetch_revision_already_exists(self): |
|
301 |
# Make a repository with one revision.
|
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
302 |
source_repo, rev1 = self.make_repository_with_one_revision() |
|
2535.3.48
by Andrew Bennetts
Merge from bzr.dev. |
303 |
# Fetch that revision into a second repository.
|
304 |
target_repo = self.make_repository('target') |
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
305 |
target_repo.fetch(source_repo, revision_id=rev1) |
|
2535.3.48
by Andrew Bennetts
Merge from bzr.dev. |
306 |
# Now fetch again; there will be nothing to do. This should work
|
307 |
# without causing any errors.
|
|
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
308 |
target_repo.fetch(source_repo, revision_id=rev1) |
|
2535.3.48
by Andrew Bennetts
Merge from bzr.dev. |
309 |
|
|
1551.19.36
by Aaron Bentley
Prevent fetch all from causing pack collisions |
310 |
def test_fetch_all_same_revisions_twice(self): |
311 |
# Blind-fetching all the same revisions twice should succeed and be a
|
|
312 |
# no-op the second time.
|
|
313 |
repo = self.make_repository('repo') |
|
314 |
tree = self.make_branch_and_tree('tree') |
|
315 |
revision_id = tree.commit('test') |
|
316 |
repo.fetch(tree.branch.repository) |
|
317 |
repo.fetch(tree.branch.repository) |
|
|
4360.2.1
by Robert Collins
Don't return ghosts in the keyset for PendingAncestryResult. |
318 |
|
|
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
319 |
def make_simple_branch_with_ghost(self): |
|
4476.3.59
by Andrew Bennetts
Undo changes that aren't needed anymore. |
320 |
builder = self.make_branch_builder('source') |
|
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
321 |
builder.start_series() |
322 |
builder.build_snapshot('A-id', None, [ |
|
|
4476.3.59
by Andrew Bennetts
Undo changes that aren't needed anymore. |
323 |
('add', ('', 'root-id', 'directory', None)), |
|
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
324 |
('add', ('file', 'file-id', 'file', 'content\n'))]) |
325 |
builder.build_snapshot('B-id', ['A-id', 'ghost-id'], []) |
|
326 |
builder.finish_series() |
|
327 |
source_b = builder.get_branch() |
|
328 |
source_b.lock_read() |
|
329 |
self.addCleanup(source_b.unlock) |
|
330 |
return source_b |
|
331 |
||
332 |
def test_fetch_with_ghost(self): |
|
333 |
source_b = self.make_simple_branch_with_ghost() |
|
334 |
target = self.make_repository('target') |
|
335 |
target.lock_write() |
|
336 |
self.addCleanup(target.unlock) |
|
337 |
target.fetch(source_b.repository, revision_id='B-id') |
|
338 |
||
339 |
def test_fetch_into_smart_with_ghost(self): |
|
340 |
trans = self.make_smart_server('target') |
|
341 |
source_b = self.make_simple_branch_with_ghost() |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
342 |
if not source_b.controldir._format.supports_transport(trans): |
|
6205.3.1
by Jelmer Vernooij
Add ControlDirFormat.supports_transport. |
343 |
raise TestNotApplicable("format does not support transport") |
|
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
344 |
target = self.make_repository('target') |
345 |
# Re-open the repository over the smart protocol
|
|
346 |
target = repository.Repository.open(trans.base) |
|
347 |
target.lock_write() |
|
348 |
self.addCleanup(target.unlock) |
|
349 |
try: |
|
350 |
target.fetch(source_b.repository, revision_id='B-id') |
|
351 |
except errors.TokenLockingNotSupported: |
|
352 |
# The code inside fetch() that tries to lock and then fails, also
|
|
353 |
# causes weird problems with 'lock_not_held' later on...
|
|
354 |
target.lock_read() |
|
|
6050.1.2
by Martin
Make tests raising KnownFailure use the knownFailure method instead |
355 |
self.knownFailure('some repositories fail to fetch' |
|
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
356 |
' via the smart server because of locking issues.') |
357 |
||
358 |
def test_fetch_from_smart_with_ghost(self): |
|
359 |
trans = self.make_smart_server('source') |
|
360 |
source_b = self.make_simple_branch_with_ghost() |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
361 |
if not source_b.controldir._format.supports_transport(trans): |
|
6205.3.1
by Jelmer Vernooij
Add ControlDirFormat.supports_transport. |
362 |
raise TestNotApplicable("format does not support transport") |
|
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
363 |
target = self.make_repository('target') |
364 |
target.lock_write() |
|
365 |
self.addCleanup(target.unlock) |
|
366 |
# Re-open the repository over the smart protocol
|
|
367 |
source = repository.Repository.open(trans.base) |
|
368 |
source.lock_read() |
|
369 |
self.addCleanup(source.unlock) |
|
370 |
target.fetch(source, revision_id='B-id') |
|
371 |