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 |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
49 |
repo.supports_rich_root()): |
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
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) |
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
88 |
with rev1_tree.lock_read(): |
89 |
lines = rev1_tree.get_file_lines(u'') |
|
2696.3.2
by Martin Pool
Move some per-repository tests from big test_repository to test_fetch |
90 |
self.assertEqual([], lines) |
91 |
b_branch = b_bzrdir.create_branch() |
|
92 |
b_branch.pull(tree_a.branch) |
|
93 |
try: |
|
94 |
tree_b = b_bzrdir.create_workingtree() |
|
95 |
except errors.NotLocalUrl: |
|
4060.1.4
by Robert Collins
Streaming fetch from remote servers. |
96 |
try: |
97 |
tree_b = b_branch.create_checkout('b', lightweight=True) |
|
98 |
except errors.NotLocalUrl: |
|
99 |
raise TestSkipped("cannot make working tree with transport %r" |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
100 |
% b_bzrdir.transport) |
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
101 |
rev2 = tree_b.commit('no change') |
102 |
rev2_tree = knit3_repo.revision_tree(rev2) |
|
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
103 |
self.assertEqual(rev1, rev2_tree.get_file_revision(u'')) |
2696.3.9
by Martin Pool
merge trunk |
104 |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
105 |
def do_test_fetch_to_rich_root_sets_parents_correctly(self, result, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
106 |
snapshots, root_id=ROOT_ID, allow_lefthand_ghost=False): |
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
107 |
"""Assert that result is the parents of b'tip' after fetching snapshots. |
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
108 |
|
109 |
This helper constructs a 1.9 format source, and a test-format target
|
|
110 |
and fetches the result of building snapshots in the source, then
|
|
111 |
asserts that the parents of tip are result.
|
|
112 |
||
113 |
:param result: A parents list for the inventories.get_parent_map call.
|
|
114 |
:param snapshots: An iterable of snapshot parameters for
|
|
115 |
BranchBuilder.build_snapshot.
|
|
116 |
'"""
|
|
117 |
# This overlaps slightly with the tests for commit builder about graph
|
|
118 |
# consistency.
|
|
119 |
# Cases:
|
|
120 |
repo = self.make_repository('target') |
|
4324.3.3
by Robert Collins
Fix silly typo. |
121 |
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'. |
122 |
if not repo._format.rich_root_data and not remote_format: |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
123 |
return # not relevant |
6883.14.1
by Jelmer Vernooij
Don't run rich root test against non-versioned-file repositories. |
124 |
if not repo._format.supports_full_versioned_files: |
125 |
raise TestNotApplicable( |
|
126 |
'format does not support full versioned files') |
|
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 |
builder = self.make_branch_builder('source', format='1.9') |
128 |
builder.start_series() |
|
129 |
for revision_id, parent_ids, actions in snapshots: |
|
6816.2.1
by Jelmer Vernooij
Migrate some build_snapshot code over to having revision_id as keyword argument. |
130 |
builder.build_snapshot(parent_ids, actions, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
131 |
allow_leftmost_as_ghost=allow_lefthand_ghost, |
132 |
revision_id=revision_id) |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
133 |
builder.finish_series() |
134 |
source = builder.get_branch() |
|
135 |
if remote_format and not repo._format.rich_root_data: |
|
136 |
# use a manual rich root format to ensure the code path is tested.
|
|
137 |
repo = self.make_repository('remote-target', |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
138 |
format='1.9-rich-root') |
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
139 |
repo.lock_write() |
140 |
self.addCleanup(repo.unlock) |
|
141 |
repo.fetch(source.repository) |
|
5815.5.10
by Jelmer Vernooij
Fix two issues pointed out by John. |
142 |
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'. |
143 |
self.assertEqual(result, |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
144 |
graph.get_parent_map([(root_id, b'tip')])[(root_id, b'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'. |
145 |
|
146 |
def test_fetch_to_rich_root_set_parent_no_parents(self): |
|
147 |
# No parents rev -> No parents
|
|
148 |
self.do_test_fetch_to_rich_root_sets_parents_correctly((), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
149 |
[(b'tip', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
150 |
])
|
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
151 |
|
152 |
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. |
153 |
# 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'. |
154 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
6973.14.14
by Jelmer Vernooij
Fix determinism in MemoryTree.unversion. |
155 |
((ROOT_ID, b'base'),), |
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
156 |
[(b'base', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
157 |
(b'tip', None, []), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
158 |
])
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
159 |
|
160 |
def test_fetch_to_rich_root_set_parent_1_ghost_parent(self): |
|
161 |
# 1 ghost parent -> No parents
|
|
6162.2.1
by Jelmer Vernooij
Skip tests that require ghosts on repositories that don't support ghosts. |
162 |
if not self.repository_format.supports_ghosts: |
163 |
raise TestNotApplicable("repository format does not support " |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
164 |
"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'. |
165 |
self.do_test_fetch_to_rich_root_sets_parents_correctly((), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
166 |
[(b'tip', [b'ghost'], [('add', ('', ROOT_ID, 'directory', ''))]), |
167 |
], allow_lefthand_ghost=True) |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
168 |
|
169 |
def test_fetch_to_rich_root_set_parent_2_head_parents(self): |
|
170 |
# 2 parents both heads -> 2 parents
|
|
171 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
172 |
((ROOT_ID, b'left'), (ROOT_ID, b'right')), |
173 |
[(b'base', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
174 |
(b'left', None, []), |
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
175 |
(b'right', [b'base'], []), |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
176 |
(b'tip', [b'left', b'right'], []), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
177 |
])
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
178 |
|
179 |
def test_fetch_to_rich_root_set_parent_2_parents_1_head(self): |
|
180 |
# 2 parents one head -> 1 parent
|
|
181 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
182 |
((ROOT_ID, b'right'),), |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
183 |
[(b'left', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
184 |
(b'right', None, []), |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
185 |
(b'tip', [b'left', b'right'], []), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
186 |
])
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
187 |
|
188 |
def test_fetch_to_rich_root_set_parent_1_parent_different_id_gone(self): |
|
189 |
# 1 parent different fileid, ours missing -> no parents
|
|
190 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
191 |
(),
|
|
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
192 |
[(b'base', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
193 |
(b'tip', None, [('unversion', ''), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
194 |
('add', ('', b'my-root', 'directory', '')), |
195 |
]),
|
|
196 |
], root_id=b'my-root') |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
197 |
|
198 |
def test_fetch_to_rich_root_set_parent_1_parent_different_id_moved(self): |
|
199 |
# 1 parent different fileid, ours moved -> 1 parent
|
|
200 |
# (and that parent honours the changing revid of the other location)
|
|
201 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
202 |
((b'my-root', b'origin'),), |
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
203 |
[(b'origin', None, [('add', ('', ROOT_ID, 'directory', '')), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
204 |
('add', ('child', b'my-root', 'directory', ''))]), |
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
205 |
(b'base', None, []), |
206 |
(b'tip', None, [('unversion', 'child'), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
207 |
('unversion', ''), |
208 |
('flush', None), |
|
209 |
('add', ('', b'my-root', 'directory', '')), |
|
210 |
]),
|
|
211 |
], root_id=b'my-root') |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
212 |
|
213 |
def test_fetch_to_rich_root_set_parent_2_parent_1_different_id_gone(self): |
|
214 |
# 2 parents, 1 different fileid, our second missing -> 1 parent
|
|
215 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
216 |
((b'my-root', b'right'),), |
217 |
[(b'base', None, [('add', ('', ROOT_ID, 'directory', ''))]), |
|
218 |
(b'right', None, [('unversion', ''), |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
219 |
('add', ('', b'my-root', 'directory', ''))]), |
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
220 |
(b'tip', [b'base', b'right'], [('unversion', ''), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
221 |
('add', ('', b'my-root', 'directory', '')), |
222 |
]),
|
|
223 |
], root_id=b'my-root') |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
224 |
|
225 |
def test_fetch_to_rich_root_set_parent_2_parent_2_different_id_moved(self): |
|
226 |
# 2 parents, 1 different fileid, our second moved -> 2 parent
|
|
227 |
# (and that parent honours the changing revid of the other location)
|
|
228 |
self.do_test_fetch_to_rich_root_sets_parents_correctly( |
|
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
229 |
((b'my-root', b'right'),), |
230 |
# b'my-root' at 'child'.
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
231 |
[(b'origin', None, [('add', ('', ROOT_ID, 'directory', '')), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
232 |
('add', ('child', b'my-root', 'directory', ''))]), |
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
233 |
(b'base', None, []), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
234 |
# b'my-root' at root
|
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
235 |
(b'right', None, [('unversion', 'child'), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
236 |
('unversion', ''), |
237 |
('flush', None), |
|
238 |
('add', ('', b'my-root', 'directory', ''))]), |
|
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
239 |
(b'tip', [b'base', b'right'], [('unversion', ''), |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
240 |
('unversion', 'child'), |
241 |
('flush', None), |
|
242 |
('add', ('', b'my-root', 'directory', '')), |
|
243 |
]),
|
|
244 |
], root_id=b'my-root') |
|
4324.3.1
by Robert Collins
When adding rich root data follow the standard revision graph rules, so it does not create 'inconstent parents'. |
245 |
|
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. |
246 |
def test_fetch_all_from_self(self): |
247 |
tree = self.make_branch_and_tree('.') |
|
248 |
rev_id = tree.commit('one') |
|
249 |
# This needs to be a new copy of the repository, if this changes, the
|
|
250 |
# test needs to be rewritten
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
251 |
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. |
252 |
# This fetch should be a no-op see bug #158333
|
253 |
tree.branch.repository.fetch(repo, None) |
|
254 |
||
255 |
def test_fetch_from_self(self): |
|
256 |
tree = self.make_branch_and_tree('.') |
|
257 |
rev_id = tree.commit('one') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
258 |
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. |
259 |
# This fetch should be a no-op see bug #158333
|
260 |
tree.branch.repository.fetch(repo, rev_id) |
|
261 |
||
262 |
def test_fetch_missing_from_self(self): |
|
263 |
tree = self.make_branch_and_tree('.') |
|
264 |
rev_id = tree.commit('one') |
|
265 |
# Even though the fetch() is a NO-OP it should assert the revision id
|
|
266 |
# is present
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
267 |
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. |
268 |
self.assertRaises(errors.NoSuchRevision, tree.branch.repository.fetch, |
6973.12.10
by Jelmer Vernooij
Fix remaining tests. |
269 |
repo, b'no-such-revision') |
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. |
270 |
|
2696.3.9
by Martin Pool
merge trunk |
271 |
def makeARepoWithSignatures(self): |
272 |
wt = self.make_branch_and_tree('a-repo-with-sigs') |
|
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
273 |
rev1 = wt.commit('rev1', allow_pointless=True) |
2696.3.9
by Martin Pool
merge trunk |
274 |
repo = wt.branch.repository |
2592.3.96
by Robert Collins
Merge index improvements (includes bzr.dev). |
275 |
repo.lock_write() |
276 |
repo.start_write_group() |
|
5751.2.3
by Jelmer Vernooij
More tests |
277 |
try: |
6747.3.1
by Jelmer Vernooij
Avoid more uses of revision_id. |
278 |
repo.sign_revision(rev1, gpg.LoopbackGPGStrategy(None)) |
5751.2.3
by Jelmer Vernooij
More tests |
279 |
except errors.UnsupportedOperation: |
280 |
self.assertFalse(repo._format.supports_revision_signatures) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
281 |
raise TestNotApplicable( |
282 |
"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): |
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
320 |
if not self.repository_format.supports_ghosts: |
321 |
raise TestNotApplicable("repository format does not support " |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
322 |
"ghosts") |
4476.3.59
by Andrew Bennetts
Undo changes that aren't needed anymore. |
323 |
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. |
324 |
builder.start_series() |
6825.2.1
by Jelmer Vernooij
Fix some tests for foreign branches. |
325 |
a_revid = builder.build_snapshot(None, [ |
6963.2.15
by Jelmer Vernooij
Accept unicode - for now. |
326 |
('add', ('', b'root-id', 'directory', None)), |
327 |
('add', ('file', b'file-id', 'file', b'content\n'))]) |
|
328 |
b_revid = builder.build_snapshot([a_revid, b'ghost-id'], []) |
|
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
329 |
builder.finish_series() |
330 |
source_b = builder.get_branch() |
|
331 |
source_b.lock_read() |
|
332 |
self.addCleanup(source_b.unlock) |
|
6825.2.1
by Jelmer Vernooij
Fix some tests for foreign branches. |
333 |
return source_b, b_revid |
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
334 |
|
335 |
def test_fetch_with_ghost(self): |
|
6825.2.1
by Jelmer Vernooij
Fix some tests for foreign branches. |
336 |
source_b, b_revid = self.make_simple_branch_with_ghost() |
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
337 |
target = self.make_repository('target') |
338 |
target.lock_write() |
|
339 |
self.addCleanup(target.unlock) |
|
6825.2.1
by Jelmer Vernooij
Fix some tests for foreign branches. |
340 |
target.fetch(source_b.repository, revision_id=b_revid) |
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
341 |
|
342 |
def test_fetch_into_smart_with_ghost(self): |
|
343 |
trans = self.make_smart_server('target') |
|
6825.2.1
by Jelmer Vernooij
Fix some tests for foreign branches. |
344 |
source_b, b_revid = self.make_simple_branch_with_ghost() |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
345 |
if not source_b.controldir._format.supports_transport(trans): |
6205.3.1
by Jelmer Vernooij
Add ControlDirFormat.supports_transport. |
346 |
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. |
347 |
target = self.make_repository('target') |
348 |
# Re-open the repository over the smart protocol
|
|
349 |
target = repository.Repository.open(trans.base) |
|
350 |
target.lock_write() |
|
351 |
self.addCleanup(target.unlock) |
|
352 |
try: |
|
6825.2.1
by Jelmer Vernooij
Fix some tests for foreign branches. |
353 |
target.fetch(source_b.repository, revision_id=b_revid) |
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
354 |
except errors.TokenLockingNotSupported: |
355 |
# The code inside fetch() that tries to lock and then fails, also
|
|
356 |
# causes weird problems with 'lock_not_held' later on...
|
|
357 |
target.lock_read() |
|
6050.1.2
by Martin
Make tests raising KnownFailure use the knownFailure method instead |
358 |
self.knownFailure('some repositories fail to fetch' |
7143.15.2
by Jelmer Vernooij
Run autopep8. |
359 |
' via the smart server because of locking issues.') |
4392.2.2
by John Arbash Meinel
Add tests that ensure we can fetch branches with ghosts in their ancestry. |
360 |
|
361 |
def test_fetch_from_smart_with_ghost(self): |
|
362 |
trans = self.make_smart_server('source') |
|
6825.2.1
by Jelmer Vernooij
Fix some tests for foreign branches. |
363 |
source_b, b_revid = self.make_simple_branch_with_ghost() |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
364 |
if not source_b.controldir._format.supports_transport(trans): |
6205.3.1
by Jelmer Vernooij
Add ControlDirFormat.supports_transport. |
365 |
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. |
366 |
target = self.make_repository('target') |
367 |
target.lock_write() |
|
368 |
self.addCleanup(target.unlock) |
|
369 |
# Re-open the repository over the smart protocol
|
|
370 |
source = repository.Repository.open(trans.base) |
|
371 |
source.lock_read() |
|
372 |
self.addCleanup(source.unlock) |
|
6825.2.1
by Jelmer Vernooij
Fix some tests for foreign branches. |
373 |
target.fetch(source, revision_id=b_revid) |