4988.10.5
by John Arbash Meinel
Merge bzr.dev 5021 to resolve NEWS |
1 |
# Copyright (C) 2006-2010 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
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
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
16 |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
17 |
"""Tests for repository implementations - tests a repository format."""
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
18 |
|
2520.4.54
by Aaron Bentley
Hang a create_bundle method off repository |
19 |
from cStringIO import StringIO |
1666.1.6
by Robert Collins
Make knit the default format. |
20 |
import re |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
21 |
|
1752.2.87
by Andrew Bennetts
Make tests pass. |
22 |
from bzrlib import ( |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
23 |
branch as _mod_branch, |
1752.2.87
by Andrew Bennetts
Make tests pass. |
24 |
bzrdir, |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
25 |
delta as _mod_delta, |
1752.2.87
by Andrew Bennetts
Make tests pass. |
26 |
errors, |
3735.2.100
by Vincent Ladeuil
Fix 3 failing tests due to an amazing typo. |
27 |
gpg, |
3184.1.9
by Robert Collins
* ``Repository.get_data_stream`` is now deprecated in favour of |
28 |
graph, |
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
29 |
info, |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
30 |
inventory, |
3305.1.1
by Jelmer Vernooij
Make sure that specifying the inv= argument to add_revision() sets the |
31 |
osutils, |
1752.2.87
by Andrew Bennetts
Make tests pass. |
32 |
remote, |
33 |
repository, |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
34 |
revision as _mod_revision, |
35 |
tests, |
|
36 |
transport, |
|
37 |
upgrade, |
|
38 |
versionedfile, |
|
39 |
workingtree, |
|
4416.5.1
by Jelmer Vernooij
Move squashing of XML-invalid characters to XMLSerializer. |
40 |
xml_serializer, |
1752.2.87
by Andrew Bennetts
Make tests pass. |
41 |
)
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
42 |
from bzrlib.repofmt import ( |
43 |
pack_repo, |
|
44 |
weaverepo, |
|
45 |
)
|
|
5017.3.42
by Vincent Ladeuil
-s bt.per_repository.test_repo passing |
46 |
from bzrlib.tests import ( |
47 |
per_repository, |
|
48 |
test_server, |
|
49 |
)
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
50 |
from bzrlib.tests.matchers import * |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
51 |
|
52 |
||
53 |
class TestRepositoryMakeBranchAndTree(per_repository.TestCaseWithRepository): |
|
2018.5.66
by Wouter van Heyst
Fix repository test parameterization for RemoteRepository. |
54 |
|
55 |
def test_repository_format(self): |
|
2018.5.119
by Robert Collins
Unbreak TestRepositoryMakeBranchAndTree. |
56 |
# make sure the repository on tree.branch is of the desired format,
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
57 |
# because developers use this api to setup the tree, branch and
|
2018.5.119
by Robert Collins
Unbreak TestRepositoryMakeBranchAndTree. |
58 |
# repository for their tests: having it now give the right repository
|
59 |
# type would invalidate the tests.
|
|
2018.5.66
by Wouter van Heyst
Fix repository test parameterization for RemoteRepository. |
60 |
tree = self.make_branch_and_tree('repo') |
61 |
self.assertIsInstance(tree.branch.repository._format, |
|
62 |
self.repository_format.__class__) |
|
2381.1.1
by Robert Collins
Split out hpss test fixes which dont depend on new or altered API's. |
63 |
|
64 |
||
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
65 |
class TestRepository(per_repository.TestCaseWithRepository): |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
66 |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
67 |
def assertFormatAttribute(self, attribute, allowed_values): |
68 |
"""Assert that the format has an attribute 'attribute'."""
|
|
69 |
repo = self.make_repository('repo') |
|
70 |
self.assertSubset([getattr(repo._format, attribute)], allowed_values) |
|
71 |
||
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
72 |
def test_attribute__fetch_order(self): |
4775.1.1
by Martin Pool
Remove several 'the the' typos |
73 |
"""Test the _fetch_order attribute."""
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
74 |
self.assertFormatAttribute('_fetch_order', ('topological', 'unordered')) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
75 |
|
76 |
def test_attribute__fetch_uses_deltas(self): |
|
4775.1.1
by Martin Pool
Remove several 'the the' typos |
77 |
"""Test the _fetch_uses_deltas attribute."""
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
78 |
self.assertFormatAttribute('_fetch_uses_deltas', (True, False)) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
79 |
|
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
80 |
def test_attribute_fast_deltas(self): |
81 |
"""Test the format.fast_deltas attribute."""
|
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
82 |
self.assertFormatAttribute('fast_deltas', (True, False)) |
4183.5.1
by Robert Collins
Add RepositoryFormat.fast_deltas to signal fast delta creation. |
83 |
|
3565.3.4
by Robert Collins
Defer decision to reconcile to the repository being fetched into. |
84 |
def test_attribute__fetch_reconcile(self): |
4775.1.1
by Martin Pool
Remove several 'the the' typos |
85 |
"""Test the _fetch_reconcile attribute."""
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
86 |
self.assertFormatAttribute('_fetch_reconcile', (True, False)) |
87 |
||
4988.9.1
by Jelmer Vernooij
Add experimental flag to RepositoryFormat. |
88 |
def test_attribute_format_experimental(self): |
89 |
self.assertFormatAttribute('experimental', (True, False)) |
|
90 |
||
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
91 |
def test_attribute_format_pack_compresses(self): |
92 |
self.assertFormatAttribute('pack_compresses', (True, False)) |
|
3565.3.4
by Robert Collins
Defer decision to reconcile to the repository being fetched into. |
93 |
|
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. |
94 |
def test_attribute_inventories_store(self): |
95 |
"""Test the existence of the inventories attribute."""
|
|
96 |
tree = self.make_branch_and_tree('tree') |
|
97 |
repo = tree.branch.repository |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
98 |
self.assertIsInstance(repo.inventories, versionedfile.VersionedFiles) |
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. |
99 |
|
100 |
def test_attribute_inventories_basics(self): |
|
101 |
"""Test basic aspects of the inventories attribute."""
|
|
102 |
tree = self.make_branch_and_tree('tree') |
|
103 |
repo = tree.branch.repository |
|
104 |
rev_id = (tree.commit('a'),) |
|
105 |
tree.lock_read() |
|
106 |
self.addCleanup(tree.unlock) |
|
107 |
self.assertEqual(set([rev_id]), set(repo.inventories.keys())) |
|
108 |
||
109 |
def test_attribute_revision_store(self): |
|
110 |
"""Test the existence of the revisions attribute."""
|
|
111 |
tree = self.make_branch_and_tree('tree') |
|
112 |
repo = tree.branch.repository |
|
113 |
self.assertIsInstance(repo.revisions, |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
114 |
versionedfile.VersionedFiles) |
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. |
115 |
|
116 |
def test_attribute_revision_store_basics(self): |
|
117 |
"""Test the basic behaviour of the revisions attribute."""
|
|
118 |
tree = self.make_branch_and_tree('tree') |
|
119 |
repo = tree.branch.repository |
|
120 |
repo.lock_write() |
|
121 |
try: |
|
122 |
self.assertEqual(set(), set(repo.revisions.keys())) |
|
123 |
revid = (tree.commit("foo"),) |
|
124 |
self.assertEqual(set([revid]), set(repo.revisions.keys())) |
|
125 |
self.assertEqual({revid:()}, |
|
126 |
repo.revisions.get_parent_map([revid])) |
|
127 |
finally: |
|
128 |
repo.unlock() |
|
129 |
tree2 = self.make_branch_and_tree('tree2') |
|
130 |
tree2.pull(tree.branch) |
|
131 |
left_id = (tree2.commit('left'),) |
|
132 |
right_id = (tree.commit('right'),) |
|
133 |
tree.merge_from_branch(tree2.branch) |
|
134 |
merge_id = (tree.commit('merged'),) |
|
135 |
repo.lock_read() |
|
136 |
self.addCleanup(repo.unlock) |
|
137 |
self.assertEqual(set([revid, left_id, right_id, merge_id]), |
|
138 |
set(repo.revisions.keys())) |
|
139 |
self.assertEqual({revid:(), left_id:(revid,), right_id:(revid,), |
|
140 |
merge_id:(right_id, left_id)}, |
|
141 |
repo.revisions.get_parent_map(repo.revisions.keys())) |
|
142 |
||
143 |
def test_attribute_signature_store(self): |
|
144 |
"""Test the existence of the signatures attribute."""
|
|
145 |
tree = self.make_branch_and_tree('tree') |
|
146 |
repo = tree.branch.repository |
|
147 |
self.assertIsInstance(repo.signatures, |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
148 |
versionedfile.VersionedFiles) |
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. |
149 |
|
150 |
def test_attribute_text_store_basics(self): |
|
151 |
"""Test the basic behaviour of the text store."""
|
|
152 |
tree = self.make_branch_and_tree('tree') |
|
153 |
repo = tree.branch.repository |
|
4398.7.1
by John Arbash Meinel
Fix some failing tests for repositories and win32. |
154 |
file_id = "Foo:Bar" |
155 |
file_key = (file_id,) |
|
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. |
156 |
tree.lock_write() |
157 |
try: |
|
158 |
self.assertEqual(set(), set(repo.texts.keys())) |
|
4398.7.1
by John Arbash Meinel
Fix some failing tests for repositories and win32. |
159 |
tree.add(['foo'], [file_id], ['file']) |
160 |
tree.put_file_bytes_non_atomic(file_id, 'content\n') |
|
161 |
try: |
|
162 |
rev_key = (tree.commit("foo"),) |
|
163 |
except errors.IllegalPath: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
164 |
raise tests.TestNotApplicable( |
165 |
'file_id %r cannot be stored on this' |
|
4398.7.1
by John Arbash Meinel
Fix some failing tests for repositories and win32. |
166 |
' platform for this repo format' % (file_id,)) |
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. |
167 |
if repo._format.rich_root_data: |
4398.7.1
by John Arbash Meinel
Fix some failing tests for repositories and win32. |
168 |
root_commit = (tree.get_root_id(),) + rev_key |
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. |
169 |
keys = set([root_commit]) |
170 |
parents = {root_commit:()} |
|
171 |
else: |
|
172 |
keys = set() |
|
173 |
parents = {} |
|
4398.7.1
by John Arbash Meinel
Fix some failing tests for repositories and win32. |
174 |
keys.add(file_key + rev_key) |
175 |
parents[file_key + rev_key] = () |
|
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. |
176 |
self.assertEqual(keys, set(repo.texts.keys())) |
177 |
self.assertEqual(parents, |
|
178 |
repo.texts.get_parent_map(repo.texts.keys())) |
|
179 |
finally: |
|
180 |
tree.unlock() |
|
181 |
tree2 = self.make_branch_and_tree('tree2') |
|
182 |
tree2.pull(tree.branch) |
|
183 |
tree2.put_file_bytes_non_atomic('Foo:Bar', 'right\n') |
|
4398.7.1
by John Arbash Meinel
Fix some failing tests for repositories and win32. |
184 |
right_key = (tree2.commit('right'),) |
185 |
keys.add(file_key + right_key) |
|
186 |
parents[file_key + right_key] = (file_key + rev_key,) |
|
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. |
187 |
tree.put_file_bytes_non_atomic('Foo:Bar', 'left\n') |
4398.7.1
by John Arbash Meinel
Fix some failing tests for repositories and win32. |
188 |
left_key = (tree.commit('left'),) |
189 |
keys.add(file_key + left_key) |
|
190 |
parents[file_key + left_key] = (file_key + rev_key,) |
|
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. |
191 |
tree.merge_from_branch(tree2.branch) |
192 |
tree.put_file_bytes_non_atomic('Foo:Bar', 'merged\n') |
|
193 |
try: |
|
194 |
tree.auto_resolve() |
|
195 |
except errors.UnsupportedOperation: |
|
196 |
pass
|
|
4398.7.1
by John Arbash Meinel
Fix some failing tests for repositories and win32. |
197 |
merge_key = (tree.commit('merged'),) |
198 |
keys.add(file_key + merge_key) |
|
199 |
parents[file_key + merge_key] = (file_key + left_key, |
|
200 |
file_key + right_key) |
|
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. |
201 |
repo.lock_read() |
202 |
self.addCleanup(repo.unlock) |
|
203 |
self.assertEqual(keys, set(repo.texts.keys())) |
|
204 |
self.assertEqual(parents, repo.texts.get_parent_map(repo.texts.keys())) |
|
205 |
||
206 |
def test_attribute_text_store(self): |
|
207 |
"""Test the existence of the texts attribute."""
|
|
208 |
tree = self.make_branch_and_tree('tree') |
|
209 |
repo = tree.branch.repository |
|
210 |
self.assertIsInstance(repo.texts, |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
211 |
versionedfile.VersionedFiles) |
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. |
212 |
|
213 |
def test_exposed_versioned_files_are_marked_dirty(self): |
|
214 |
repo = self.make_repository('.') |
|
215 |
repo.lock_write() |
|
216 |
signatures = repo.signatures |
|
217 |
revisions = repo.revisions |
|
218 |
inventories = repo.inventories |
|
219 |
repo.unlock() |
|
220 |
self.assertRaises(errors.ObjectNotLocked, |
|
221 |
signatures.keys) |
|
222 |
self.assertRaises(errors.ObjectNotLocked, |
|
223 |
revisions.keys) |
|
224 |
self.assertRaises(errors.ObjectNotLocked, |
|
225 |
inventories.keys) |
|
226 |
self.assertRaises(errors.ObjectNotLocked, |
|
227 |
signatures.add_lines, ('foo',), [], []) |
|
228 |
self.assertRaises(errors.ObjectNotLocked, |
|
229 |
revisions.add_lines, ('foo',), [], []) |
|
230 |
self.assertRaises(errors.ObjectNotLocked, |
|
231 |
inventories.add_lines, ('foo',), [], []) |
|
232 |
||
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
233 |
def test_clone_to_default_format(self): |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
234 |
#TODO: Test that cloning a repository preserves all the information
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
235 |
# such as signatures[not tested yet] etc etc.
|
236 |
# when changing to the current default format.
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
237 |
tree_a = self.make_branch_and_tree('a') |
2381.1.3
by Robert Collins
Review feedback. |
238 |
self.build_tree(['a/foo']) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
239 |
tree_a.add('foo', 'file1') |
240 |
tree_a.commit('rev1', rev_id='rev1') |
|
241 |
bzrdirb = self.make_bzrdir('b') |
|
242 |
repo_b = tree_a.branch.repository.clone(bzrdirb) |
|
243 |
tree_b = repo_b.revision_tree('rev1') |
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
244 |
tree_b.lock_read() |
245 |
self.addCleanup(tree_b.unlock) |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
246 |
tree_b.get_file_text('file1') |
247 |
rev1 = repo_b.get_revision('rev1') |
|
248 |
||
3169.2.1
by Robert Collins
New method ``iter_inventories`` on Repository for access to many |
249 |
def test_iter_inventories_is_ordered(self): |
250 |
# just a smoke test
|
|
251 |
tree = self.make_branch_and_tree('a') |
|
252 |
first_revision = tree.commit('') |
|
253 |
second_revision = tree.commit('') |
|
254 |
tree.lock_read() |
|
255 |
self.addCleanup(tree.unlock) |
|
256 |
revs = (first_revision, second_revision) |
|
257 |
invs = tree.branch.repository.iter_inventories(revs) |
|
258 |
for rev_id, inv in zip(revs, invs): |
|
259 |
self.assertEqual(rev_id, inv.revision_id) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
260 |
self.assertIsInstance(inv, inventory.CommonInventory) |
3169.2.1
by Robert Collins
New method ``iter_inventories`` on Repository for access to many |
261 |
|
1910.2.63
by Aaron Bentley
Add supports_rich_root member to repository |
262 |
def test_supports_rich_root(self): |
263 |
tree = self.make_branch_and_tree('a') |
|
264 |
tree.commit('') |
|
265 |
second_revision = tree.commit('') |
|
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
266 |
rev_tree = tree.branch.repository.revision_tree(second_revision) |
267 |
rev_tree.lock_read() |
|
268 |
self.addCleanup(rev_tree.unlock) |
|
269 |
inv = rev_tree.inventory |
|
1910.2.63
by Aaron Bentley
Add supports_rich_root member to repository |
270 |
rich_root = (inv.root.revision != second_revision) |
2018.5.113
by Robert Collins
Test only fixes from the ported-to-bzr.dev test-correctness branch. |
271 |
self.assertEqual(rich_root, |
1910.2.63
by Aaron Bentley
Add supports_rich_root member to repository |
272 |
tree.branch.repository.supports_rich_root()) |
273 |
||
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
274 |
def test_clone_specific_format(self): |
275 |
"""todo"""
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
276 |
|
277 |
def test_format_initialize_find_open(self): |
|
278 |
# loopback test to check the current format initializes to itself.
|
|
279 |
if not self.repository_format.is_supported(): |
|
280 |
# unsupported formats are not loopback testable
|
|
281 |
# because the default open will not open them and
|
|
282 |
# they may not be initializable.
|
|
283 |
return
|
|
284 |
# supported formats must be able to init and open
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
285 |
t = transport.get_transport(self.get_url()) |
286 |
readonly_t = transport.get_transport(self.get_readonly_url()) |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
287 |
made_control = self.bzrdir_format.initialize(t.base) |
288 |
made_repo = self.repository_format.initialize(made_control) |
|
289 |
self.assertEqual(made_control, made_repo.bzrdir) |
|
290 |
||
291 |
# find it via bzrdir opening:
|
|
292 |
opened_control = bzrdir.BzrDir.open(readonly_t.base) |
|
293 |
direct_opened_repo = opened_control.open_repository() |
|
294 |
self.assertEqual(direct_opened_repo.__class__, made_repo.__class__) |
|
295 |
self.assertEqual(opened_control, direct_opened_repo.bzrdir) |
|
296 |
||
1752.2.52
by Andrew Bennetts
Flesh out more Remote* methods needed to open and initialise remote branches/trees/repositories. |
297 |
self.assertIsInstance(direct_opened_repo._format, |
298 |
self.repository_format.__class__) |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
299 |
# find it via Repository.open
|
300 |
opened_repo = repository.Repository.open(readonly_t.base) |
|
301 |
self.failUnless(isinstance(opened_repo, made_repo.__class__)) |
|
302 |
self.assertEqual(made_repo._format.__class__, |
|
303 |
opened_repo._format.__class__) |
|
304 |
# if it has a unique id string, can we probe for it ?
|
|
305 |
try: |
|
306 |
self.repository_format.get_format_string() |
|
307 |
except NotImplementedError: |
|
308 |
return
|
|
309 |
self.assertEqual(self.repository_format, |
|
310 |
repository.RepositoryFormat.find_format(opened_control)) |
|
311 |
||
3845.1.1
by John Arbash Meinel
Ensure that RepositoryFormat._matchingbzrdir.repository_format matches. |
312 |
def test_format_matchingbzrdir(self): |
313 |
self.assertEqual(self.repository_format, |
|
314 |
self.repository_format._matchingbzrdir.repository_format) |
|
315 |
self.assertEqual(self.repository_format, |
|
316 |
self.bzrdir_format.repository_format) |
|
317 |
||
3990.5.1
by Andrew Bennetts
Add network_name() to RepositoryFormat. |
318 |
def test_format_network_name(self): |
319 |
repo = self.make_repository('r') |
|
320 |
format = repo._format |
|
321 |
network_name = format.network_name() |
|
322 |
self.assertIsInstance(network_name, str) |
|
323 |
# We want to test that the network_name matches the actual format on
|
|
324 |
# disk. For local repositories, that means that using network_name as
|
|
325 |
# a key in the registry gives back the same format. For remote
|
|
326 |
# repositories, that means that the network_name of the
|
|
327 |
# RemoteRepositoryFormat we have locally matches the actual format
|
|
328 |
# present on the remote side.
|
|
329 |
if isinstance(format, remote.RemoteRepositoryFormat): |
|
330 |
repo._ensure_real() |
|
331 |
real_repo = repo._real_repository |
|
332 |
self.assertEqual(real_repo._format.network_name(), network_name) |
|
333 |
else: |
|
334 |
registry = repository.network_format_registry |
|
335 |
looked_up_format = registry.get(network_name) |
|
336 |
self.assertEqual(format.__class__, looked_up_format.__class__) |
|
337 |
||
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
338 |
def test_create_repository(self): |
1534.6.1
by Robert Collins
allow API creation of shared repositories |
339 |
# bzrdir can construct a repository for itself.
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
340 |
if not self.bzrdir_format.is_supported(): |
341 |
# unsupported formats are not loopback testable
|
|
342 |
# because the default open will not open them and
|
|
343 |
# they may not be initializable.
|
|
344 |
return
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
345 |
t = transport.get_transport(self.get_url()) |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
346 |
made_control = self.bzrdir_format.initialize(t.base) |
347 |
made_repo = made_control.create_repository() |
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
348 |
# Check that we have a repository object.
|
349 |
made_repo.has_revision('foo') |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
350 |
self.assertEqual(made_control, made_repo.bzrdir) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
351 |
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
352 |
def test_create_repository_shared(self): |
353 |
# bzrdir can construct a shared repository.
|
|
354 |
if not self.bzrdir_format.is_supported(): |
|
355 |
# unsupported formats are not loopback testable
|
|
356 |
# because the default open will not open them and
|
|
357 |
# they may not be initializable.
|
|
358 |
return
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
359 |
t = transport.get_transport(self.get_url()) |
1534.6.1
by Robert Collins
allow API creation of shared repositories |
360 |
made_control = self.bzrdir_format.initialize(t.base) |
361 |
try: |
|
362 |
made_repo = made_control.create_repository(shared=True) |
|
363 |
except errors.IncompatibleFormat: |
|
364 |
# not all repository formats understand being shared, or
|
|
365 |
# may only be shared in some circumstances.
|
|
366 |
return
|
|
1752.2.50
by Andrew Bennetts
Implement RemoteBzrDir.create_{branch,workingtree} |
367 |
# Check that we have a repository object.
|
368 |
made_repo.has_revision('foo') |
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
369 |
self.assertEqual(made_control, made_repo.bzrdir) |
1534.6.3
by Robert Collins
find_repository sufficiently robust. |
370 |
self.assertTrue(made_repo.is_shared()) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
371 |
|
372 |
def test_revision_tree(self): |
|
373 |
wt = self.make_branch_and_tree('.') |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
374 |
wt.set_root_id('fixed-root') |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
375 |
wt.commit('lala!', rev_id='revision-1', allow_pointless=True) |
376 |
tree = wt.branch.repository.revision_tree('revision-1') |
|
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
377 |
tree.lock_read() |
378 |
try: |
|
379 |
self.assertEqual('revision-1', tree.inventory.root.revision) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
380 |
expected = inventory.InventoryDirectory('fixed-root', '', None) |
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
381 |
expected.revision = 'revision-1' |
382 |
self.assertEqual([('', 'V', 'directory', 'fixed-root', expected)], |
|
383 |
list(tree.list_files(include_root=True))) |
|
384 |
finally: |
|
385 |
tree.unlock() |
|
3668.5.3
by Jelmer Vernooij
Add test to make sure revision_tree(None) prints a deprecation warning. |
386 |
tree = self.callDeprecated(['NULL_REVISION should be used for the null' |
387 |
' revision instead of None, as of bzr 0.91.'], |
|
388 |
wt.branch.repository.revision_tree, None) |
|
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
389 |
tree.lock_read() |
390 |
try: |
|
391 |
self.assertEqual([], list(tree.list_files(include_root=True))) |
|
392 |
finally: |
|
393 |
tree.unlock() |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
394 |
tree = wt.branch.repository.revision_tree(_mod_revision.NULL_REVISION) |
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
395 |
tree.lock_read() |
396 |
try: |
|
397 |
self.assertEqual([], list(tree.list_files(include_root=True))) |
|
398 |
finally: |
|
399 |
tree.unlock() |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
400 |
|
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
401 |
def test_get_revision_delta(self): |
402 |
tree_a = self.make_branch_and_tree('a') |
|
2381.1.3
by Robert Collins
Review feedback. |
403 |
self.build_tree(['a/foo']) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
404 |
tree_a.add('foo', 'file1') |
405 |
tree_a.commit('rev1', rev_id='rev1') |
|
2381.1.3
by Robert Collins
Review feedback. |
406 |
self.build_tree(['a/vla']) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
407 |
tree_a.add('vla', 'file2') |
408 |
tree_a.commit('rev2', rev_id='rev2') |
|
409 |
||
410 |
delta = tree_a.branch.repository.get_revision_delta('rev1') |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
411 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
412 |
self.assertEqual([('foo', 'file1', 'file')], delta.added) |
413 |
delta = tree_a.branch.repository.get_revision_delta('rev2') |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
414 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
1770.3.3
by Jelmer Vernooij
Add tests for Branch.get_revision_delta() and Repository.get_revision_delta(). |
415 |
self.assertEqual([('vla', 'file2', 'file')], delta.added) |
416 |
||
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
417 |
def test_get_revision_delta_filtered(self): |
418 |
tree_a = self.make_branch_and_tree('a') |
|
419 |
self.build_tree(['a/foo', 'a/bar/', 'a/bar/b1', 'a/bar/b2', 'a/baz']) |
|
420 |
tree_a.add(['foo', 'bar', 'bar/b1', 'bar/b2', 'baz'], |
|
421 |
['foo-id', 'bar-id', 'b1-id', 'b2-id', 'baz-id']) |
|
422 |
tree_a.commit('rev1', rev_id='rev1') |
|
423 |
self.build_tree(['a/bar/b3']) |
|
424 |
tree_a.add('bar/b3', 'b3-id') |
|
425 |
tree_a.commit('rev2', rev_id='rev2') |
|
426 |
||
427 |
# Test multiple files
|
|
428 |
delta = tree_a.branch.repository.get_revision_delta('rev1', |
|
429 |
specific_fileids=['foo-id', 'baz-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
430 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
431 |
self.assertEqual([ |
432 |
('baz', 'baz-id', 'file'), |
|
433 |
('foo', 'foo-id', 'file'), |
|
434 |
], delta.added) |
|
435 |
# Test a directory
|
|
436 |
delta = tree_a.branch.repository.get_revision_delta('rev1', |
|
437 |
specific_fileids=['bar-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
438 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
439 |
self.assertEqual([ |
440 |
('bar', 'bar-id', 'directory'), |
|
441 |
('bar/b1', 'b1-id', 'file'), |
|
442 |
('bar/b2', 'b2-id', 'file'), |
|
443 |
], delta.added) |
|
444 |
# Test a file in a directory
|
|
445 |
delta = tree_a.branch.repository.get_revision_delta('rev1', |
|
446 |
specific_fileids=['b2-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
447 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
448 |
self.assertEqual([ |
449 |
('bar', 'bar-id', 'directory'), |
|
450 |
('bar/b2', 'b2-id', 'file'), |
|
451 |
], delta.added) |
|
452 |
# Try another revision
|
|
453 |
delta = tree_a.branch.repository.get_revision_delta('rev2', |
|
454 |
specific_fileids=['b3-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
455 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
456 |
self.assertEqual([ |
457 |
('bar', 'bar-id', 'directory'), |
|
458 |
('bar/b3', 'b3-id', 'file'), |
|
459 |
], delta.added) |
|
460 |
delta = tree_a.branch.repository.get_revision_delta('rev2', |
|
461 |
specific_fileids=['foo-id']) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
462 |
self.assertIsInstance(delta, _mod_delta.TreeDelta) |
4137.3.2
by Ian Clatworthy
Repository.get_deltas_for_revisions() now supports file-id filtering |
463 |
self.assertEqual([], delta.added) |
464 |
||
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
465 |
def test_clone_bzrdir_repository_revision(self): |
466 |
# make a repository with some revisions,
|
|
467 |
# and clone it, this should not have unreferenced revisions.
|
|
468 |
# also: test cloning with a revision id of NULL_REVISION -> empty repo.
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
469 |
raise tests.TestSkipped('revision limiting is not implemented yet.') |
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
470 |
|
471 |
def test_clone_repository_basis_revision(self): |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
472 |
raise tests.TestSkipped( |
473 |
'the use of a basis should not add noise data to the result.') |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
474 |
|
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
475 |
def test_clone_shared_no_tree(self): |
476 |
# cloning a shared repository keeps it shared
|
|
477 |
# and preserves the make_working_tree setting.
|
|
478 |
made_control = self.make_bzrdir('source') |
|
479 |
try: |
|
480 |
made_repo = made_control.create_repository(shared=True) |
|
481 |
except errors.IncompatibleFormat: |
|
482 |
# not all repository formats understand being shared, or
|
|
483 |
# may only be shared in some circumstances.
|
|
484 |
return
|
|
2018.14.2
by Andrew Bennetts
All but one repository_implementation tests for RemoteRepository passing. |
485 |
try: |
486 |
made_repo.set_make_working_trees(False) |
|
487 |
except NotImplementedError: |
|
2018.5.120
by Robert Collins
The Repository API ``make_working_trees`` is now permitted to return |
488 |
# the repository does not support having its tree-making flag
|
489 |
# toggled.
|
|
490 |
return
|
|
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
491 |
result = made_control.clone(self.get_url('target')) |
1752.2.55
by Andrew Bennetts
Replace another isinstance(made_repo, Repository) check. |
492 |
# Check that we have a repository object.
|
493 |
made_repo.has_revision('foo') |
|
494 |
||
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
495 |
self.assertEqual(made_control, made_repo.bzrdir) |
496 |
self.assertTrue(result.open_repository().is_shared()) |
|
497 |
self.assertFalse(result.open_repository().make_working_trees()) |
|
498 |
||
2018.5.90
by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository. |
499 |
def test_upgrade_preserves_signatures(self): |
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
500 |
wt = self.make_branch_and_tree('source') |
501 |
wt.commit('A', allow_pointless=True, rev_id='A') |
|
2018.5.90
by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository. |
502 |
repo = wt.branch.repository |
2592.3.39
by Robert Collins
Fugly version to remove signatures.kndx |
503 |
repo.lock_write() |
504 |
repo.start_write_group() |
|
3735.2.100
by Vincent Ladeuil
Fix 3 failing tests due to an amazing typo. |
505 |
repo.sign_revision('A', gpg.LoopbackGPGStrategy(None)) |
2592.3.39
by Robert Collins
Fugly version to remove signatures.kndx |
506 |
repo.commit_write_group() |
507 |
repo.unlock() |
|
2018.5.90
by Andrew Bennetts
Fix test_upgrade_preserves_signatures; it incorrectly assumed that upgrade(wt, ...) would necessarily affect the repository. |
508 |
old_signature = repo.get_signature_text('A') |
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
509 |
try: |
510 |
old_format = bzrdir.BzrDirFormat.get_default_format() |
|
511 |
# This gives metadir branches something they can convert to.
|
|
512 |
# it would be nice to have a 'latest' vs 'default' concept.
|
|
2255.2.208
by Robert Collins
Remove more references to 'experimental' formats. |
513 |
format = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree') |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
514 |
upgrade.upgrade(repo.bzrdir.root_transport.base, format=format) |
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
515 |
except errors.UpToDateFormat: |
516 |
# this is in the most current format already.
|
|
517 |
return
|
|
1910.2.12
by Aaron Bentley
Implement knit repo format 2 |
518 |
except errors.BadConversionTarget, e: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
519 |
raise tests.TestSkipped(str(e)) |
520 |
wt = workingtree.WorkingTree.open(wt.basedir) |
|
1563.2.31
by Robert Collins
Convert Knit repositories to use knits. |
521 |
new_signature = wt.branch.repository.get_signature_text('A') |
1556.1.4
by Robert Collins
Add a new format for what will become knit, and the surrounding logic to upgrade repositories within metadirs, and tests for the same. |
522 |
self.assertEqual(old_signature, new_signature) |
523 |
||
1624.3.19
by Olaf Conradi
New call get_format_description to give a user-friendly description of a |
524 |
def test_format_description(self): |
525 |
repo = self.make_repository('.') |
|
526 |
text = repo._format.get_format_description() |
|
527 |
self.failUnless(len(text)) |
|
528 |
||
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
529 |
def test_format_supports_external_lookups(self): |
530 |
repo = self.make_repository('.') |
|
531 |
self.assertSubset( |
|
532 |
[repo._format.supports_external_lookups], (True, False)) |
|
533 |
||
1666.1.6
by Robert Collins
Make knit the default format. |
534 |
def assertMessageRoundtrips(self, message): |
535 |
"""Assert that message roundtrips to a repository and back intact."""
|
|
536 |
tree = self.make_branch_and_tree('.') |
|
537 |
tree.commit(message, rev_id='a', allow_pointless=True) |
|
538 |
rev = tree.branch.repository.get_revision('a') |
|
4416.5.1
by Jelmer Vernooij
Move squashing of XML-invalid characters to XMLSerializer. |
539 |
if tree.branch.repository._serializer.squashes_xml_invalid_characters: |
540 |
# we have to manually escape this as we dont try to
|
|
4443.1.2
by Jelmer Vernooij
Fix comment about XML escaping in tests. |
541 |
# roundtrip xml invalid characters in the xml-based serializers.
|
4416.5.1
by Jelmer Vernooij
Move squashing of XML-invalid characters to XMLSerializer. |
542 |
escaped_message, escape_count = re.subn( |
543 |
u'[^\x09\x0A\x0D\u0020-\uD7FF\uE000-\uFFFD]+', |
|
544 |
lambda match: match.group(0).encode('unicode_escape'), |
|
545 |
message) |
|
546 |
self.assertEqual(rev.message, escaped_message) |
|
547 |
else: |
|
548 |
self.assertEqual(rev.message, message) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
549 |
# insist the class is unicode no matter what came in for
|
1666.1.6
by Robert Collins
Make knit the default format. |
550 |
# consistency.
|
551 |
self.assertIsInstance(rev.message, unicode) |
|
552 |
||
553 |
def test_commit_unicode_message(self): |
|
554 |
# a siple unicode message should be preserved
|
|
555 |
self.assertMessageRoundtrips(u'foo bar gamm\xae plop') |
|
556 |
||
557 |
def test_commit_unicode_control_characters(self): |
|
558 |
# a unicode message with control characters should roundtrip too.
|
|
3831.1.4
by John Arbash Meinel
Update the per-repository unicode commit test. |
559 |
unichars = [unichr(x) for x in range(256)] |
560 |
# '\r' is not directly allowed anymore, as it used to be translated
|
|
561 |
# into '\n' anyway
|
|
562 |
unichars[ord('\r')] = u'\n' |
|
1666.1.6
by Robert Collins
Make knit the default format. |
563 |
self.assertMessageRoundtrips( |
3831.1.4
by John Arbash Meinel
Update the per-repository unicode commit test. |
564 |
u"All 8-bit chars: " + ''.join(unichars)) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
565 |
|
1732.2.4
by Martin Pool
Split check into Branch.check and Repository.check |
566 |
def test_check_repository(self): |
567 |
"""Check a fairly simple repository's history"""
|
|
568 |
tree = self.make_branch_and_tree('.') |
|
569 |
tree.commit('initial empty commit', rev_id='a-rev', |
|
570 |
allow_pointless=True) |
|
2745.6.39
by Andrew Bennetts
Use scenario in test_check too, and make check actually report inconsistent parents to the end user. |
571 |
result = tree.branch.repository.check() |
1732.2.4
by Martin Pool
Split check into Branch.check and Repository.check |
572 |
# writes to log; should accept both verbose or non-verbose
|
573 |
result.report_results(verbose=True) |
|
574 |
result.report_results(verbose=False) |
|
575 |
||
1756.1.5
by Aaron Bentley
Test get_revisions with all repository types (and fix bug...) |
576 |
def test_get_revisions(self): |
577 |
tree = self.make_branch_and_tree('.') |
|
578 |
tree.commit('initial empty commit', rev_id='a-rev', |
|
579 |
allow_pointless=True) |
|
580 |
tree.commit('second empty commit', rev_id='b-rev', |
|
581 |
allow_pointless=True) |
|
582 |
tree.commit('third empty commit', rev_id='c-rev', |
|
583 |
allow_pointless=True) |
|
584 |
repo = tree.branch.repository |
|
585 |
revision_ids = ['a-rev', 'b-rev', 'c-rev'] |
|
586 |
revisions = repo.get_revisions(revision_ids) |
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
587 |
self.assertEqual(len(revisions), 3) |
1756.1.5
by Aaron Bentley
Test get_revisions with all repository types (and fix bug...) |
588 |
zipped = zip(revisions, revision_ids) |
589 |
self.assertEqual(len(zipped), 3) |
|
590 |
for revision, revision_id in zipped: |
|
591 |
self.assertEqual(revision.revision_id, revision_id) |
|
592 |
self.assertEqual(revision, repo.get_revision(revision_id)) |
|
1732.2.4
by Martin Pool
Split check into Branch.check and Repository.check |
593 |
|
1910.2.1
by Aaron Bentley
Ensure root entry always has a revision |
594 |
def test_root_entry_has_revision(self): |
595 |
tree = self.make_branch_and_tree('.') |
|
596 |
tree.commit('message', rev_id='rev_id') |
|
2255.7.65
by Robert Collins
Split test_root_revision_entry into tree and repository portions. |
597 |
rev_tree = tree.branch.repository.revision_tree(tree.last_revision()) |
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
598 |
rev_tree.lock_read() |
599 |
self.addCleanup(rev_tree.unlock) |
|
1910.2.6
by Aaron Bentley
Update for merge review, handle deprecations |
600 |
self.assertEqual('rev_id', rev_tree.inventory.root.revision) |
1910.2.1
by Aaron Bentley
Ensure root entry always has a revision |
601 |
|
1910.2.36
by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats |
602 |
def test_upgrade_from_format4(self): |
603 |
from bzrlib.tests.test_upgrade import _upgrade_dir_template |
|
4792.1.2
by Andrew Bennetts
Fix test failure. |
604 |
if isinstance(self.repository_format, remote.RemoteRepositoryFormat): |
605 |
return # local conversion to/from RemoteObjects is irrelevant. |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
606 |
if self.repository_format.get_format_description() \ |
607 |
== "Repository format 4": |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
608 |
raise tests.TestSkipped('Cannot convert format-4 to itself') |
1910.2.36
by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats |
609 |
self.build_tree_contents(_upgrade_dir_template) |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
610 |
old_repodir = bzrdir.BzrDir.open_unsupported('.') |
1910.2.36
by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats |
611 |
old_repo_format = old_repodir.open_repository()._format |
612 |
format = self.repository_format._matchingbzrdir |
|
613 |
try: |
|
614 |
format.repository_format = self.repository_format |
|
615 |
except AttributeError: |
|
616 |
pass
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
617 |
upgrade.upgrade('.', format) |
1910.2.36
by Aaron Bentley
Get upgrade from format4 under test and fixed for all formats |
618 |
|
1910.2.37
by Aaron Bentley
Handle empty commits, fix test |
619 |
def test_pointless_commit(self): |
620 |
tree = self.make_branch_and_tree('.') |
|
621 |
self.assertRaises(errors.PointlessCommit, tree.commit, 'pointless', |
|
622 |
allow_pointless=False) |
|
623 |
tree.commit('pointless', allow_pointless=True) |
|
624 |
||
2323.5.17
by Martin Pool
Add supports_tree_reference to all repo formats (robert) |
625 |
def test_format_attributes(self): |
626 |
"""All repository formats should have some basic attributes."""
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
627 |
# create a repository to get a real format instance, not the
|
3128.1.3
by Vincent Ladeuil
Since we are there s/parameteris.*/parameteriz&/. |
628 |
# template from the test suite parameterization.
|
2323.5.17
by Martin Pool
Add supports_tree_reference to all repo formats (robert) |
629 |
repo = self.make_repository('.') |
630 |
repo._format.rich_root_data |
|
631 |
repo._format.supports_tree_reference |
|
632 |
||
2520.4.113
by Aaron Bentley
Avoid peeking at Repository._serializer |
633 |
def test_get_serializer_format(self): |
634 |
repo = self.make_repository('.') |
|
635 |
format = repo.get_serializer_format() |
|
636 |
self.assertEqual(repo._serializer.format_num, format) |
|
637 |
||
2708.1.7
by Aaron Bentley
Rename extract_files_bytes to iter_files_bytes |
638 |
def test_iter_files_bytes(self): |
2708.1.3
by Aaron Bentley
Implement extract_files_bytes on Repository |
639 |
tree = self.make_branch_and_tree('tree') |
640 |
self.build_tree_contents([('tree/file1', 'foo'), |
|
641 |
('tree/file2', 'bar')]) |
|
642 |
tree.add(['file1', 'file2'], ['file1-id', 'file2-id']) |
|
643 |
tree.commit('rev1', rev_id='rev1') |
|
644 |
self.build_tree_contents([('tree/file1', 'baz')]) |
|
645 |
tree.commit('rev2', rev_id='rev2') |
|
2708.1.11
by Aaron Bentley
Test and tweak error handling |
646 |
repository = tree.branch.repository |
2592.3.214
by Robert Collins
Merge bzr.dev. |
647 |
repository.lock_read() |
648 |
self.addCleanup(repository.unlock) |
|
2708.1.6
by Aaron Bentley
Turn extract_files_bytes into an iterator |
649 |
extracted = dict((i, ''.join(b)) for i, b in |
2708.1.11
by Aaron Bentley
Test and tweak error handling |
650 |
repository.iter_files_bytes( |
2708.1.6
by Aaron Bentley
Turn extract_files_bytes into an iterator |
651 |
[('file1-id', 'rev1', 'file1-old'), |
652 |
('file1-id', 'rev2', 'file1-new'), |
|
653 |
('file2-id', 'rev1', 'file2'), |
|
654 |
]))
|
|
655 |
self.assertEqual('foo', extracted['file1-old']) |
|
656 |
self.assertEqual('bar', extracted['file2']) |
|
657 |
self.assertEqual('baz', extracted['file1-new']) |
|
2708.1.11
by Aaron Bentley
Test and tweak error handling |
658 |
self.assertRaises(errors.RevisionNotPresent, list, |
659 |
repository.iter_files_bytes( |
|
660 |
[('file1-id', 'rev3', 'file1-notpresent')])) |
|
2592.3.102
by Robert Collins
Change the iter_files_bytes error to allow either RevisionNotPresent or NoSuchId when requesting a file that was not in the repository at all. |
661 |
self.assertRaises((errors.RevisionNotPresent, errors.NoSuchId), list, |
2708.1.11
by Aaron Bentley
Test and tweak error handling |
662 |
repository.iter_files_bytes( |
663 |
[('file3-id', 'rev3', 'file1-notpresent')])) |
|
2708.1.3
by Aaron Bentley
Implement extract_files_bytes on Repository |
664 |
|
2535.3.63
by Andrew Bennetts
Add repository implementations test for item_keys_introduced_by. |
665 |
def test_item_keys_introduced_by(self): |
666 |
# Make a repo with one revision and one versioned file.
|
|
667 |
tree = self.make_branch_and_tree('t') |
|
668 |
self.build_tree(['t/foo']) |
|
669 |
tree.add('foo', 'file1') |
|
670 |
tree.commit('message', rev_id='rev_id') |
|
671 |
repo = tree.branch.repository |
|
3825.5.2
by Andrew Bennetts
Ensure that item_keys_introduced_by returns the |
672 |
repo.lock_write() |
673 |
repo.start_write_group() |
|
3735.2.100
by Vincent Ladeuil
Fix 3 failing tests due to an amazing typo. |
674 |
repo.sign_revision('rev_id', gpg.LoopbackGPGStrategy(None)) |
3825.5.2
by Andrew Bennetts
Ensure that item_keys_introduced_by returns the |
675 |
repo.commit_write_group() |
676 |
repo.unlock() |
|
3381.1.3
by Aaron Bentley
Stop locking in get_data_stream_for_search |
677 |
repo.lock_read() |
678 |
self.addCleanup(repo.unlock) |
|
2535.3.63
by Andrew Bennetts
Add repository implementations test for item_keys_introduced_by. |
679 |
|
680 |
# Item keys will be in this order, for maximum convenience for
|
|
681 |
# generating data to insert into knit repository:
|
|
682 |
# * files
|
|
683 |
# * inventory
|
|
684 |
# * signatures
|
|
685 |
# * revisions
|
|
686 |
expected_item_keys = [ |
|
687 |
('file', 'file1', ['rev_id']), |
|
688 |
('inventory', None, ['rev_id']), |
|
3825.5.2
by Andrew Bennetts
Ensure that item_keys_introduced_by returns the |
689 |
('signatures', None, ['rev_id']), |
2535.3.63
by Andrew Bennetts
Add repository implementations test for item_keys_introduced_by. |
690 |
('revisions', None, ['rev_id'])] |
691 |
item_keys = list(repo.item_keys_introduced_by(['rev_id'])) |
|
692 |
item_keys = [ |
|
693 |
(kind, file_id, list(versions)) |
|
694 |
for (kind, file_id, versions) in item_keys] |
|
695 |
||
696 |
if repo.supports_rich_root(): |
|
697 |
# Check for the root versioned file in the item_keys, then remove
|
|
698 |
# it from streamed_names so we can compare that with
|
|
699 |
# expected_record_names.
|
|
700 |
# Note that the file keys can be in any order, so this test is
|
|
701 |
# written to allow that.
|
|
702 |
inv = repo.get_inventory('rev_id') |
|
703 |
root_item_key = ('file', inv.root.file_id, ['rev_id']) |
|
704 |
self.assertTrue(root_item_key in item_keys) |
|
705 |
item_keys.remove(root_item_key) |
|
706 |
||
707 |
self.assertEqual(expected_item_keys, item_keys) |
|
708 |
||
2850.4.1
by Andrew Bennetts
Add smoketest for repo.get_graph, and fix bug in RemoteRepository.get_graph that it reveals. |
709 |
def test_get_graph(self): |
710 |
"""Bare-bones smoketest that all repositories implement get_graph."""
|
|
711 |
repo = self.make_repository('repo') |
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
712 |
repo.lock_read() |
713 |
self.addCleanup(repo.unlock) |
|
2850.4.1
by Andrew Bennetts
Add smoketest for repo.get_graph, and fix bug in RemoteRepository.get_graph that it reveals. |
714 |
repo.get_graph() |
715 |
||
3146.1.1
by Aaron Bentley
Fix bad ghost handling in KnitParentsProvider |
716 |
def test_graph_ghost_handling(self): |
717 |
tree = self.make_branch_and_tree('here') |
|
718 |
tree.lock_write() |
|
719 |
self.addCleanup(tree.unlock) |
|
720 |
tree.commit('initial commit', rev_id='rev1') |
|
721 |
tree.add_parent_tree_id('ghost') |
|
722 |
tree.commit('commit-with-ghost', rev_id='rev2') |
|
723 |
graph = tree.branch.repository.get_graph() |
|
724 |
parents = graph.get_parent_map(['ghost', 'rev2']) |
|
725 |
self.assertTrue('ghost' not in parents) |
|
3146.1.2
by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists |
726 |
self.assertEqual(parents['rev2'], ('rev1', 'ghost')) |
727 |
||
4913.4.4
by Jelmer Vernooij
Add test for Repository.get_known_graph_ancestry(). |
728 |
def test_get_known_graph_ancestry(self): |
729 |
tree = self.make_branch_and_tree('here') |
|
730 |
tree.lock_write() |
|
731 |
self.addCleanup(tree.unlock) |
|
732 |
# A
|
|
733 |
# |\
|
|
734 |
# | B
|
|
735 |
# |/
|
|
736 |
# C
|
|
737 |
tree.commit('initial commit', rev_id='A') |
|
738 |
tree_other = tree.bzrdir.sprout('there').open_workingtree() |
|
739 |
tree_other.commit('another', rev_id='B') |
|
740 |
tree.merge_from_branch(tree_other.branch) |
|
741 |
tree.commit('another', rev_id='C') |
|
742 |
kg = tree.branch.repository.get_known_graph_ancestry( |
|
743 |
['C']) |
|
744 |
self.assertEqual(['C'], list(kg.heads(['A', 'B', 'C']))) |
|
745 |
self.assertEqual(['A', 'B', 'C'], list(kg.topo_sort())) |
|
746 |
||
3146.1.2
by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists |
747 |
def test_parent_map_type(self): |
748 |
tree = self.make_branch_and_tree('here') |
|
749 |
tree.lock_write() |
|
750 |
self.addCleanup(tree.unlock) |
|
751 |
tree.commit('initial commit', rev_id='rev1') |
|
752 |
tree.commit('next commit', rev_id='rev2') |
|
753 |
graph = tree.branch.repository.get_graph() |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
754 |
parents = graph.get_parent_map( |
755 |
[_mod_revision.NULL_REVISION, 'rev1', 'rev2']) |
|
3146.1.2
by Aaron Bentley
ParentsProviders now provide tuples of parents, never lists |
756 |
for value in parents.values(): |
757 |
self.assertIsInstance(value, tuple) |
|
3146.1.1
by Aaron Bentley
Fix bad ghost handling in KnitParentsProvider |
758 |
|
2819.2.4
by Andrew Bennetts
Add a 'revision_graph_can_have_wrong_parents' method to repository. |
759 |
def test_implements_revision_graph_can_have_wrong_parents(self): |
760 |
"""All repositories should implement
|
|
761 |
revision_graph_can_have_wrong_parents, so that check and reconcile can
|
|
762 |
work correctly.
|
|
763 |
"""
|
|
764 |
repo = self.make_repository('.') |
|
765 |
# This should work, not raise NotImplementedError:
|
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
766 |
if not repo.revision_graph_can_have_wrong_parents(): |
767 |
return
|
|
768 |
repo.lock_read() |
|
769 |
self.addCleanup(repo.unlock) |
|
770 |
# This repo must also implement
|
|
771 |
# _find_inconsistent_revision_parents and
|
|
772 |
# _check_for_inconsistent_revision_parents. So calling these
|
|
773 |
# should not raise NotImplementedError.
|
|
774 |
list(repo._find_inconsistent_revision_parents()) |
|
775 |
repo._check_for_inconsistent_revision_parents() |
|
2819.2.4
by Andrew Bennetts
Add a 'revision_graph_can_have_wrong_parents' method to repository. |
776 |
|
2996.2.4
by Aaron Bentley
Rename function to add_signature_text |
777 |
def test_add_signature_text(self): |
2996.2.3
by Aaron Bentley
Add tests for install_revisions and add_signature |
778 |
repo = self.make_repository('repo') |
779 |
repo.lock_write() |
|
780 |
self.addCleanup(repo.unlock) |
|
781 |
repo.start_write_group() |
|
4634.35.16
by Andrew Bennetts
Fix more test fallout. |
782 |
self.addCleanup(repo.abort_write_group) |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
783 |
inv = inventory.Inventory(revision_id='A') |
2996.2.3
by Aaron Bentley
Add tests for install_revisions and add_signature |
784 |
inv.root.revision = 'A' |
785 |
repo.add_inventory('A', inv, []) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
786 |
repo.add_revision('A', _mod_revision.Revision( |
787 |
'A', committer='A', timestamp=0, |
|
788 |
inventory_sha1='', timezone=0, message='A')) |
|
2996.2.4
by Aaron Bentley
Rename function to add_signature_text |
789 |
repo.add_signature_text('A', 'This might be a signature') |
2996.2.3
by Aaron Bentley
Add tests for install_revisions and add_signature |
790 |
self.assertEqual('This might be a signature', |
791 |
repo.get_signature_text('A')) |
|
792 |
||
3305.1.1
by Jelmer Vernooij
Make sure that specifying the inv= argument to add_revision() sets the |
793 |
def test_add_revision_inventory_sha1(self): |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
794 |
inv = inventory.Inventory(revision_id='A') |
3305.1.1
by Jelmer Vernooij
Make sure that specifying the inv= argument to add_revision() sets the |
795 |
inv.root.revision = 'A' |
796 |
inv.root.file_id = 'fixed-root' |
|
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
797 |
# Insert the inventory on its own to an identical repository, to get
|
798 |
# its sha1.
|
|
799 |
reference_repo = self.make_repository('reference_repo') |
|
800 |
reference_repo.lock_write() |
|
801 |
reference_repo.start_write_group() |
|
802 |
inv_sha1 = reference_repo.add_inventory('A', inv, []) |
|
803 |
reference_repo.abort_write_group() |
|
804 |
reference_repo.unlock() |
|
805 |
# Now insert a revision with this inventory, and it should get the same
|
|
806 |
# sha1.
|
|
807 |
repo = self.make_repository('repo') |
|
3305.1.1
by Jelmer Vernooij
Make sure that specifying the inv= argument to add_revision() sets the |
808 |
repo.lock_write() |
809 |
repo.start_write_group() |
|
4634.35.16
by Andrew Bennetts
Fix more test fallout. |
810 |
root_id = inv.root.file_id |
811 |
repo.texts.add_lines(('fixed-root', 'A'), [], []) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
812 |
repo.add_revision('A', _mod_revision.Revision( |
813 |
'A', committer='B', timestamp=0, |
|
814 |
timezone=0, message='C'), inv=inv) |
|
3305.1.1
by Jelmer Vernooij
Make sure that specifying the inv= argument to add_revision() sets the |
815 |
repo.commit_write_group() |
816 |
repo.unlock() |
|
817 |
repo.lock_read() |
|
4253.3.1
by Robert Collins
per_repository/test_repository improvements (Robert Collins) |
818 |
self.assertEquals(inv_sha1, repo.get_revision('A').inventory_sha1) |
3305.1.1
by Jelmer Vernooij
Make sure that specifying the inv= argument to add_revision() sets the |
819 |
repo.unlock() |
820 |
||
2996.2.3
by Aaron Bentley
Add tests for install_revisions and add_signature |
821 |
def test_install_revisions(self): |
822 |
wt = self.make_branch_and_tree('source') |
|
823 |
wt.commit('A', allow_pointless=True, rev_id='A') |
|
824 |
repo = wt.branch.repository |
|
825 |
repo.lock_write() |
|
826 |
repo.start_write_group() |
|
3735.2.100
by Vincent Ladeuil
Fix 3 failing tests due to an amazing typo. |
827 |
repo.sign_revision('A', gpg.LoopbackGPGStrategy(None)) |
2996.2.3
by Aaron Bentley
Add tests for install_revisions and add_signature |
828 |
repo.commit_write_group() |
829 |
repo.unlock() |
|
830 |
repo.lock_read() |
|
831 |
self.addCleanup(repo.unlock) |
|
832 |
repo2 = self.make_repository('repo2') |
|
833 |
revision = repo.get_revision('A') |
|
834 |
tree = repo.revision_tree('A') |
|
835 |
signature = repo.get_signature_text('A') |
|
836 |
repo2.lock_write() |
|
837 |
self.addCleanup(repo2.unlock) |
|
838 |
repository.install_revisions(repo2, [(revision, tree, signature)]) |
|
839 |
self.assertEqual(revision, repo2.get_revision('A')) |
|
840 |
self.assertEqual(signature, repo2.get_signature_text('A')) |
|
1852.9.6
by Robert Collins
Merge the change from Tree.compare to Tree.changes_from. |
841 |
|
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
842 |
# XXX: this helper duplicated from tests.test_repository
|
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
843 |
def make_remote_repository(self, path, shared=False): |
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
844 |
"""Make a RemoteRepository object backed by a real repository that will
|
845 |
be created at the given path."""
|
|
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
846 |
repo = self.make_repository(path, shared=shared) |
5017.3.42
by Vincent Ladeuil
-s bt.per_repository.test_repo passing |
847 |
smart_server = test_server.SmartTCPServer_for_testing() |
4659.1.2
by Robert Collins
Refactor creation and shutdown of test servers to use a common helper, |
848 |
self.start_server(smart_server, self.get_server()) |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
849 |
remote_transport = transport.get_transport( |
850 |
smart_server.get_url()).clone(path) |
|
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
851 |
remote_bzrdir = bzrdir.BzrDir.open_from_transport(remote_transport) |
852 |
remote_repo = remote_bzrdir.open_repository() |
|
853 |
return remote_repo |
|
854 |
||
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
855 |
def test_sprout_from_hpss_preserves_format(self): |
856 |
"""repo.sprout from a smart server preserves the repository format."""
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
857 |
if self.repository_format == weaverepo.RepositoryFormat7(): |
858 |
raise tests.TestNotApplicable( |
|
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
859 |
"Cannot fetch weaves over smart protocol.") |
860 |
remote_repo = self.make_remote_repository('remote') |
|
861 |
local_bzrdir = self.make_bzrdir('local') |
|
862 |
try: |
|
863 |
local_repo = remote_repo.sprout(local_bzrdir) |
|
864 |
except errors.TransportNotPossible: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
865 |
raise tests.TestNotApplicable( |
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
866 |
"Cannot lock_read old formats like AllInOne over HPSS.") |
867 |
remote_backing_repo = bzrdir.BzrDir.open( |
|
868 |
self.get_vfs_only_url('remote')).open_repository() |
|
869 |
self.assertEqual(remote_backing_repo._format, local_repo._format) |
|
870 |
||
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
871 |
def test_sprout_branch_from_hpss_preserves_repo_format(self): |
872 |
"""branch.sprout from a smart server preserves the repository format.
|
|
873 |
"""
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
874 |
weave_formats = [weaverepo.RepositoryFormat5(), |
875 |
weaverepo.RepositoryFormat6(), |
|
876 |
weaverepo.RepositoryFormat7()] |
|
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
877 |
if self.repository_format in weave_formats: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
878 |
raise tests.TestNotApplicable( |
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
879 |
"Cannot fetch weaves over smart protocol.") |
880 |
remote_repo = self.make_remote_repository('remote') |
|
881 |
remote_branch = remote_repo.bzrdir.create_branch() |
|
882 |
try: |
|
883 |
local_bzrdir = remote_branch.bzrdir.sprout('local') |
|
884 |
except errors.TransportNotPossible: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
885 |
raise tests.TestNotApplicable( |
3047.1.2
by Andrew Bennetts
Directly test that sprouting branches from a HPSS preserves the repository format. |
886 |
"Cannot lock_read old formats like AllInOne over HPSS.") |
887 |
local_repo = local_bzrdir.open_repository() |
|
888 |
remote_backing_repo = bzrdir.BzrDir.open( |
|
889 |
self.get_vfs_only_url('remote')).open_repository() |
|
890 |
self.assertEqual(remote_backing_repo._format, local_repo._format) |
|
891 |
||
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
892 |
def test_sprout_branch_from_hpss_preserves_shared_repo_format(self): |
893 |
"""branch.sprout from a smart server preserves the repository format of
|
|
894 |
a branch from a shared repository.
|
|
895 |
"""
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
896 |
weave_formats = [weaverepo.RepositoryFormat5(), |
897 |
weaverepo.RepositoryFormat6(), |
|
898 |
weaverepo.RepositoryFormat7()] |
|
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
899 |
if self.repository_format in weave_formats: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
900 |
raise tests.TestNotApplicable( |
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
901 |
"Cannot fetch weaves over smart protocol.") |
902 |
# Make a shared repo
|
|
903 |
remote_repo = self.make_remote_repository('remote', shared=True) |
|
904 |
remote_backing_repo = bzrdir.BzrDir.open( |
|
905 |
self.get_vfs_only_url('remote')).open_repository() |
|
906 |
# Make a branch in that repo in an old format that isn't the default
|
|
907 |
# branch format for the repo.
|
|
908 |
from bzrlib.branch import BzrBranchFormat5 |
|
909 |
format = remote_backing_repo.bzrdir.cloning_metadir() |
|
910 |
format._branch_format = BzrBranchFormat5() |
|
911 |
remote_transport = remote_repo.bzrdir.root_transport.clone('branch') |
|
912 |
remote_backing_repo.bzrdir.create_branch_convenience( |
|
913 |
remote_transport.base, force_new_repo=False, format=format) |
|
914 |
remote_branch = bzrdir.BzrDir.open_from_transport( |
|
915 |
remote_transport).open_branch() |
|
916 |
try: |
|
917 |
local_bzrdir = remote_branch.bzrdir.sprout('local') |
|
918 |
except errors.TransportNotPossible: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
919 |
raise tests.TestNotApplicable( |
3697.6.2
by Andrew Bennetts
Add test for preserving shared repository format when sprouting from a smart server. |
920 |
"Cannot lock_read old formats like AllInOne over HPSS.") |
921 |
local_repo = local_bzrdir.open_repository() |
|
922 |
self.assertEqual(remote_backing_repo._format, local_repo._format) |
|
923 |
||
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
924 |
def test_clone_to_hpss(self): |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
925 |
pre_metadir_formats = [weaverepo.RepositoryFormat5(), |
926 |
weaverepo.RepositoryFormat6()] |
|
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
927 |
if self.repository_format in pre_metadir_formats: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
928 |
raise tests.TestNotApplicable( |
4118.1.1
by Andrew Bennetts
Fix performance regression (many small round-trips) when pushing to a remote pack, and tidy the tests. |
929 |
"Cannot lock pre_metadir_formats remotely.") |
930 |
remote_transport = self.make_smart_server('remote') |
|
931 |
local_branch = self.make_branch('local') |
|
932 |
remote_branch = local_branch.create_clone_on_transport(remote_transport) |
|
933 |
self.assertEqual( |
|
934 |
local_branch.repository._format.supports_external_lookups, |
|
935 |
remote_branch.repository._format.supports_external_lookups) |
|
936 |
||
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
937 |
def test_clone_stacking_policy_upgrades(self): |
938 |
"""Cloning an unstackable branch format to somewhere with a default
|
|
939 |
stack-on branch upgrades branch and repo to match the target and honour
|
|
940 |
the policy.
|
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
941 |
"""
|
942 |
try: |
|
943 |
repo = self.make_repository('repo', shared=True) |
|
944 |
except errors.IncompatibleFormat: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
945 |
raise tests.TestNotApplicable('Cannot make a shared repository') |
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
946 |
if isinstance(repo.bzrdir, bzrdir.BzrDirPreSplitOut): |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
947 |
raise tests.KnownFailure( |
948 |
"pre metadir branches do not upgrade on push "
|
|
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
949 |
"with stacking policy") |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
950 |
if isinstance(repo._format, |
951 |
pack_repo.RepositoryFormatKnitPack5RichRootBroken): |
|
952 |
raise tests.TestNotApplicable("unsupported format") |
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
953 |
# Make a source branch in 'repo' in an unstackable branch format
|
954 |
bzrdir_format = self.repository_format._matchingbzrdir |
|
955 |
transport = self.get_transport('repo/branch') |
|
956 |
transport.mkdir('.') |
|
957 |
target_bzrdir = bzrdir_format.initialize_on_transport(transport) |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
958 |
branch = _mod_branch.BzrBranchFormat6().initialize(target_bzrdir) |
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
959 |
# Ensure that stack_on will be stackable and match the serializer of
|
960 |
# repo.
|
|
961 |
if isinstance(repo, remote.RemoteRepository): |
|
962 |
repo._ensure_real() |
|
963 |
info_repo = repo._real_repository |
|
4599.4.40
by Robert Collins
Fix formats for per_repository upgrade-to-stacking test. |
964 |
else: |
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
965 |
info_repo = repo |
966 |
format_description = info.describe_format(info_repo.bzrdir, |
|
967 |
info_repo, None, None) |
|
968 |
formats = format_description.split(' or ') |
|
969 |
stack_on_format = formats[0] |
|
970 |
if stack_on_format in ["pack-0.92", "dirstate", "metaweave"]: |
|
971 |
stack_on_format = "1.9" |
|
972 |
elif stack_on_format in ["dirstate-with-subtree", "rich-root", |
|
973 |
"rich-root-pack", "pack-0.92-subtree"]: |
|
974 |
stack_on_format = "1.9-rich-root" |
|
975 |
# formats not tested for above are already stackable, so we can use the
|
|
976 |
# format as-is.
|
|
977 |
stack_on = self.make_branch('stack-on-me', format=stack_on_format) |
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
978 |
self.make_bzrdir('.').get_config().set_default_stack_on('stack-on-me') |
979 |
target = branch.bzrdir.clone(self.get_url('target')) |
|
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
980 |
# The target branch supports stacking.
|
981 |
self.assertTrue(target.open_branch()._format.supports_stacking()) |
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
982 |
if isinstance(repo, remote.RemoteRepository): |
983 |
repo._ensure_real() |
|
984 |
repo = repo._real_repository |
|
4005.2.1
by Robert Collins
Fix RemoteBranch to be used correctly in tests using bzr+ssh, to fire off Branch hooks correctly, and improve the branch_implementations tests to check that making a branch gets the right format under test. |
985 |
target_repo = target.open_repository() |
986 |
if isinstance(target_repo, remote.RemoteRepository): |
|
987 |
target_repo._ensure_real() |
|
988 |
target_repo = target_repo._real_repository |
|
4599.4.45
by Robert Collins
Fix a final failure in stacking upgrade of branch/repository tests. |
989 |
# The repository format is unchanged if it could already stack, or the
|
990 |
# same as the stack on.
|
|
991 |
if repo._format.supports_external_lookups: |
|
992 |
self.assertEqual(repo._format, target_repo._format) |
|
993 |
else: |
|
994 |
self.assertEqual(stack_on.repository._format, target_repo._format) |
|
3904.3.8
by Andrew Bennetts
Add test requested by John, and fix whitespace nit. |
995 |
|
4022.1.1
by Robert Collins
Refactoring of fetch to have a sender and sink component enabling splitting the logic over a network stream. (Robert Collins, Andrew Bennetts) |
996 |
def test__get_sink(self): |
997 |
repo = self.make_repository('repo') |
|
998 |
sink = repo._get_sink() |
|
999 |
self.assertIsInstance(sink, repository.StreamSink) |
|
4032.1.2
by John Arbash Meinel
Track down a few more files that have trailing whitespace. |
1000 |
|
3089.2.1
by Andrew Bennetts
Implement RemoteRepository._make_parents_provider. |
1001 |
def test__make_parents_provider(self): |
1002 |
"""Repositories must have a _make_parents_provider method that returns
|
|
3099.3.5
by John Arbash Meinel
Update the last couple of places that referred to Provider.get_parents() directly. |
1003 |
an object with a get_parent_map method.
|
3089.2.1
by Andrew Bennetts
Implement RemoteRepository._make_parents_provider. |
1004 |
"""
|
1005 |
repo = self.make_repository('repo') |
|
3099.3.5
by John Arbash Meinel
Update the last couple of places that referred to Provider.get_parents() directly. |
1006 |
repo._make_parents_provider().get_parent_map |
3089.2.1
by Andrew Bennetts
Implement RemoteRepository._make_parents_provider. |
1007 |
|
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
1008 |
def make_repository_and_foo_bar(self, shared): |
1009 |
made_control = self.make_bzrdir('repository') |
|
1010 |
repo = made_control.create_repository(shared=shared) |
|
1011 |
bzrdir.BzrDir.create_branch_convenience(self.get_url('repository/foo'), |
|
1012 |
force_new_repo=False) |
|
1013 |
bzrdir.BzrDir.create_branch_convenience(self.get_url('repository/bar'), |
|
1014 |
force_new_repo=True) |
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
1015 |
baz = self.make_bzrdir('repository/baz') |
1016 |
qux = self.make_branch('repository/baz/qux') |
|
3140.1.6
by Aaron Bentley
Add test that nested branches are returned |
1017 |
quxx = self.make_branch('repository/baz/qux/quxx') |
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
1018 |
return repo |
1019 |
||
1020 |
def test_find_branches(self): |
|
1021 |
repo = self.make_repository_and_foo_bar(shared=False) |
|
1022 |
branches = repo.find_branches() |
|
1023 |
self.assertContainsRe(branches[-1].base, 'repository/foo/$') |
|
3140.1.6
by Aaron Bentley
Add test that nested branches are returned |
1024 |
self.assertContainsRe(branches[-3].base, 'repository/baz/qux/$') |
1025 |
self.assertContainsRe(branches[-2].base, 'repository/baz/qux/quxx/$') |
|
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
1026 |
# in some formats, creating a repo creates a branch
|
3140.1.6
by Aaron Bentley
Add test that nested branches are returned |
1027 |
if len(branches) == 6: |
1028 |
self.assertContainsRe(branches[-4].base, 'repository/baz/$') |
|
1029 |
self.assertContainsRe(branches[-5].base, 'repository/bar/$') |
|
1030 |
self.assertContainsRe(branches[-6].base, 'repository/$') |
|
1031 |
else: |
|
1032 |
self.assertEqual(4, len(branches)) |
|
3140.1.3
by Aaron Bentley
Add support for finding branches to BzrDir |
1033 |
self.assertContainsRe(branches[-4].base, 'repository/bar/$') |
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
1034 |
|
1035 |
def test_find_branches_using(self): |
|
1036 |
try: |
|
1037 |
repo = self.make_repository_and_foo_bar(shared=True) |
|
1038 |
except errors.IncompatibleFormat: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1039 |
raise tests.TestNotApplicable |
3140.1.2
by Aaron Bentley
Add ability to find branches inside repositories |
1040 |
branches = repo.find_branches(using=True) |
1041 |
self.assertContainsRe(branches[-1].base, 'repository/foo/$') |
|
1042 |
# in some formats, creating a repo creates a branch
|
|
1043 |
if len(branches) == 2: |
|
1044 |
self.assertContainsRe(branches[-2].base, 'repository/$') |
|
1045 |
else: |
|
1046 |
self.assertEqual(1, len(branches)) |
|
1047 |
||
3140.1.9
by Aaron Bentley
Optimize find_branches for standalone repositories |
1048 |
def test_find_branches_using_standalone(self): |
1049 |
branch = self.make_branch('branch') |
|
1050 |
contained = self.make_branch('branch/contained') |
|
1051 |
branches = branch.repository.find_branches(using=True) |
|
1052 |
self.assertEqual([branch.base], [b.base for b in branches]) |
|
1053 |
branches = branch.repository.find_branches(using=False) |
|
1054 |
self.assertEqual([branch.base, contained.base], |
|
1055 |
[b.base for b in branches]) |
|
1056 |
||
1057 |
def test_find_branches_using_empty_standalone_repo(self): |
|
1058 |
repo = self.make_repository('repo') |
|
1059 |
self.assertFalse(repo.is_shared()) |
|
1060 |
try: |
|
1061 |
repo.bzrdir.open_branch() |
|
1062 |
except errors.NotBranchError: |
|
1063 |
self.assertEqual([], repo.find_branches(using=True)) |
|
1064 |
else: |
|
1065 |
self.assertEqual([repo.bzrdir.root_transport.base], |
|
1066 |
[b.base for b in repo.find_branches(using=True)]) |
|
1067 |
||
3349.1.1
by Aaron Bentley
Enable setting and getting make_working_trees for all repositories |
1068 |
def test_set_get_make_working_trees_true(self): |
1069 |
repo = self.make_repository('repo') |
|
3349.1.2
by Aaron Bentley
Change ValueError to RepositoryUpgradeRequired |
1070 |
try: |
1071 |
repo.set_make_working_trees(True) |
|
1072 |
except errors.RepositoryUpgradeRequired, e: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1073 |
raise tests.TestNotApplicable('Format does not support this flag.') |
3349.1.1
by Aaron Bentley
Enable setting and getting make_working_trees for all repositories |
1074 |
self.assertTrue(repo.make_working_trees()) |
1075 |
||
1076 |
def test_set_get_make_working_trees_false(self): |
|
1077 |
repo = self.make_repository('repo') |
|
1078 |
try: |
|
1079 |
repo.set_make_working_trees(False) |
|
3349.1.2
by Aaron Bentley
Change ValueError to RepositoryUpgradeRequired |
1080 |
except errors.RepositoryUpgradeRequired, e: |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1081 |
raise tests.TestNotApplicable('Format does not support this flag.') |
3349.1.2
by Aaron Bentley
Change ValueError to RepositoryUpgradeRequired |
1082 |
self.assertFalse(repo.make_working_trees()) |
3349.1.1
by Aaron Bentley
Enable setting and getting make_working_trees for all repositories |
1083 |
|
3047.1.1
by Andrew Bennetts
Fix for bug 164626, add test that Repository.sprout preserves format. |
1084 |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1085 |
class TestRepositoryLocking(per_repository.TestCaseWithRepository): |
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
1086 |
|
1087 |
def test_leave_lock_in_place(self): |
|
1088 |
repo = self.make_repository('r') |
|
1089 |
# Lock the repository, then use leave_lock_in_place so that when we
|
|
1090 |
# unlock the repository the lock is still held on disk.
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1091 |
token = repo.lock_write().repository_token |
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
1092 |
try: |
2018.5.76
by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None. |
1093 |
if token is None: |
1094 |
# This test does not apply, because this repository refuses lock
|
|
1095 |
# tokens.
|
|
1096 |
self.assertRaises(NotImplementedError, repo.leave_lock_in_place) |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
1097 |
return
|
2018.5.76
by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None. |
1098 |
repo.leave_lock_in_place() |
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
1099 |
finally: |
1100 |
repo.unlock() |
|
1101 |
# We should be unable to relock the repo.
|
|
1102 |
self.assertRaises(errors.LockContention, repo.lock_write) |
|
4327.1.8
by Vincent Ladeuil
Fix 4 more lock-related test failures. |
1103 |
# Cleanup
|
1104 |
repo.lock_write(token) |
|
1105 |
repo.dont_leave_lock_in_place() |
|
1106 |
repo.unlock() |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
1107 |
|
1108 |
def test_dont_leave_lock_in_place(self): |
|
1109 |
repo = self.make_repository('r') |
|
1110 |
# Create a lock on disk.
|
|
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1111 |
token = repo.lock_write().repository_token |
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
1112 |
try: |
1113 |
if token is None: |
|
1114 |
# This test does not apply, because this repository refuses lock
|
|
1115 |
# tokens.
|
|
2018.5.76
by Andrew Bennetts
Testing that repository.{dont_,}leave_lock_in_place raises NotImplementedError if lock_write returns None. |
1116 |
self.assertRaises(NotImplementedError, |
1117 |
repo.dont_leave_lock_in_place) |
|
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
1118 |
return
|
1119 |
try: |
|
1120 |
repo.leave_lock_in_place() |
|
1121 |
except NotImplementedError: |
|
1122 |
# This repository doesn't support this API.
|
|
1123 |
return
|
|
1124 |
finally: |
|
1125 |
repo.unlock() |
|
1126 |
# Reacquire the lock (with a different repository object) by using the
|
|
1127 |
# token.
|
|
1128 |
new_repo = repo.bzrdir.open_repository() |
|
1129 |
new_repo.lock_write(token=token) |
|
1130 |
# Call dont_leave_lock_in_place, so that the lock will be released by
|
|
1131 |
# this instance, even though the lock wasn't originally acquired by it.
|
|
1132 |
new_repo.dont_leave_lock_in_place() |
|
1133 |
new_repo.unlock() |
|
1134 |
# Now the repository is unlocked. Test this by locking it (without a
|
|
1135 |
# token).
|
|
1136 |
repo.lock_write() |
|
1137 |
repo.unlock() |
|
1138 |
||
2018.5.78
by Andrew Bennetts
Implement RemoteRepository.lock_write/unlock to expect and send tokens over the |
1139 |
def test_lock_read_then_unlock(self): |
1140 |
# Calling lock_read then unlocking should work without errors.
|
|
1141 |
repo = self.make_repository('r') |
|
1142 |
repo.lock_read() |
|
1143 |
repo.unlock() |
|
1144 |
||
5200.3.3
by Robert Collins
Lock methods on ``Tree``, ``Branch`` and ``Repository`` are now |
1145 |
def test_lock_read_returns_unlockable(self): |
1146 |
repo = self.make_repository('r') |
|
1147 |
self.assertThat(repo.lock_read, ReturnsUnlockable(repo)) |
|
1148 |
||
1149 |
def test_lock_write_returns_unlockable(self): |
|
1150 |
repo = self.make_repository('r') |
|
1151 |
self.assertThat(repo.lock_write, ReturnsUnlockable(repo)) |
|
1152 |
||
2018.5.75
by Andrew Bennetts
Add Repository.{dont_,}leave_lock_in_place. |
1153 |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1154 |
class TestCaseWithComplexRepository(per_repository.TestCaseWithRepository): |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1155 |
|
1156 |
def setUp(self): |
|
1157 |
super(TestCaseWithComplexRepository, self).setUp() |
|
1158 |
tree_a = self.make_branch_and_tree('a') |
|
1159 |
self.bzrdir = tree_a.branch.bzrdir |
|
1160 |
# add a corrupt inventory 'orphan'
|
|
1534.1.34
by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method. |
1161 |
# this may need some generalising for knits.
|
2592.3.74
by Robert Collins
Test setup fix to use get_inventory_weave rather than control_store.get_weave. |
1162 |
tree_a.lock_write() |
1163 |
try: |
|
1164 |
tree_a.branch.repository.start_write_group() |
|
1165 |
try: |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
1166 |
inv_file = tree_a.branch.repository.inventories |
1167 |
inv_file.add_lines(('orphan',), [], []) |
|
2592.3.74
by Robert Collins
Test setup fix to use get_inventory_weave rather than control_store.get_weave. |
1168 |
except: |
1169 |
tree_a.branch.repository.commit_write_group() |
|
1170 |
raise
|
|
1171 |
else: |
|
1172 |
tree_a.branch.repository.abort_write_group() |
|
1173 |
finally: |
|
1174 |
tree_a.unlock() |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1175 |
# add a real revision 'rev1'
|
1176 |
tree_a.commit('rev1', rev_id='rev1', allow_pointless=True) |
|
1177 |
# add a real revision 'rev2' based on rev1
|
|
1178 |
tree_a.commit('rev2', rev_id='rev2', allow_pointless=True) |
|
1594.2.3
by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits. |
1179 |
# add a reference to a ghost
|
1908.6.7
by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly. |
1180 |
tree_a.add_parent_tree_id('ghost1') |
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. |
1181 |
try: |
1182 |
tree_a.commit('rev3', rev_id='rev3', allow_pointless=True) |
|
1183 |
except errors.RevisionNotPresent: |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1184 |
raise tests.TestNotApplicable( |
1185 |
"Cannot test with ghosts for this format.") |
|
1594.2.3
by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits. |
1186 |
# add another reference to a ghost, and a second ghost.
|
1908.6.7
by Robert Collins
Remove all users of set_pending_merges and add_pending_merge except tests that they work correctly. |
1187 |
tree_a.add_parent_tree_id('ghost1') |
1188 |
tree_a.add_parent_tree_id('ghost2') |
|
1594.2.3
by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits. |
1189 |
tree_a.commit('rev4', rev_id='rev4', allow_pointless=True) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1190 |
|
1756.3.20
by Aaron Bentley
Tests for get_revision_deltas and revisions_trees |
1191 |
def test_revision_trees(self): |
1192 |
revision_ids = ['rev1', 'rev2', 'rev3', 'rev4'] |
|
1193 |
repository = self.bzrdir.open_repository() |
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
1194 |
repository.lock_read() |
1195 |
self.addCleanup(repository.unlock) |
|
1756.3.20
by Aaron Bentley
Tests for get_revision_deltas and revisions_trees |
1196 |
trees1 = list(repository.revision_trees(revision_ids)) |
1197 |
trees2 = [repository.revision_tree(t) for t in revision_ids] |
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
1198 |
self.assertEqual(len(trees1), len(trees2)) |
1756.3.20
by Aaron Bentley
Tests for get_revision_deltas and revisions_trees |
1199 |
for tree1, tree2 in zip(trees1, trees2): |
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
1200 |
self.assertFalse(tree2.changes_from(tree1).has_changed()) |
1756.3.20
by Aaron Bentley
Tests for get_revision_deltas and revisions_trees |
1201 |
|
1756.3.22
by Aaron Bentley
Tweaks from review |
1202 |
def test_get_deltas_for_revisions(self): |
1756.3.20
by Aaron Bentley
Tests for get_revision_deltas and revisions_trees |
1203 |
repository = self.bzrdir.open_repository() |
2592.3.214
by Robert Collins
Merge bzr.dev. |
1204 |
repository.lock_read() |
1205 |
self.addCleanup(repository.unlock) |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1206 |
revisions = [repository.get_revision(r) for r in |
1756.3.20
by Aaron Bentley
Tests for get_revision_deltas and revisions_trees |
1207 |
['rev1', 'rev2', 'rev3', 'rev4']] |
1756.3.22
by Aaron Bentley
Tweaks from review |
1208 |
deltas1 = list(repository.get_deltas_for_revisions(revisions)) |
1756.3.20
by Aaron Bentley
Tests for get_revision_deltas and revisions_trees |
1209 |
deltas2 = [repository.get_revision_delta(r.revision_id) for r in |
1210 |
revisions] |
|
3376.2.4
by Martin Pool
Remove every assert statement from bzrlib! |
1211 |
self.assertEqual(deltas1, deltas2) |
1756.3.20
by Aaron Bentley
Tests for get_revision_deltas and revisions_trees |
1212 |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1213 |
def test_all_revision_ids(self): |
1214 |
# all_revision_ids -> all revisions
|
|
3221.12.1
by Robert Collins
Backport development1 format (stackable packs) to before-shallow-branches. |
1215 |
self.assertEqual(set(['rev1', 'rev2', 'rev3', 'rev4']), |
1216 |
set(self.bzrdir.open_repository().all_revision_ids())) |
|
1534.4.50
by Robert Collins
Got the bzrdir api straightened out, plenty of refactoring to use it pending, but the api is up and running. |
1217 |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1218 |
def test_get_ancestry_missing_revision(self): |
1534.1.34
by Robert Collins
Move missing_revision_ids from Repository to InterRepository, and eliminate the now unused Repository._compatible_formats method. |
1219 |
# get_ancestry(revision that is in some data but not fully installed
|
1220 |
# -> NoSuchRevision
|
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
1221 |
self.assertRaises(errors.NoSuchRevision, |
1222 |
self.bzrdir.open_repository().get_ancestry, 'orphan') |
|
1570.1.13
by Robert Collins
Check for incorrect revision parentage in the weave during revision access. |
1223 |
|
3606.7.8
by John Arbash Meinel
Switch names to 'unordered' that I missed before. |
1224 |
def test_get_unordered_ancestry(self): |
2530.1.1
by Aaron Bentley
Make topological sorting optional for get_ancestry |
1225 |
repo = self.bzrdir.open_repository() |
1226 |
self.assertEqual(set(repo.get_ancestry('rev3')), |
|
1227 |
set(repo.get_ancestry('rev3', topo_sorted=False))) |
|
1228 |
||
2229.2.1
by Aaron Bentley
Reject reserved ids in versiondfile, tree, branch and repository |
1229 |
def test_reserved_id(self): |
1230 |
repo = self.make_repository('repository') |
|
2592.3.61
by Robert Collins
Remove inventory.kndx. |
1231 |
repo.lock_write() |
1232 |
repo.start_write_group() |
|
1233 |
try: |
|
1234 |
self.assertRaises(errors.ReservedId, repo.add_inventory, 'reserved:', |
|
1235 |
None, None) |
|
3879.2.12
by John Arbash Meinel
Missed an add_inventory_delta => add_inventory_by_delta. |
1236 |
self.assertRaises(errors.ReservedId, repo.add_inventory_by_delta, |
3775.2.1
by Robert Collins
Create bzrlib.repository.Repository.add_inventory_delta for adding inventories via deltas. |
1237 |
"foo", [], 'reserved:', None) |
2592.3.61
by Robert Collins
Remove inventory.kndx. |
1238 |
self.assertRaises(errors.ReservedId, repo.add_revision, 'reserved:', |
1239 |
None) |
|
1240 |
finally: |
|
1241 |
repo.abort_write_group() |
|
1242 |
repo.unlock() |
|
2229.2.3
by Aaron Bentley
change reserved_id to is_reserved_id, add check_not_reserved for DRY |
1243 |
|
1570.1.13
by Robert Collins
Check for incorrect revision parentage in the weave during revision access. |
1244 |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1245 |
class TestCaseWithCorruptRepository(per_repository.TestCaseWithRepository): |
1570.1.13
by Robert Collins
Check for incorrect revision parentage in the weave during revision access. |
1246 |
|
1247 |
def setUp(self): |
|
1248 |
super(TestCaseWithCorruptRepository, self).setUp() |
|
1249 |
# a inventory with no parents and the revision has parents..
|
|
1250 |
# i.e. a ghost.
|
|
1251 |
repo = self.make_repository('inventory_with_unnecessary_ghost') |
|
2592.3.38
by Robert Collins
All experimental format tests passing again. |
1252 |
repo.lock_write() |
1253 |
repo.start_write_group() |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1254 |
inv = inventory.Inventory(revision_id = 'ghost') |
1910.2.23
by Aaron Bentley
Fix up test cases that manually construct inventories |
1255 |
inv.root.revision = 'ghost' |
4634.35.16
by Andrew Bennetts
Fix more test fallout. |
1256 |
if repo.supports_rich_root(): |
1257 |
root_id = inv.root.file_id |
|
1258 |
repo.texts.add_lines((root_id, 'ghost'), [], []) |
|
1907.1.1
by Aaron Bentley
Unshelved all changes except those related to removing RootEntry |
1259 |
sha1 = repo.add_inventory('ghost', inv, []) |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1260 |
rev = _mod_revision.Revision( |
1261 |
timestamp=0, timezone=None, committer="Foo Bar <foo@example.com>", |
|
1262 |
message="Message", inventory_sha1=sha1, revision_id='ghost') |
|
1570.1.13
by Robert Collins
Check for incorrect revision parentage in the weave during revision access. |
1263 |
rev.parent_ids = ['the_ghost'] |
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. |
1264 |
try: |
1265 |
repo.add_revision('ghost', rev) |
|
1266 |
except (errors.NoSuchRevision, errors.RevisionNotPresent): |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1267 |
raise tests.TestNotApplicable( |
1268 |
"Cannot test with ghosts for this format.") |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1269 |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1270 |
inv = inventory.Inventory(revision_id = 'the_ghost') |
1910.2.23
by Aaron Bentley
Fix up test cases that manually construct inventories |
1271 |
inv.root.revision = 'the_ghost' |
4634.35.16
by Andrew Bennetts
Fix more test fallout. |
1272 |
if repo.supports_rich_root(): |
1273 |
root_id = inv.root.file_id |
|
1274 |
repo.texts.add_lines((root_id, 'the_ghost'), [], []) |
|
1907.1.1
by Aaron Bentley
Unshelved all changes except those related to removing RootEntry |
1275 |
sha1 = repo.add_inventory('the_ghost', inv, []) |
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1276 |
rev = _mod_revision.Revision( |
1277 |
timestamp=0, timezone=None, committer="Foo Bar <foo@example.com>", |
|
1278 |
message="Message", inventory_sha1=sha1, revision_id='the_ghost') |
|
1570.1.13
by Robert Collins
Check for incorrect revision parentage in the weave during revision access. |
1279 |
rev.parent_ids = [] |
1280 |
repo.add_revision('the_ghost', rev) |
|
1281 |
# check its setup usefully
|
|
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. |
1282 |
inv_weave = repo.inventories |
1283 |
possible_parents = (None, (('ghost',),)) |
|
1284 |
self.assertSubset(inv_weave.get_parent_map([('ghost',)])[('ghost',)], |
|
1285 |
possible_parents) |
|
2592.3.38
by Robert Collins
All experimental format tests passing again. |
1286 |
repo.commit_write_group() |
1287 |
repo.unlock() |
|
1570.1.13
by Robert Collins
Check for incorrect revision parentage in the weave during revision access. |
1288 |
|
1594.2.10
by Robert Collins
Teach knit fetching and branching to only duplicate relevant data avoiding unnecessary reconciles. |
1289 |
def test_corrupt_revision_access_asserts_if_reported_wrong(self): |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1290 |
repo_url = self.get_url('inventory_with_unnecessary_ghost') |
1291 |
repo = repository.Repository.open(repo_url) |
|
1594.2.10
by Robert Collins
Teach knit fetching and branching to only duplicate relevant data avoiding unnecessary reconciles. |
1292 |
reported_wrong = False |
1293 |
try: |
|
1294 |
if repo.get_ancestry('ghost') != [None, 'the_ghost', 'ghost']: |
|
1295 |
reported_wrong = True |
|
1296 |
except errors.CorruptRepository: |
|
1297 |
# caught the bad data:
|
|
1298 |
return
|
|
1299 |
if not reported_wrong: |
|
1300 |
return
|
|
1570.1.13
by Robert Collins
Check for incorrect revision parentage in the weave during revision access. |
1301 |
self.assertRaises(errors.CorruptRepository, repo.get_revision, 'ghost') |
1302 |
||
1594.2.3
by Robert Collins
bugfix revision.MultipleRevisionSources.get_revision_graph to integrate ghosts between sources. [slow on weaves, fast on knits. |
1303 |
def test_corrupt_revision_get_revision_reconcile(self): |
2018.14.1
by Andrew Bennetts
Update to current hpss branch? Fix lots of test failures. |
1304 |
repo_url = self.get_url('inventory_with_unnecessary_ghost') |
1305 |
repo = repository.Repository.open(repo_url) |
|
1570.1.13
by Robert Collins
Check for incorrect revision parentage in the weave during revision access. |
1306 |
repo.get_revision_reconcile('ghost') |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1307 |
|
1308 |
||
2018.5.29
by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point. |
1309 |
# FIXME: document why this is a TestCaseWithTransport rather than a
|
1310 |
# TestCaseWithRepository
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1311 |
class TestEscaping(tests.TestCaseWithTransport): |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1312 |
"""Test that repositories can be stored correctly on VFAT transports.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1313 |
|
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1314 |
Makes sure we have proper escaping of invalid characters, etc.
|
1315 |
||
1316 |
It'd be better to test all operations on the FakeVFATTransportDecorator,
|
|
1317 |
but working trees go straight to the os not through the Transport layer.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1318 |
Therefore we build some history first in the regular way and then
|
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1319 |
check it's safe to access for vfat.
|
1320 |
"""
|
|
1321 |
||
1322 |
def test_on_vfat(self): |
|
2018.5.29
by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point. |
1323 |
# dont bother with remote repository testing, because this test is
|
1324 |
# about local disk layout/support.
|
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1325 |
if isinstance(self.repository_format, remote.RemoteRepositoryFormat): |
2018.5.29
by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point. |
1326 |
return
|
5017.3.42
by Vincent Ladeuil
-s bt.per_repository.test_repo passing |
1327 |
self.transport_server = test_server.FakeVFATServer |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1328 |
FOO_ID = 'foo<:>ID' |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
1329 |
REV_ID = 'revid-1' |
1330 |
# this makes a default format repository always, which is wrong:
|
|
1331 |
# it should be a TestCaseWithRepository in order to get the
|
|
2018.5.29
by Robert Collins
Dont run the vfat repository test on RemoteRepositories as there is no point. |
1332 |
# default format.
|
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1333 |
wt = self.make_branch_and_tree('repo') |
2052.2.1
by Alexander Belchenko
test_on_vfat win32 fix: use binary line-endings |
1334 |
self.build_tree(["repo/foo"], line_endings='binary') |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1335 |
# add file with id containing wierd characters
|
1336 |
wt.add(['foo'], [FOO_ID]) |
|
1337 |
wt.commit('this is my new commit', rev_id=REV_ID) |
|
1338 |
# now access over vfat; should be safe
|
|
4691.2.1
by Robert Collins
Add stronger test isolation by interception BzrDir.open and checking the thing being opened is known to the test suite. |
1339 |
branch = bzrdir.BzrDir.open(self.get_url('repo')).open_branch() |
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1340 |
revtree = branch.repository.revision_tree(REV_ID) |
3015.2.13
by Robert Collins
More lock correctness for the use of get_file_text in repository_implementations. |
1341 |
revtree.lock_read() |
1342 |
self.addCleanup(revtree.unlock) |
|
1986.1.1
by Robert Collins
Move test_branch_on_vfat into a repository implementation test, to ensure that all repository formats are safe on vfat. |
1343 |
contents = revtree.get_file_text(FOO_ID) |
1344 |
self.assertEqual(contents, 'contents of repo/foo\n') |
|
2520.4.54
by Aaron Bentley
Hang a create_bundle method off repository |
1345 |
|
1346 |
def test_create_bundle(self): |
|
1347 |
wt = self.make_branch_and_tree('repo') |
|
1348 |
self.build_tree(['repo/file1']) |
|
1349 |
wt.add('file1') |
|
1350 |
wt.commit('file1', rev_id='rev1') |
|
1351 |
fileobj = StringIO() |
|
5010.2.6
by Vincent Ladeuil
Fix per_repository/test_repository.py imports. |
1352 |
wt.branch.repository.create_bundle( |
1353 |
'rev1', _mod_revision.NULL_REVISION, fileobj) |
|
5158.6.4
by Martin Pool
Repository implements ControlComponent too |
1354 |
|
1355 |
||
1356 |
||
1357 |
||
1358 |
class TestRepositoryControlComponent(per_repository.TestCaseWithRepository): |
|
1359 |
"""Repository implementations adequately implement ControlComponent."""
|
|
1360 |
||
1361 |
def test_urls(self): |
|
1362 |
repo = self.make_repository('repo') |
|
1363 |
self.assertIsInstance(repo.user_url, str) |
|
1364 |
self.assertEqual(repo.user_url, repo.user_transport.base) |
|
1365 |
# for all current bzrdir implementations the user dir must be
|
|
1366 |
# above the control dir but we might need to relax that?
|
|
1367 |
self.assertEqual(repo.control_url.find(repo.user_url), 0) |
|
1368 |
self.assertEqual(repo.control_url, repo.control_transport.base) |