4110.2.26
by Martin Pool
Remove outdated progress bar test |
1 |
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
|
1685.1.63
by Martin Pool
Small Transport fixups |
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.
|
|
1685.1.63
by Martin Pool
Small Transport fixups |
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.
|
|
1685.1.63
by Martin Pool
Small Transport fixups |
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 |
|
17 |
"""Tests for the Repository facility that are not interface tests.
|
|
18 |
||
3689.1.4
by John Arbash Meinel
Doc strings that reference repository_implementations |
19 |
For interface tests see tests/per_repository/*.py.
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
20 |
|
21 |
For concrete class tests see this file, and for storage formats tests
|
|
22 |
also see this file.
|
|
23 |
"""
|
|
24 |
||
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
25 |
from stat import S_ISDIR |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
26 |
from StringIO import StringIO |
27 |
||
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. |
28 |
import bzrlib |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
29 |
from bzrlib.errors import (NotBranchError, |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
30 |
NoSuchFile, |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
31 |
UnknownFormatError, |
32 |
UnsupportedFormatError, |
|
33 |
)
|
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
34 |
from bzrlib import ( |
35 |
graph, |
|
36 |
tests, |
|
37 |
)
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
38 |
from bzrlib.branchbuilder import BranchBuilder |
3735.1.1
by Robert Collins
Add development2 formats using BTree indices. |
39 |
from bzrlib.btree_index import BTreeBuilder, BTreeGraphIndex |
2592.3.192
by Robert Collins
Move new revision index management to NewPack. |
40 |
from bzrlib.index import GraphIndex, InMemoryGraphIndex |
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
41 |
from bzrlib.repository import RepositoryFormat |
2535.3.41
by Andrew Bennetts
Add tests for InterRemoteToOther.is_compatible. |
42 |
from bzrlib.smart import server |
2670.3.5
by Andrew Bennetts
Remove get_stream_as_bytes from KnitVersionedFile's API, make it a function in knitrepo.py instead. |
43 |
from bzrlib.tests import ( |
44 |
TestCase, |
|
45 |
TestCaseWithTransport, |
|
3446.2.1
by Martin Pool
Failure to delete an obsolete pack file should not be fatal. |
46 |
TestSkipped, |
2670.3.5
by Andrew Bennetts
Remove get_stream_as_bytes from KnitVersionedFile's API, make it a function in knitrepo.py instead. |
47 |
test_knit, |
48 |
)
|
|
3446.2.1
by Martin Pool
Failure to delete an obsolete pack file should not be fatal. |
49 |
from bzrlib.transport import ( |
50 |
fakenfs, |
|
51 |
get_transport, |
|
52 |
)
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
53 |
from bzrlib.transport.memory import MemoryServer |
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
54 |
from bzrlib import ( |
2694.5.4
by Jelmer Vernooij
Move bzrlib.util.bencode to bzrlib._bencode_py. |
55 |
bencode, |
2535.3.41
by Andrew Bennetts
Add tests for InterRemoteToOther.is_compatible. |
56 |
bzrdir, |
57 |
errors, |
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
58 |
inventory, |
2929.3.5
by Vincent Ladeuil
New files, same warnings, same fixes. |
59 |
osutils, |
3146.6.1
by Aaron Bentley
InterDifferingSerializer shows a progress bar |
60 |
progress, |
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
61 |
repository, |
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
62 |
revision as _mod_revision, |
2535.3.41
by Andrew Bennetts
Add tests for InterRemoteToOther.is_compatible. |
63 |
symbol_versioning, |
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
64 |
upgrade, |
65 |
workingtree, |
|
66 |
)
|
|
3735.42.5
by John Arbash Meinel
Change the tests so we now just use a direct test that _get_source is |
67 |
from bzrlib.repofmt import ( |
68 |
groupcompress_repo, |
|
69 |
knitrepo, |
|
70 |
pack_repo, |
|
71 |
weaverepo, |
|
72 |
)
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
73 |
|
74 |
||
75 |
class TestDefaultFormat(TestCase): |
|
76 |
||
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
77 |
def test_get_set_default_format(self): |
2204.5.3
by Aaron Bentley
zap old repository default handling |
78 |
old_default = bzrdir.format_registry.get('default') |
79 |
private_default = old_default().repository_format.__class__ |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
80 |
old_format = repository.RepositoryFormat.get_default_format() |
1910.2.33
by Aaron Bentley
Fix default format test |
81 |
self.assertTrue(isinstance(old_format, private_default)) |
2204.5.3
by Aaron Bentley
zap old repository default handling |
82 |
def make_sample_bzrdir(): |
83 |
my_bzrdir = bzrdir.BzrDirMetaFormat1() |
|
84 |
my_bzrdir.repository_format = SampleRepositoryFormat() |
|
85 |
return my_bzrdir |
|
86 |
bzrdir.format_registry.remove('default') |
|
87 |
bzrdir.format_registry.register('sample', make_sample_bzrdir, '') |
|
88 |
bzrdir.format_registry.set_default('sample') |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
89 |
# creating a repository should now create an instrumented dir.
|
90 |
try: |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
91 |
# the default branch format is used by the meta dir format
|
92 |
# which is not the default bzrdir format at this point
|
|
1685.1.63
by Martin Pool
Small Transport fixups |
93 |
dir = bzrdir.BzrDirMetaFormat1().initialize('memory:///') |
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
94 |
result = dir.create_repository() |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
95 |
self.assertEqual(result, 'A bzr repository dir') |
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
96 |
finally: |
2204.5.3
by Aaron Bentley
zap old repository default handling |
97 |
bzrdir.format_registry.remove('default') |
2363.5.14
by Aaron Bentley
Prevent repository.get_set_default_format from corrupting inventory |
98 |
bzrdir.format_registry.remove('sample') |
2204.5.3
by Aaron Bentley
zap old repository default handling |
99 |
bzrdir.format_registry.register('default', old_default, '') |
100 |
self.assertIsInstance(repository.RepositoryFormat.get_default_format(), |
|
101 |
old_format.__class__) |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
102 |
|
103 |
||
104 |
class SampleRepositoryFormat(repository.RepositoryFormat): |
|
105 |
"""A sample format
|
|
106 |
||
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
107 |
this format is initializable, unsupported to aid in testing the
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
108 |
open and open(unsupported=True) routines.
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
109 |
"""
|
110 |
||
111 |
def get_format_string(self): |
|
112 |
"""See RepositoryFormat.get_format_string()."""
|
|
113 |
return "Sample .bzr repository format." |
|
114 |
||
1534.6.1
by Robert Collins
allow API creation of shared repositories |
115 |
def initialize(self, a_bzrdir, shared=False): |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
116 |
"""Initialize a repository in a BzrDir"""
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
117 |
t = a_bzrdir.get_repository_transport(self) |
1955.3.13
by John Arbash Meinel
Run the full test suite, and fix up any deprecation warnings. |
118 |
t.put_bytes('format', self.get_format_string()) |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
119 |
return 'A bzr repository dir' |
120 |
||
121 |
def is_supported(self): |
|
122 |
return False |
|
123 |
||
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
124 |
def open(self, a_bzrdir, _found=False): |
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
125 |
return "opened repository." |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
126 |
|
127 |
||
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
128 |
class TestRepositoryFormat(TestCaseWithTransport): |
129 |
"""Tests for the Repository format detection used by the bzr meta dir facility.BzrBranchFormat facility."""
|
|
130 |
||
131 |
def test_find_format(self): |
|
132 |
# is the right format object found for a repository?
|
|
133 |
# create a branch with a few known format objects.
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
134 |
# this is not quite the same as
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
135 |
self.build_tree(["foo/", "bar/"]) |
136 |
def check_format(format, url): |
|
137 |
dir = format._matchingbzrdir.initialize(url) |
|
138 |
format.initialize(dir) |
|
139 |
t = get_transport(url) |
|
140 |
found_format = repository.RepositoryFormat.find_format(dir) |
|
141 |
self.failUnless(isinstance(found_format, format.__class__)) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
142 |
check_format(weaverepo.RepositoryFormat7(), "bar") |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
143 |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
144 |
def test_find_format_no_repository(self): |
145 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
146 |
self.assertRaises(errors.NoRepositoryPresent, |
|
147 |
repository.RepositoryFormat.find_format, |
|
148 |
dir) |
|
149 |
||
150 |
def test_find_format_unknown_format(self): |
|
151 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
152 |
SampleRepositoryFormat().initialize(dir) |
|
153 |
self.assertRaises(UnknownFormatError, |
|
154 |
repository.RepositoryFormat.find_format, |
|
155 |
dir) |
|
156 |
||
157 |
def test_register_unregister_format(self): |
|
158 |
format = SampleRepositoryFormat() |
|
159 |
# make a control dir
|
|
160 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
161 |
# make a repo
|
|
162 |
format.initialize(dir) |
|
163 |
# register a format for it.
|
|
164 |
repository.RepositoryFormat.register_format(format) |
|
165 |
# which repository.Open will refuse (not supported)
|
|
166 |
self.assertRaises(UnsupportedFormatError, repository.Repository.open, self.get_url()) |
|
167 |
# but open(unsupported) will work
|
|
168 |
self.assertEqual(format.open(dir), "opened repository.") |
|
169 |
# unregister the format
|
|
170 |
repository.RepositoryFormat.unregister_format(format) |
|
171 |
||
172 |
||
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
173 |
class TestFormat6(TestCaseWithTransport): |
174 |
||
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
175 |
def test_attribute__fetch_order(self): |
176 |
"""Weaves need topological data insertion."""
|
|
177 |
control = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
178 |
repo = weaverepo.RepositoryFormat6().initialize(control) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
179 |
self.assertEqual('topological', repo._format._fetch_order) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
180 |
|
181 |
def test_attribute__fetch_uses_deltas(self): |
|
182 |
"""Weaves do not reuse deltas."""
|
|
183 |
control = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
184 |
repo = weaverepo.RepositoryFormat6().initialize(control) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
185 |
self.assertEqual(False, repo._format._fetch_uses_deltas) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
186 |
|
3565.3.4
by Robert Collins
Defer decision to reconcile to the repository being fetched into. |
187 |
def test_attribute__fetch_reconcile(self): |
188 |
"""Weave repositories need a reconcile after fetch."""
|
|
189 |
control = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
190 |
repo = weaverepo.RepositoryFormat6().initialize(control) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
191 |
self.assertEqual(True, repo._format._fetch_reconcile) |
3565.3.4
by Robert Collins
Defer decision to reconcile to the repository being fetched into. |
192 |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
193 |
def test_no_ancestry_weave(self): |
194 |
control = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
195 |
repo = weaverepo.RepositoryFormat6().initialize(control) |
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
196 |
# We no longer need to create the ancestry.weave file
|
197 |
# since it is *never* used.
|
|
198 |
self.assertRaises(NoSuchFile, |
|
199 |
control.transport.get, |
|
200 |
'ancestry.weave') |
|
201 |
||
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
202 |
def test_supports_external_lookups(self): |
203 |
control = bzrdir.BzrDirFormat6().initialize(self.get_url()) |
|
204 |
repo = weaverepo.RepositoryFormat6().initialize(control) |
|
205 |
self.assertFalse(repo._format.supports_external_lookups) |
|
206 |
||
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
207 |
|
208 |
class TestFormat7(TestCaseWithTransport): |
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
209 |
|
210 |
def test_attribute__fetch_order(self): |
|
211 |
"""Weaves need topological data insertion."""
|
|
212 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
213 |
repo = weaverepo.RepositoryFormat7().initialize(control) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
214 |
self.assertEqual('topological', repo._format._fetch_order) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
215 |
|
216 |
def test_attribute__fetch_uses_deltas(self): |
|
217 |
"""Weaves do not reuse deltas."""
|
|
218 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
219 |
repo = weaverepo.RepositoryFormat7().initialize(control) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
220 |
self.assertEqual(False, repo._format._fetch_uses_deltas) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
221 |
|
3565.3.4
by Robert Collins
Defer decision to reconcile to the repository being fetched into. |
222 |
def test_attribute__fetch_reconcile(self): |
223 |
"""Weave repositories need a reconcile after fetch."""
|
|
224 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
225 |
repo = weaverepo.RepositoryFormat7().initialize(control) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
226 |
self.assertEqual(True, repo._format._fetch_reconcile) |
3565.3.4
by Robert Collins
Defer decision to reconcile to the repository being fetched into. |
227 |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
228 |
def test_disk_layout(self): |
229 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
230 |
repo = weaverepo.RepositoryFormat7().initialize(control) |
1534.5.3
by Robert Collins
Make format 4/5/6 branches share a single LockableFiles instance across wt/branch/repository. |
231 |
# in case of side effects of locking.
|
232 |
repo.lock_write() |
|
233 |
repo.unlock() |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
234 |
# we want:
|
235 |
# format 'Bazaar-NG Repository format 7'
|
|
236 |
# lock ''
|
|
237 |
# inventory.weave == empty_weave
|
|
238 |
# empty revision-store directory
|
|
239 |
# empty weaves directory
|
|
240 |
t = control.get_repository_transport(None) |
|
241 |
self.assertEqualDiff('Bazaar-NG Repository format 7', |
|
242 |
t.get('format').read()) |
|
243 |
self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode)) |
|
244 |
self.assertTrue(S_ISDIR(t.stat('weaves').st_mode)) |
|
245 |
self.assertEqualDiff('# bzr weave file v5\n' |
|
246 |
'w\n' |
|
247 |
'W\n', |
|
248 |
t.get('inventory.weave').read()) |
|
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. |
249 |
# Creating a file with id Foo:Bar results in a non-escaped file name on
|
250 |
# disk.
|
|
251 |
control.create_branch() |
|
252 |
tree = control.create_workingtree() |
|
253 |
tree.add(['foo'], ['Foo:Bar'], ['file']) |
|
254 |
tree.put_file_bytes_non_atomic('Foo:Bar', 'content\n') |
|
255 |
tree.commit('first post', rev_id='first') |
|
256 |
self.assertEqualDiff( |
|
257 |
'# bzr weave file v5\n' |
|
258 |
'i\n' |
|
259 |
'1 7fe70820e08a1aac0ef224d9c66ab66831cc4ab1\n' |
|
260 |
'n first\n' |
|
261 |
'\n' |
|
262 |
'w\n' |
|
263 |
'{ 0\n' |
|
264 |
'. content\n' |
|
265 |
'}\n' |
|
266 |
'W\n', |
|
267 |
t.get('weaves/74/Foo%3ABar.weave').read()) |
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
268 |
|
269 |
def test_shared_disk_layout(self): |
|
270 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
271 |
repo = weaverepo.RepositoryFormat7().initialize(control, shared=True) |
1534.6.1
by Robert Collins
allow API creation of shared repositories |
272 |
# we want:
|
273 |
# format 'Bazaar-NG Repository format 7'
|
|
274 |
# inventory.weave == empty_weave
|
|
275 |
# empty revision-store directory
|
|
276 |
# empty weaves directory
|
|
277 |
# a 'shared-storage' marker file.
|
|
1553.5.49
by Martin Pool
Use LockDirs for repo format 7 |
278 |
# lock is not present when unlocked
|
1534.6.1
by Robert Collins
allow API creation of shared repositories |
279 |
t = control.get_repository_transport(None) |
280 |
self.assertEqualDiff('Bazaar-NG Repository format 7', |
|
281 |
t.get('format').read()) |
|
282 |
self.assertEqualDiff('', t.get('shared-storage').read()) |
|
283 |
self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode)) |
|
284 |
self.assertTrue(S_ISDIR(t.stat('weaves').st_mode)) |
|
285 |
self.assertEqualDiff('# bzr weave file v5\n' |
|
286 |
'w\n' |
|
287 |
'W\n', |
|
288 |
t.get('inventory.weave').read()) |
|
1553.5.49
by Martin Pool
Use LockDirs for repo format 7 |
289 |
self.assertFalse(t.has('branch-lock')) |
290 |
||
1553.5.56
by Martin Pool
Format 7 repo now uses LockDir! |
291 |
def test_creates_lockdir(self): |
1553.5.49
by Martin Pool
Use LockDirs for repo format 7 |
292 |
"""Make sure it appears to be controlled by a LockDir existence"""
|
293 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
294 |
repo = weaverepo.RepositoryFormat7().initialize(control, shared=True) |
1553.5.49
by Martin Pool
Use LockDirs for repo format 7 |
295 |
t = control.get_repository_transport(None) |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
296 |
# TODO: Should check there is a 'lock' toplevel directory,
|
1553.5.58
by Martin Pool
Change LockDirs to format "lock-name/held/info" |
297 |
# regardless of contents
|
298 |
self.assertFalse(t.has('lock/held/info')) |
|
1553.5.49
by Martin Pool
Use LockDirs for repo format 7 |
299 |
repo.lock_write() |
1658.1.4
by Martin Pool
Quieten warning from TestFormat7.test_creates_lockdir about failing to unlock |
300 |
try: |
301 |
self.assertTrue(t.has('lock/held/info')) |
|
302 |
finally: |
|
303 |
# unlock so we don't get a warning about failing to do so
|
|
304 |
repo.unlock() |
|
1553.5.56
by Martin Pool
Format 7 repo now uses LockDir! |
305 |
|
306 |
def test_uses_lockdir(self): |
|
307 |
"""repo format 7 actually locks on lockdir"""
|
|
308 |
base_url = self.get_url() |
|
309 |
control = bzrdir.BzrDirMetaFormat1().initialize(base_url) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
310 |
repo = weaverepo.RepositoryFormat7().initialize(control, shared=True) |
1553.5.56
by Martin Pool
Format 7 repo now uses LockDir! |
311 |
t = control.get_repository_transport(None) |
312 |
repo.lock_write() |
|
313 |
repo.unlock() |
|
314 |
del repo |
|
315 |
# make sure the same lock is created by opening it
|
|
316 |
repo = repository.Repository.open(base_url) |
|
317 |
repo.lock_write() |
|
1553.5.58
by Martin Pool
Change LockDirs to format "lock-name/held/info" |
318 |
self.assertTrue(t.has('lock/held/info')) |
1553.5.56
by Martin Pool
Format 7 repo now uses LockDir! |
319 |
repo.unlock() |
1553.5.58
by Martin Pool
Change LockDirs to format "lock-name/held/info" |
320 |
self.assertFalse(t.has('lock/held/info')) |
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
321 |
|
322 |
def test_shared_no_tree_disk_layout(self): |
|
323 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
324 |
repo = weaverepo.RepositoryFormat7().initialize(control, shared=True) |
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
325 |
repo.set_make_working_trees(False) |
326 |
# we want:
|
|
327 |
# format 'Bazaar-NG Repository format 7'
|
|
328 |
# lock ''
|
|
329 |
# inventory.weave == empty_weave
|
|
330 |
# empty revision-store directory
|
|
331 |
# empty weaves directory
|
|
332 |
# a 'shared-storage' marker file.
|
|
333 |
t = control.get_repository_transport(None) |
|
334 |
self.assertEqualDiff('Bazaar-NG Repository format 7', |
|
335 |
t.get('format').read()) |
|
1553.5.56
by Martin Pool
Format 7 repo now uses LockDir! |
336 |
## self.assertEqualDiff('', t.get('lock').read())
|
1534.6.5
by Robert Collins
Cloning of repos preserves shared and make-working-tree attributes. |
337 |
self.assertEqualDiff('', t.get('shared-storage').read()) |
338 |
self.assertEqualDiff('', t.get('no-working-trees').read()) |
|
339 |
repo.set_make_working_trees(True) |
|
340 |
self.assertFalse(t.has('no-working-trees')) |
|
341 |
self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode)) |
|
342 |
self.assertTrue(S_ISDIR(t.stat('weaves').st_mode)) |
|
343 |
self.assertEqualDiff('# bzr weave file v5\n' |
|
344 |
'w\n' |
|
345 |
'W\n', |
|
346 |
t.get('inventory.weave').read()) |
|
1534.1.27
by Robert Collins
Start InterRepository with InterRepository.get. |
347 |
|
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
348 |
def test_supports_external_lookups(self): |
349 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
350 |
repo = weaverepo.RepositoryFormat7().initialize(control) |
|
351 |
self.assertFalse(repo._format.supports_external_lookups) |
|
352 |
||
1534.1.27
by Robert Collins
Start InterRepository with InterRepository.get. |
353 |
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
354 |
class TestFormatKnit1(TestCaseWithTransport): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
355 |
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
356 |
def test_attribute__fetch_order(self): |
357 |
"""Knits need topological data insertion."""
|
|
358 |
repo = self.make_repository('.', |
|
359 |
format=bzrdir.format_registry.get('knit')()) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
360 |
self.assertEqual('topological', repo._format._fetch_order) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
361 |
|
362 |
def test_attribute__fetch_uses_deltas(self): |
|
363 |
"""Knits reuse deltas."""
|
|
364 |
repo = self.make_repository('.', |
|
365 |
format=bzrdir.format_registry.get('knit')()) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
366 |
self.assertEqual(True, repo._format._fetch_uses_deltas) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
367 |
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
368 |
def test_disk_layout(self): |
369 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
370 |
repo = knitrepo.RepositoryFormatKnit1().initialize(control) |
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
371 |
# in case of side effects of locking.
|
372 |
repo.lock_write() |
|
373 |
repo.unlock() |
|
374 |
# we want:
|
|
375 |
# format 'Bazaar-NG Knit Repository Format 1'
|
|
1553.5.62
by Martin Pool
Add tests that MetaDir repositories use LockDirs |
376 |
# lock: is a directory
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
377 |
# inventory.weave == empty_weave
|
378 |
# empty revision-store directory
|
|
379 |
# empty weaves directory
|
|
380 |
t = control.get_repository_transport(None) |
|
381 |
self.assertEqualDiff('Bazaar-NG Knit Repository Format 1', |
|
382 |
t.get('format').read()) |
|
1553.5.57
by Martin Pool
[merge] sync from bzr.dev |
383 |
# XXX: no locks left when unlocked at the moment
|
384 |
# self.assertEqualDiff('', t.get('lock').read())
|
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
385 |
self.assertTrue(S_ISDIR(t.stat('knits').st_mode)) |
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
386 |
self.check_knits(t) |
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. |
387 |
# Check per-file knits.
|
388 |
branch = control.create_branch() |
|
389 |
tree = control.create_workingtree() |
|
390 |
tree.add(['foo'], ['Nasty-IdC:'], ['file']) |
|
391 |
tree.put_file_bytes_non_atomic('Nasty-IdC:', '') |
|
392 |
tree.commit('1st post', rev_id='foo') |
|
393 |
self.assertHasKnit(t, 'knits/e8/%254easty-%2549d%2543%253a', |
|
394 |
'\nfoo fulltext 0 81 :') |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
395 |
|
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. |
396 |
def assertHasKnit(self, t, knit_name, extra_content=''): |
1654.1.3
by Robert Collins
Refactor repository knit tests slightly to remove duplication - add a assertHasKnit method. |
397 |
"""Assert that knit_name exists on t."""
|
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. |
398 |
self.assertEqualDiff('# bzr knit index 8\n' + extra_content, |
1654.1.3
by Robert Collins
Refactor repository knit tests slightly to remove duplication - add a assertHasKnit method. |
399 |
t.get(knit_name + '.kndx').read()) |
400 |
||
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
401 |
def check_knits(self, t): |
402 |
"""check knit content for a repository."""
|
|
1654.1.3
by Robert Collins
Refactor repository knit tests slightly to remove duplication - add a assertHasKnit method. |
403 |
self.assertHasKnit(t, 'inventory') |
404 |
self.assertHasKnit(t, 'revisions') |
|
405 |
self.assertHasKnit(t, 'signatures') |
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
406 |
|
407 |
def test_shared_disk_layout(self): |
|
408 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
409 |
repo = knitrepo.RepositoryFormatKnit1().initialize(control, shared=True) |
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
410 |
# we want:
|
411 |
# format 'Bazaar-NG Knit Repository Format 1'
|
|
1553.5.62
by Martin Pool
Add tests that MetaDir repositories use LockDirs |
412 |
# lock: is a directory
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
413 |
# inventory.weave == empty_weave
|
414 |
# empty revision-store directory
|
|
415 |
# empty weaves directory
|
|
416 |
# a 'shared-storage' marker file.
|
|
417 |
t = control.get_repository_transport(None) |
|
418 |
self.assertEqualDiff('Bazaar-NG Knit Repository Format 1', |
|
419 |
t.get('format').read()) |
|
1553.5.57
by Martin Pool
[merge] sync from bzr.dev |
420 |
# XXX: no locks left when unlocked at the moment
|
421 |
# self.assertEqualDiff('', t.get('lock').read())
|
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
422 |
self.assertEqualDiff('', t.get('shared-storage').read()) |
423 |
self.assertTrue(S_ISDIR(t.stat('knits').st_mode)) |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
424 |
self.check_knits(t) |
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
425 |
|
426 |
def test_shared_no_tree_disk_layout(self): |
|
427 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
428 |
repo = knitrepo.RepositoryFormatKnit1().initialize(control, shared=True) |
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
429 |
repo.set_make_working_trees(False) |
430 |
# we want:
|
|
431 |
# format 'Bazaar-NG Knit Repository Format 1'
|
|
432 |
# lock ''
|
|
433 |
# inventory.weave == empty_weave
|
|
434 |
# empty revision-store directory
|
|
435 |
# empty weaves directory
|
|
436 |
# a 'shared-storage' marker file.
|
|
437 |
t = control.get_repository_transport(None) |
|
438 |
self.assertEqualDiff('Bazaar-NG Knit Repository Format 1', |
|
439 |
t.get('format').read()) |
|
1553.5.57
by Martin Pool
[merge] sync from bzr.dev |
440 |
# XXX: no locks left when unlocked at the moment
|
441 |
# self.assertEqualDiff('', t.get('lock').read())
|
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
442 |
self.assertEqualDiff('', t.get('shared-storage').read()) |
443 |
self.assertEqualDiff('', t.get('no-working-trees').read()) |
|
444 |
repo.set_make_working_trees(True) |
|
445 |
self.assertFalse(t.has('no-working-trees')) |
|
446 |
self.assertTrue(S_ISDIR(t.stat('knits').st_mode)) |
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
447 |
self.check_knits(t) |
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
448 |
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
449 |
def test_deserialise_sets_root_revision(self): |
450 |
"""We must have a inventory.root.revision
|
|
451 |
||
452 |
Old versions of the XML5 serializer did not set the revision_id for
|
|
453 |
the whole inventory. So we grab the one from the expected text. Which
|
|
454 |
is valid when the api is not being abused.
|
|
455 |
"""
|
|
456 |
repo = self.make_repository('.', |
|
457 |
format=bzrdir.format_registry.get('knit')()) |
|
458 |
inv_xml = '<inventory format="5">\n</inventory>\n' |
|
459 |
inv = repo.deserialise_inventory('test-rev-id', inv_xml) |
|
460 |
self.assertEqual('test-rev-id', inv.root.revision) |
|
461 |
||
462 |
def test_deserialise_uses_global_revision_id(self): |
|
463 |
"""If it is set, then we re-use the global revision id"""
|
|
464 |
repo = self.make_repository('.', |
|
465 |
format=bzrdir.format_registry.get('knit')()) |
|
466 |
inv_xml = ('<inventory format="5" revision_id="other-rev-id">\n' |
|
467 |
'</inventory>\n') |
|
468 |
# Arguably, the deserialise_inventory should detect a mismatch, and
|
|
469 |
# raise an error, rather than silently using one revision_id over the
|
|
470 |
# other.
|
|
3169.2.2
by Robert Collins
Add a test to Repository.deserialise_inventory that the resulting ivnentory is the one asked for, and update relevant tests. Also tweak the model 1 to 2 regenerate inventories logic to use the revision trees parent marker which is more accurate in some cases. |
471 |
self.assertRaises(AssertionError, repo.deserialise_inventory, |
472 |
'test-rev-id', inv_xml) |
|
473 |
inv = repo.deserialise_inventory('other-rev-id', inv_xml) |
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
474 |
self.assertEqual('other-rev-id', inv.root.revision) |
475 |
||
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
476 |
def test_supports_external_lookups(self): |
477 |
repo = self.make_repository('.', |
|
478 |
format=bzrdir.format_registry.get('knit')()) |
|
479 |
self.assertFalse(repo._format.supports_external_lookups) |
|
480 |
||
2535.3.53
by Andrew Bennetts
Remove get_stream_as_bytes from KnitVersionedFile's API, make it a function in knitrepo.py instead. |
481 |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
482 |
class DummyRepository(object): |
483 |
"""A dummy repository for testing."""
|
|
484 |
||
3452.2.11
by Andrew Bennetts
Merge thread. |
485 |
_format = None |
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
486 |
_serializer = None |
487 |
||
488 |
def supports_rich_root(self): |
|
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
489 |
if self._format is not None: |
490 |
return self._format.rich_root_data |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
491 |
return False |
492 |
||
3709.5.10
by Andrew Bennetts
Fix test failure caused by missing attributes on DummyRepository. |
493 |
def get_graph(self): |
494 |
raise NotImplementedError |
|
495 |
||
496 |
def get_parent_map(self, revision_ids): |
|
497 |
raise NotImplementedError |
|
498 |
||
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
499 |
|
500 |
class InterDummy(repository.InterRepository): |
|
501 |
"""An inter-repository optimised code path for DummyRepository.
|
|
502 |
||
503 |
This is for use during testing where we use DummyRepository as repositories
|
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
504 |
so that none of the default regsitered inter-repository classes will
|
2818.4.2
by Robert Collins
Review feedback. |
505 |
MATCH.
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
506 |
"""
|
507 |
||
508 |
@staticmethod
|
|
509 |
def is_compatible(repo_source, repo_target): |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
510 |
"""InterDummy is compatible with DummyRepository."""
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
511 |
return (isinstance(repo_source, DummyRepository) and |
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
512 |
isinstance(repo_target, DummyRepository)) |
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
513 |
|
514 |
||
1534.1.27
by Robert Collins
Start InterRepository with InterRepository.get. |
515 |
class TestInterRepository(TestCaseWithTransport): |
516 |
||
517 |
def test_get_default_inter_repository(self): |
|
518 |
# test that the InterRepository.get(repo_a, repo_b) probes
|
|
519 |
# for a inter_repo class where is_compatible(repo_a, repo_b) returns
|
|
520 |
# true and returns a default inter_repo otherwise.
|
|
521 |
# This also tests that the default registered optimised interrepository
|
|
522 |
# classes do not barf inappropriately when a surprising repository type
|
|
523 |
# is handed to them.
|
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
524 |
dummy_a = DummyRepository() |
525 |
dummy_b = DummyRepository() |
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
526 |
self.assertGetsDefaultInterRepository(dummy_a, dummy_b) |
527 |
||
528 |
def assertGetsDefaultInterRepository(self, repo_a, repo_b): |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
529 |
"""Asserts that InterRepository.get(repo_a, repo_b) -> the default.
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
530 |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
531 |
The effective default is now InterSameDataRepository because there is
|
532 |
no actual sane default in the presence of incompatible data models.
|
|
533 |
"""
|
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
534 |
inter_repo = repository.InterRepository.get(repo_a, repo_b) |
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
535 |
self.assertEqual(repository.InterSameDataRepository, |
1534.1.27
by Robert Collins
Start InterRepository with InterRepository.get. |
536 |
inter_repo.__class__) |
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
537 |
self.assertEqual(repo_a, inter_repo.source) |
538 |
self.assertEqual(repo_b, inter_repo.target) |
|
539 |
||
540 |
def test_register_inter_repository_class(self): |
|
541 |
# test that a optimised code path provider - a
|
|
542 |
# InterRepository subclass can be registered and unregistered
|
|
543 |
# and that it is correctly selected when given a repository
|
|
544 |
# pair that it returns true on for the is_compatible static method
|
|
545 |
# check
|
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
546 |
dummy_a = DummyRepository() |
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
547 |
dummy_a._format = RepositoryFormat() |
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
548 |
dummy_b = DummyRepository() |
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
549 |
dummy_b._format = RepositoryFormat() |
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
550 |
repo = self.make_repository('.') |
551 |
# hack dummies to look like repo somewhat.
|
|
552 |
dummy_a._serializer = repo._serializer |
|
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
553 |
dummy_a._format.supports_tree_reference = repo._format.supports_tree_reference |
554 |
dummy_a._format.rich_root_data = repo._format.rich_root_data |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
555 |
dummy_b._serializer = repo._serializer |
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
556 |
dummy_b._format.supports_tree_reference = repo._format.supports_tree_reference |
557 |
dummy_b._format.rich_root_data = repo._format.rich_root_data |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
558 |
repository.InterRepository.register_optimiser(InterDummy) |
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
559 |
try: |
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
560 |
# we should get the default for something InterDummy returns False
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
561 |
# to
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
562 |
self.assertFalse(InterDummy.is_compatible(dummy_a, repo)) |
563 |
self.assertGetsDefaultInterRepository(dummy_a, repo) |
|
564 |
# and we should get an InterDummy for a pair it 'likes'
|
|
565 |
self.assertTrue(InterDummy.is_compatible(dummy_a, dummy_b)) |
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
566 |
inter_repo = repository.InterRepository.get(dummy_a, dummy_b) |
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
567 |
self.assertEqual(InterDummy, inter_repo.__class__) |
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
568 |
self.assertEqual(dummy_a, inter_repo.source) |
569 |
self.assertEqual(dummy_b, inter_repo.target) |
|
570 |
finally: |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
571 |
repository.InterRepository.unregister_optimiser(InterDummy) |
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
572 |
# now we should get the default InterRepository object again.
|
573 |
self.assertGetsDefaultInterRepository(dummy_a, dummy_b) |
|
1534.1.33
by Robert Collins
Move copy_content_into into InterRepository and InterWeaveRepo, and disable the default codepath test as we have optimised paths for all current combinations. |
574 |
|
2241.1.17
by Martin Pool
Restore old InterWeave tests |
575 |
|
576 |
class TestInterWeaveRepo(TestCaseWithTransport): |
|
577 |
||
578 |
def test_is_compatible_and_registered(self): |
|
579 |
# InterWeaveRepo is compatible when either side
|
|
580 |
# is a format 5/6/7 branch
|
|
2241.1.20
by mbp at sourcefrog
update tests for new locations of weave repos |
581 |
from bzrlib.repofmt import knitrepo, weaverepo |
582 |
formats = [weaverepo.RepositoryFormat5(), |
|
583 |
weaverepo.RepositoryFormat6(), |
|
584 |
weaverepo.RepositoryFormat7()] |
|
585 |
incompatible_formats = [weaverepo.RepositoryFormat4(), |
|
586 |
knitrepo.RepositoryFormatKnit1(), |
|
2241.1.17
by Martin Pool
Restore old InterWeave tests |
587 |
]
|
588 |
repo_a = self.make_repository('a') |
|
589 |
repo_b = self.make_repository('b') |
|
590 |
is_compatible = repository.InterWeaveRepo.is_compatible |
|
591 |
for source in incompatible_formats: |
|
592 |
# force incompatible left then right
|
|
593 |
repo_a._format = source |
|
594 |
repo_b._format = formats[0] |
|
595 |
self.assertFalse(is_compatible(repo_a, repo_b)) |
|
596 |
self.assertFalse(is_compatible(repo_b, repo_a)) |
|
597 |
for source in formats: |
|
598 |
repo_a._format = source |
|
599 |
for target in formats: |
|
600 |
repo_b._format = target |
|
601 |
self.assertTrue(is_compatible(repo_a, repo_b)) |
|
602 |
self.assertEqual(repository.InterWeaveRepo, |
|
603 |
repository.InterRepository.get(repo_a, |
|
604 |
repo_b).__class__) |
|
605 |
||
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. |
606 |
|
607 |
class TestRepositoryConverter(TestCaseWithTransport): |
|
608 |
||
609 |
def test_convert_empty(self): |
|
610 |
t = get_transport(self.get_url('.')) |
|
611 |
t.mkdir('repository') |
|
612 |
repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository') |
|
2241.1.4
by Martin Pool
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo. |
613 |
repo = weaverepo.RepositoryFormat7().initialize(repo_dir) |
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
614 |
target_format = knitrepo.RepositoryFormatKnit1() |
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. |
615 |
converter = repository.CopyConverter(target_format) |
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
616 |
pb = bzrlib.ui.ui_factory.nested_progress_bar() |
617 |
try: |
|
618 |
converter.convert(repo, pb) |
|
619 |
finally: |
|
620 |
pb.finished() |
|
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. |
621 |
repo = repo_dir.open_repository() |
622 |
self.assertTrue(isinstance(target_format, repo._format.__class__)) |
|
1843.2.5
by Aaron Bentley
Add test of _unescape_xml |
623 |
|
624 |
||
625 |
class TestMisc(TestCase): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
626 |
|
1843.2.5
by Aaron Bentley
Add test of _unescape_xml |
627 |
def test_unescape_xml(self): |
628 |
"""We get some kind of error when malformed entities are passed"""
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
629 |
self.assertRaises(KeyError, repository._unescape_xml, 'foo&bar;') |
1910.2.13
by Aaron Bentley
Start work on converter |
630 |
|
631 |
||
2255.2.211
by Robert Collins
Remove knit2 repository format- it has never been supported. |
632 |
class TestRepositoryFormatKnit3(TestCaseWithTransport): |
1910.2.13
by Aaron Bentley
Start work on converter |
633 |
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
634 |
def test_attribute__fetch_order(self): |
635 |
"""Knits need topological data insertion."""
|
|
636 |
format = bzrdir.BzrDirMetaFormat1() |
|
637 |
format.repository_format = knitrepo.RepositoryFormatKnit3() |
|
638 |
repo = self.make_repository('.', format=format) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
639 |
self.assertEqual('topological', repo._format._fetch_order) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
640 |
|
641 |
def test_attribute__fetch_uses_deltas(self): |
|
642 |
"""Knits reuse deltas."""
|
|
643 |
format = bzrdir.BzrDirMetaFormat1() |
|
644 |
format.repository_format = knitrepo.RepositoryFormatKnit3() |
|
645 |
repo = self.make_repository('.', format=format) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
646 |
self.assertEqual(True, repo._format._fetch_uses_deltas) |
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
647 |
|
1910.2.13
by Aaron Bentley
Start work on converter |
648 |
def test_convert(self): |
649 |
"""Ensure the upgrade adds weaves for roots"""
|
|
1910.2.35
by Aaron Bentley
Better fix for convesion test |
650 |
format = bzrdir.BzrDirMetaFormat1() |
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
651 |
format.repository_format = knitrepo.RepositoryFormatKnit1() |
1910.2.35
by Aaron Bentley
Better fix for convesion test |
652 |
tree = self.make_branch_and_tree('.', format) |
1910.2.13
by Aaron Bentley
Start work on converter |
653 |
tree.commit("Dull commit", rev_id="dull") |
654 |
revision_tree = tree.branch.repository.revision_tree('dull') |
|
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. |
655 |
revision_tree.lock_read() |
656 |
try: |
|
657 |
self.assertRaises(errors.NoSuchFile, revision_tree.get_file_lines, |
|
658 |
revision_tree.inventory.root.file_id) |
|
659 |
finally: |
|
660 |
revision_tree.unlock() |
|
1910.2.13
by Aaron Bentley
Start work on converter |
661 |
format = bzrdir.BzrDirMetaFormat1() |
2255.2.211
by Robert Collins
Remove knit2 repository format- it has never been supported. |
662 |
format.repository_format = knitrepo.RepositoryFormatKnit3() |
1910.2.13
by Aaron Bentley
Start work on converter |
663 |
upgrade.Convert('.', format) |
1910.2.27
by Aaron Bentley
Fixed conversion test |
664 |
tree = workingtree.WorkingTree.open('.') |
1910.2.13
by Aaron Bentley
Start work on converter |
665 |
revision_tree = tree.branch.repository.revision_tree('dull') |
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. |
666 |
revision_tree.lock_read() |
667 |
try: |
|
668 |
revision_tree.get_file_lines(revision_tree.inventory.root.file_id) |
|
669 |
finally: |
|
670 |
revision_tree.unlock() |
|
1910.2.27
by Aaron Bentley
Fixed conversion test |
671 |
tree.commit("Another dull commit", rev_id='dull2') |
672 |
revision_tree = tree.branch.repository.revision_tree('dull2') |
|
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. |
673 |
revision_tree.lock_read() |
674 |
self.addCleanup(revision_tree.unlock) |
|
1910.2.27
by Aaron Bentley
Fixed conversion test |
675 |
self.assertEqual('dull', revision_tree.inventory.root.revision) |
2220.2.2
by Martin Pool
Add tag command and basic implementation |
676 |
|
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
677 |
def test_supports_external_lookups(self): |
678 |
format = bzrdir.BzrDirMetaFormat1() |
|
679 |
format.repository_format = knitrepo.RepositoryFormatKnit3() |
|
680 |
repo = self.make_repository('.', format=format) |
|
681 |
self.assertFalse(repo._format.supports_external_lookups) |
|
682 |
||
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
683 |
|
4667.1.1
by John Arbash Meinel
Drop the Test2a test times from 5+s down to 1.4s |
684 |
class Test2a(tests.TestCaseWithMemoryTransport): |
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
685 |
|
4634.20.1
by Robert Collins
Fix bug 402652 by recompressing all texts that are streamed - slightly slower at fetch, substantially faster and more compact at read. |
686 |
def test_fetch_combines_groups(self): |
687 |
builder = self.make_branch_builder('source', format='2a') |
|
688 |
builder.start_series() |
|
689 |
builder.build_snapshot('1', None, [ |
|
690 |
('add', ('', 'root-id', 'directory', '')), |
|
691 |
('add', ('file', 'file-id', 'file', 'content\n'))]) |
|
692 |
builder.build_snapshot('2', ['1'], [ |
|
693 |
('modify', ('file-id', 'content-2\n'))]) |
|
694 |
builder.finish_series() |
|
695 |
source = builder.get_branch() |
|
696 |
target = self.make_repository('target', format='2a') |
|
697 |
target.fetch(source.repository) |
|
698 |
target.lock_read() |
|
4665.3.2
by John Arbash Meinel
An alternative implementation that passes both tests. |
699 |
self.addCleanup(target.unlock) |
4634.20.1
by Robert Collins
Fix bug 402652 by recompressing all texts that are streamed - slightly slower at fetch, substantially faster and more compact at read. |
700 |
details = target.texts._index.get_build_details( |
701 |
[('file-id', '1',), ('file-id', '2',)]) |
|
702 |
file_1_details = details[('file-id', '1')] |
|
703 |
file_2_details = details[('file-id', '2')] |
|
704 |
# The index, and what to read off disk, should be the same for both
|
|
705 |
# versions of the file.
|
|
706 |
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3]) |
|
707 |
||
4634.23.1
by Robert Collins
Cherrypick from bzr.dev: Fix bug 402652: recompress badly packed groups during fetch. (John Arbash Meinel, Robert Collins) |
708 |
def test_fetch_combines_groups(self): |
709 |
builder = self.make_branch_builder('source', format='2a') |
|
710 |
builder.start_series() |
|
711 |
builder.build_snapshot('1', None, [ |
|
712 |
('add', ('', 'root-id', 'directory', '')), |
|
713 |
('add', ('file', 'file-id', 'file', 'content\n'))]) |
|
714 |
builder.build_snapshot('2', ['1'], [ |
|
715 |
('modify', ('file-id', 'content-2\n'))]) |
|
716 |
builder.finish_series() |
|
717 |
source = builder.get_branch() |
|
718 |
target = self.make_repository('target', format='2a') |
|
719 |
target.fetch(source.repository) |
|
720 |
target.lock_read() |
|
721 |
self.addCleanup(target.unlock) |
|
722 |
details = target.texts._index.get_build_details( |
|
723 |
[('file-id', '1',), ('file-id', '2',)]) |
|
724 |
file_1_details = details[('file-id', '1')] |
|
725 |
file_2_details = details[('file-id', '2')] |
|
726 |
# The index, and what to read off disk, should be the same for both
|
|
727 |
# versions of the file.
|
|
728 |
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3]) |
|
729 |
||
730 |
def test_fetch_combines_groups(self): |
|
731 |
builder = self.make_branch_builder('source', format='2a') |
|
732 |
builder.start_series() |
|
733 |
builder.build_snapshot('1', None, [ |
|
734 |
('add', ('', 'root-id', 'directory', '')), |
|
735 |
('add', ('file', 'file-id', 'file', 'content\n'))]) |
|
736 |
builder.build_snapshot('2', ['1'], [ |
|
737 |
('modify', ('file-id', 'content-2\n'))]) |
|
738 |
builder.finish_series() |
|
739 |
source = builder.get_branch() |
|
740 |
target = self.make_repository('target', format='2a') |
|
741 |
target.fetch(source.repository) |
|
742 |
target.lock_read() |
|
743 |
self.addCleanup(target.unlock) |
|
744 |
details = target.texts._index.get_build_details( |
|
745 |
[('file-id', '1',), ('file-id', '2',)]) |
|
746 |
file_1_details = details[('file-id', '1')] |
|
747 |
file_2_details = details[('file-id', '2')] |
|
748 |
# The index, and what to read off disk, should be the same for both
|
|
749 |
# versions of the file.
|
|
750 |
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3]) |
|
751 |
||
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
752 |
def test_format_pack_compresses_True(self): |
753 |
repo = self.make_repository('repo', format='2a') |
|
754 |
self.assertTrue(repo._format.pack_compresses) |
|
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
755 |
|
756 |
def test_inventories_use_chk_map_with_parent_base_dict(self): |
|
4667.1.1
by John Arbash Meinel
Drop the Test2a test times from 5+s down to 1.4s |
757 |
tree = self.make_branch_and_memory_tree('repo', format="2a") |
758 |
tree.lock_write() |
|
759 |
tree.add([''], ['TREE_ROOT']) |
|
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
760 |
revid = tree.commit("foo") |
4667.1.1
by John Arbash Meinel
Drop the Test2a test times from 5+s down to 1.4s |
761 |
tree.unlock() |
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
762 |
tree.lock_read() |
763 |
self.addCleanup(tree.unlock) |
|
764 |
inv = tree.branch.repository.get_inventory(revid) |
|
3735.2.41
by Robert Collins
Make the parent_id_basename index be updated during CHKInventory.apply_delta. |
765 |
self.assertNotEqual(None, inv.parent_id_basename_to_file_id) |
766 |
inv.parent_id_basename_to_file_id._ensure_root() |
|
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
767 |
inv.id_to_entry._ensure_root() |
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
768 |
self.assertEqual(65536, inv.id_to_entry._root_node.maximum_size) |
769 |
self.assertEqual(65536, |
|
3735.2.41
by Robert Collins
Make the parent_id_basename index be updated during CHKInventory.apply_delta. |
770 |
inv.parent_id_basename_to_file_id._root_node.maximum_size) |
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
771 |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
772 |
def test_autopack_unchanged_chk_nodes(self): |
773 |
# at 20 unchanged commits, chk pages are packed that are split into
|
|
774 |
# two groups such that the new pack being made doesn't have all its
|
|
775 |
# pages in the source packs (though they are in the repository).
|
|
4667.1.1
by John Arbash Meinel
Drop the Test2a test times from 5+s down to 1.4s |
776 |
# Use a memory backed repository, we don't need to hit disk for this
|
777 |
tree = self.make_branch_and_memory_tree('tree', format='2a') |
|
778 |
tree.lock_write() |
|
779 |
self.addCleanup(tree.unlock) |
|
780 |
tree.add([''], ['TREE_ROOT']) |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
781 |
for pos in range(20): |
782 |
tree.commit(str(pos)) |
|
783 |
||
784 |
def test_pack_with_hint(self): |
|
4667.1.1
by John Arbash Meinel
Drop the Test2a test times from 5+s down to 1.4s |
785 |
tree = self.make_branch_and_memory_tree('tree', format='2a') |
786 |
tree.lock_write() |
|
787 |
self.addCleanup(tree.unlock) |
|
788 |
tree.add([''], ['TREE_ROOT']) |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
789 |
# 1 commit to leave untouched
|
790 |
tree.commit('1') |
|
791 |
to_keep = tree.branch.repository._pack_collection.names() |
|
792 |
# 2 to combine
|
|
793 |
tree.commit('2') |
|
794 |
tree.commit('3') |
|
795 |
all = tree.branch.repository._pack_collection.names() |
|
796 |
combine = list(set(all) - set(to_keep)) |
|
797 |
self.assertLength(3, all) |
|
798 |
self.assertLength(2, combine) |
|
799 |
tree.branch.repository.pack(hint=combine) |
|
800 |
final = tree.branch.repository._pack_collection.names() |
|
801 |
self.assertLength(2, final) |
|
802 |
self.assertFalse(combine[0] in final) |
|
803 |
self.assertFalse(combine[1] in final) |
|
804 |
self.assertSubset(to_keep, final) |
|
805 |
||
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
806 |
def test_stream_source_to_gc(self): |
4462.2.1
by Robert Collins
Add new attribute to RepositoryFormat pack_compresses, hinting when pack can be useful. |
807 |
source = self.make_repository('source', format='2a') |
808 |
target = self.make_repository('target', format='2a') |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
809 |
stream = source._get_source(target._format) |
810 |
self.assertIsInstance(stream, groupcompress_repo.GroupCHKStreamSource) |
|
811 |
||
812 |
def test_stream_source_to_non_gc(self): |
|
4462.2.1
by Robert Collins
Add new attribute to RepositoryFormat pack_compresses, hinting when pack can be useful. |
813 |
source = self.make_repository('source', format='2a') |
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
814 |
target = self.make_repository('target', format='rich-root-pack') |
815 |
stream = source._get_source(target._format) |
|
816 |
# We don't want the child GroupCHKStreamSource
|
|
817 |
self.assertIs(type(stream), repository.StreamSource) |
|
818 |
||
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
819 |
def test_get_stream_for_missing_keys_includes_all_chk_refs(self): |
820 |
source_builder = self.make_branch_builder('source', |
|
4462.2.1
by Robert Collins
Add new attribute to RepositoryFormat pack_compresses, hinting when pack can be useful. |
821 |
format='2a') |
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
822 |
# We have to build a fairly large tree, so that we are sure the chk
|
823 |
# pages will have split into multiple pages.
|
|
824 |
entries = [('add', ('', 'a-root-id', 'directory', None))] |
|
825 |
for i in 'abcdefghijklmnopqrstuvwxyz123456789': |
|
826 |
for j in 'abcdefghijklmnopqrstuvwxyz123456789': |
|
827 |
fname = i + j |
|
828 |
fid = fname + '-id' |
|
829 |
content = 'content for %s\n' % (fname,) |
|
830 |
entries.append(('add', (fname, fid, 'file', content))) |
|
831 |
source_builder.start_series() |
|
832 |
source_builder.build_snapshot('rev-1', None, entries) |
|
833 |
# Now change a few of them, so we get a few new pages for the second
|
|
834 |
# revision
|
|
835 |
source_builder.build_snapshot('rev-2', ['rev-1'], [ |
|
836 |
('modify', ('aa-id', 'new content for aa-id\n')), |
|
837 |
('modify', ('cc-id', 'new content for cc-id\n')), |
|
838 |
('modify', ('zz-id', 'new content for zz-id\n')), |
|
839 |
])
|
|
840 |
source_builder.finish_series() |
|
841 |
source_branch = source_builder.get_branch() |
|
842 |
source_branch.lock_read() |
|
843 |
self.addCleanup(source_branch.unlock) |
|
4462.2.1
by Robert Collins
Add new attribute to RepositoryFormat pack_compresses, hinting when pack can be useful. |
844 |
target = self.make_repository('target', format='2a') |
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
845 |
source = source_branch.repository._get_source(target._format) |
846 |
self.assertIsInstance(source, groupcompress_repo.GroupCHKStreamSource) |
|
847 |
||
848 |
# On a regular pass, getting the inventories and chk pages for rev-2
|
|
849 |
# would only get the newly created chk pages
|
|
850 |
search = graph.SearchResult(set(['rev-2']), set(['rev-1']), 1, |
|
851 |
set(['rev-2'])) |
|
852 |
simple_chk_records = [] |
|
853 |
for vf_name, substream in source.get_stream(search): |
|
854 |
if vf_name == 'chk_bytes': |
|
855 |
for record in substream: |
|
856 |
simple_chk_records.append(record.key) |
|
857 |
else: |
|
858 |
for _ in substream: |
|
859 |
continue
|
|
860 |
# 3 pages, the root (InternalNode), + 2 pages which actually changed
|
|
861 |
self.assertEqual([('sha1:91481f539e802c76542ea5e4c83ad416bf219f73',), |
|
862 |
('sha1:4ff91971043668583985aec83f4f0ab10a907d3f',), |
|
863 |
('sha1:81e7324507c5ca132eedaf2d8414ee4bb2226187',), |
|
864 |
('sha1:b101b7da280596c71a4540e9a1eeba8045985ee0',)], |
|
865 |
simple_chk_records) |
|
866 |
# Now, when we do a similar call using 'get_stream_for_missing_keys'
|
|
867 |
# we should get a much larger set of pages.
|
|
868 |
missing = [('inventories', 'rev-2')] |
|
869 |
full_chk_records = [] |
|
870 |
for vf_name, substream in source.get_stream_for_missing_keys(missing): |
|
871 |
if vf_name == 'inventories': |
|
872 |
for record in substream: |
|
873 |
self.assertEqual(('rev-2',), record.key) |
|
874 |
elif vf_name == 'chk_bytes': |
|
875 |
for record in substream: |
|
876 |
full_chk_records.append(record.key) |
|
877 |
else: |
|
878 |
self.fail('Should not be getting a stream of %s' % (vf_name,)) |
|
879 |
# We have 257 records now. This is because we have 1 root page, and 256
|
|
880 |
# leaf pages in a complete listing.
|
|
881 |
self.assertEqual(257, len(full_chk_records)) |
|
882 |
self.assertSubset(simple_chk_records, full_chk_records) |
|
883 |
||
4465.2.7
by Aaron Bentley
Move test_inconsistency_fatal to test_repository |
884 |
def test_inconsistency_fatal(self): |
885 |
repo = self.make_repository('repo', format='2a') |
|
886 |
self.assertTrue(repo.revisions._index._inconsistency_fatal) |
|
887 |
self.assertFalse(repo.texts._index._inconsistency_fatal) |
|
888 |
self.assertFalse(repo.inventories._index._inconsistency_fatal) |
|
889 |
self.assertFalse(repo.signatures._index._inconsistency_fatal) |
|
890 |
self.assertFalse(repo.chk_bytes._index._inconsistency_fatal) |
|
891 |
||
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
892 |
|
893 |
class TestKnitPackStreamSource(tests.TestCaseWithMemoryTransport): |
|
894 |
||
895 |
def test_source_to_exact_pack_092(self): |
|
896 |
source = self.make_repository('source', format='pack-0.92') |
|
897 |
target = self.make_repository('target', format='pack-0.92') |
|
898 |
stream_source = source._get_source(target._format) |
|
899 |
self.assertIsInstance(stream_source, pack_repo.KnitPackStreamSource) |
|
900 |
||
901 |
def test_source_to_exact_pack_rich_root_pack(self): |
|
902 |
source = self.make_repository('source', format='rich-root-pack') |
|
903 |
target = self.make_repository('target', format='rich-root-pack') |
|
904 |
stream_source = source._get_source(target._format) |
|
905 |
self.assertIsInstance(stream_source, pack_repo.KnitPackStreamSource) |
|
906 |
||
907 |
def test_source_to_exact_pack_19(self): |
|
908 |
source = self.make_repository('source', format='1.9') |
|
909 |
target = self.make_repository('target', format='1.9') |
|
910 |
stream_source = source._get_source(target._format) |
|
911 |
self.assertIsInstance(stream_source, pack_repo.KnitPackStreamSource) |
|
912 |
||
913 |
def test_source_to_exact_pack_19_rich_root(self): |
|
914 |
source = self.make_repository('source', format='1.9-rich-root') |
|
915 |
target = self.make_repository('target', format='1.9-rich-root') |
|
916 |
stream_source = source._get_source(target._format) |
|
917 |
self.assertIsInstance(stream_source, pack_repo.KnitPackStreamSource) |
|
918 |
||
919 |
def test_source_to_remote_exact_pack_19(self): |
|
920 |
trans = self.make_smart_server('target') |
|
921 |
trans.ensure_base() |
|
922 |
source = self.make_repository('source', format='1.9') |
|
923 |
target = self.make_repository('target', format='1.9') |
|
924 |
target = repository.Repository.open(trans.base) |
|
925 |
stream_source = source._get_source(target._format) |
|
926 |
self.assertIsInstance(stream_source, pack_repo.KnitPackStreamSource) |
|
927 |
||
928 |
def test_stream_source_to_non_exact(self): |
|
929 |
source = self.make_repository('source', format='pack-0.92') |
|
930 |
target = self.make_repository('target', format='1.9') |
|
931 |
stream = source._get_source(target._format) |
|
932 |
self.assertIs(type(stream), repository.StreamSource) |
|
933 |
||
934 |
def test_stream_source_to_non_exact_rich_root(self): |
|
935 |
source = self.make_repository('source', format='1.9') |
|
936 |
target = self.make_repository('target', format='1.9-rich-root') |
|
937 |
stream = source._get_source(target._format) |
|
938 |
self.assertIs(type(stream), repository.StreamSource) |
|
939 |
||
940 |
def test_source_to_remote_non_exact_pack_19(self): |
|
941 |
trans = self.make_smart_server('target') |
|
942 |
trans.ensure_base() |
|
943 |
source = self.make_repository('source', format='1.9') |
|
944 |
target = self.make_repository('target', format='1.6') |
|
945 |
target = repository.Repository.open(trans.base) |
|
946 |
stream_source = source._get_source(target._format) |
|
947 |
self.assertIs(type(stream_source), repository.StreamSource) |
|
948 |
||
949 |
def test_stream_source_to_knit(self): |
|
950 |
source = self.make_repository('source', format='pack-0.92') |
|
951 |
target = self.make_repository('target', format='dirstate') |
|
952 |
stream = source._get_source(target._format) |
|
953 |
self.assertIs(type(stream), repository.StreamSource) |
|
954 |
||
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
955 |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
956 |
class TestDevelopment6FindParentIdsOfRevisions(TestCaseWithTransport): |
957 |
"""Tests for _find_parent_ids_of_revisions."""
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
958 |
|
959 |
def setUp(self): |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
960 |
super(TestDevelopment6FindParentIdsOfRevisions, self).setUp() |
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
961 |
self.builder = self.make_branch_builder('source', |
962 |
format='development6-rich-root') |
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
963 |
self.builder.start_series() |
964 |
self.builder.build_snapshot('initial', None, |
|
965 |
[('add', ('', 'tree-root', 'directory', None))]) |
|
966 |
self.repo = self.builder.get_branch().repository |
|
967 |
self.addCleanup(self.builder.finish_series) |
|
3735.2.99
by John Arbash Meinel
Merge bzr.dev 4034. Whitespace cleanup |
968 |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
969 |
def assertParentIds(self, expected_result, rev_set): |
970 |
self.assertEqual(sorted(expected_result), |
|
971 |
sorted(self.repo._find_parent_ids_of_revisions(rev_set))) |
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
972 |
|
973 |
def test_simple(self): |
|
974 |
self.builder.build_snapshot('revid1', None, []) |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
975 |
self.builder.build_snapshot('revid2', ['revid1'], []) |
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
976 |
rev_set = ['revid2'] |
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
977 |
self.assertParentIds(['revid1'], rev_set) |
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
978 |
|
979 |
def test_not_first_parent(self): |
|
980 |
self.builder.build_snapshot('revid1', None, []) |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
981 |
self.builder.build_snapshot('revid2', ['revid1'], []) |
982 |
self.builder.build_snapshot('revid3', ['revid2'], []) |
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
983 |
rev_set = ['revid3', 'revid2'] |
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
984 |
self.assertParentIds(['revid1'], rev_set) |
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
985 |
|
986 |
def test_not_null(self): |
|
987 |
rev_set = ['initial'] |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
988 |
self.assertParentIds([], rev_set) |
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
989 |
|
990 |
def test_not_null_set(self): |
|
991 |
self.builder.build_snapshot('revid1', None, []) |
|
992 |
rev_set = [_mod_revision.NULL_REVISION] |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
993 |
self.assertParentIds([], rev_set) |
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
994 |
|
995 |
def test_ghost(self): |
|
996 |
self.builder.build_snapshot('revid1', None, []) |
|
997 |
rev_set = ['ghost', 'revid1'] |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
998 |
self.assertParentIds(['initial'], rev_set) |
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
999 |
|
1000 |
def test_ghost_parent(self): |
|
1001 |
self.builder.build_snapshot('revid1', None, []) |
|
1002 |
self.builder.build_snapshot('revid2', ['revid1', 'ghost'], []) |
|
1003 |
rev_set = ['revid2', 'revid1'] |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
1004 |
self.assertParentIds(['ghost', 'initial'], rev_set) |
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
1005 |
|
1006 |
def test_righthand_parent(self): |
|
1007 |
self.builder.build_snapshot('revid1', None, []) |
|
1008 |
self.builder.build_snapshot('revid2a', ['revid1'], []) |
|
1009 |
self.builder.build_snapshot('revid2b', ['revid1'], []) |
|
1010 |
self.builder.build_snapshot('revid3', ['revid2a', 'revid2b'], []) |
|
1011 |
rev_set = ['revid3', 'revid2a'] |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
1012 |
self.assertParentIds(['revid1', 'revid2b'], rev_set) |
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
1013 |
|
1014 |
||
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
1015 |
class TestWithBrokenRepo(TestCaseWithTransport): |
2592.3.214
by Robert Collins
Merge bzr.dev. |
1016 |
"""These tests seem to be more appropriate as interface tests?"""
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
1017 |
|
1018 |
def make_broken_repository(self): |
|
1019 |
# XXX: This function is borrowed from Aaron's "Reconcile can fix bad
|
|
1020 |
# parent references" branch which is due to land in bzr.dev soon. Once
|
|
1021 |
# it does, this duplication should be removed.
|
|
1022 |
repo = self.make_repository('broken-repo') |
|
1023 |
cleanups = [] |
|
1024 |
try: |
|
1025 |
repo.lock_write() |
|
1026 |
cleanups.append(repo.unlock) |
|
1027 |
repo.start_write_group() |
|
1028 |
cleanups.append(repo.commit_write_group) |
|
1029 |
# make rev1a: A well-formed revision, containing 'file1'
|
|
1030 |
inv = inventory.Inventory(revision_id='rev1a') |
|
1031 |
inv.root.revision = 'rev1a' |
|
1032 |
self.add_file(repo, inv, 'file1', 'rev1a', []) |
|
4634.35.21
by Andrew Bennetts
Fix test_insert_from_broken_repo in test_repository. |
1033 |
repo.texts.add_lines((inv.root.file_id, 'rev1a'), [], []) |
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
1034 |
repo.add_inventory('rev1a', inv, []) |
1035 |
revision = _mod_revision.Revision('rev1a', |
|
1036 |
committer='jrandom@example.com', timestamp=0, |
|
1037 |
inventory_sha1='', timezone=0, message='foo', parent_ids=[]) |
|
1038 |
repo.add_revision('rev1a',revision, inv) |
|
1039 |
||
1040 |
# make rev1b, which has no Revision, but has an Inventory, and
|
|
1041 |
# file1
|
|
1042 |
inv = inventory.Inventory(revision_id='rev1b') |
|
1043 |
inv.root.revision = 'rev1b' |
|
1044 |
self.add_file(repo, inv, 'file1', 'rev1b', []) |
|
1045 |
repo.add_inventory('rev1b', inv, []) |
|
1046 |
||
1047 |
# make rev2, with file1 and file2
|
|
1048 |
# file2 is sane
|
|
1049 |
# file1 has 'rev1b' as an ancestor, even though this is not
|
|
1050 |
# mentioned by 'rev1a', making it an unreferenced ancestor
|
|
1051 |
inv = inventory.Inventory() |
|
1052 |
self.add_file(repo, inv, 'file1', 'rev2', ['rev1a', 'rev1b']) |
|
1053 |
self.add_file(repo, inv, 'file2', 'rev2', []) |
|
1054 |
self.add_revision(repo, 'rev2', inv, ['rev1a']) |
|
1055 |
||
1056 |
# make ghost revision rev1c
|
|
1057 |
inv = inventory.Inventory() |
|
1058 |
self.add_file(repo, inv, 'file2', 'rev1c', []) |
|
1059 |
||
1060 |
# make rev3 with file2
|
|
1061 |
# file2 refers to 'rev1c', which is a ghost in this repository, so
|
|
1062 |
# file2 cannot have rev1c as its ancestor.
|
|
1063 |
inv = inventory.Inventory() |
|
1064 |
self.add_file(repo, inv, 'file2', 'rev3', ['rev1c']) |
|
1065 |
self.add_revision(repo, 'rev3', inv, ['rev1c']) |
|
1066 |
return repo |
|
1067 |
finally: |
|
1068 |
for cleanup in reversed(cleanups): |
|
1069 |
cleanup() |
|
1070 |
||
1071 |
def add_revision(self, repo, revision_id, inv, parent_ids): |
|
1072 |
inv.revision_id = revision_id |
|
1073 |
inv.root.revision = revision_id |
|
4634.35.21
by Andrew Bennetts
Fix test_insert_from_broken_repo in test_repository. |
1074 |
repo.texts.add_lines((inv.root.file_id, revision_id), [], []) |
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
1075 |
repo.add_inventory(revision_id, inv, parent_ids) |
1076 |
revision = _mod_revision.Revision(revision_id, |
|
1077 |
committer='jrandom@example.com', timestamp=0, inventory_sha1='', |
|
1078 |
timezone=0, message='foo', parent_ids=parent_ids) |
|
1079 |
repo.add_revision(revision_id,revision, inv) |
|
1080 |
||
1081 |
def add_file(self, repo, inv, filename, revision, parents): |
|
1082 |
file_id = filename + '-id' |
|
1083 |
entry = inventory.InventoryFile(file_id, filename, 'TREE_ROOT') |
|
1084 |
entry.revision = revision |
|
2535.4.10
by Andrew Bennetts
Fix one failing test, disable another. |
1085 |
entry.text_size = 0 |
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
1086 |
inv.add(entry) |
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. |
1087 |
text_key = (file_id, revision) |
1088 |
parent_keys = [(file_id, parent) for parent in parents] |
|
1089 |
repo.texts.add_lines(text_key, parent_keys, ['line\n']) |
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
1090 |
|
1091 |
def test_insert_from_broken_repo(self): |
|
1092 |
"""Inserting a data stream from a broken repository won't silently
|
|
1093 |
corrupt the target repository.
|
|
1094 |
"""
|
|
1095 |
broken_repo = self.make_broken_repository() |
|
1096 |
empty_repo = self.make_repository('empty-repo') |
|
4606.1.1
by Robert Collins
Change test_insert_from_broken_repo from a known failure to a working test. |
1097 |
try: |
1098 |
empty_repo.fetch(broken_repo) |
|
1099 |
except (errors.RevisionNotPresent, errors.BzrCheckError): |
|
1100 |
# Test successful: compression parent not being copied leads to
|
|
1101 |
# error.
|
|
1102 |
return
|
|
1103 |
empty_repo.lock_read() |
|
1104 |
self.addCleanup(empty_repo.unlock) |
|
1105 |
text = empty_repo.texts.get_record_stream( |
|
1106 |
[('file2-id', 'rev3')], 'topological', True).next() |
|
1107 |
self.assertEqual('line\n', text.get_bytes_as('fulltext')) |
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
1108 |
|
1109 |
||
2592.3.84
by Robert Collins
Start of autopacking logic. |
1110 |
class TestRepositoryPackCollection(TestCaseWithTransport): |
1111 |
||
1112 |
def get_format(self): |
|
3010.3.3
by Martin Pool
Merge trunk |
1113 |
return bzrdir.format_registry.make_bzrdir('pack-0.92') |
2592.3.84
by Robert Collins
Start of autopacking logic. |
1114 |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1115 |
def get_packs(self): |
1116 |
format = self.get_format() |
|
1117 |
repo = self.make_repository('.', format=format) |
|
1118 |
return repo._pack_collection |
|
1119 |
||
3789.2.20
by John Arbash Meinel
The autopack code can now trigger itself to retry when _copy_revision_texts fails. |
1120 |
def make_packs_and_alt_repo(self, write_lock=False): |
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1121 |
"""Create a pack repo with 3 packs, and access it via a second repo."""
|
4617.4.1
by Robert Collins
Fix a pack specific test which didn't lock its format down. |
1122 |
tree = self.make_branch_and_tree('.', format=self.get_format()) |
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1123 |
tree.lock_write() |
1124 |
self.addCleanup(tree.unlock) |
|
1125 |
rev1 = tree.commit('one') |
|
1126 |
rev2 = tree.commit('two') |
|
1127 |
rev3 = tree.commit('three') |
|
1128 |
r = repository.Repository.open('.') |
|
3789.2.20
by John Arbash Meinel
The autopack code can now trigger itself to retry when _copy_revision_texts fails. |
1129 |
if write_lock: |
1130 |
r.lock_write() |
|
1131 |
else: |
|
1132 |
r.lock_read() |
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1133 |
self.addCleanup(r.unlock) |
1134 |
packs = r._pack_collection |
|
1135 |
packs.ensure_loaded() |
|
1136 |
return tree, r, packs, [rev1, rev2, rev3] |
|
1137 |
||
2592.3.84
by Robert Collins
Start of autopacking logic. |
1138 |
def test__max_pack_count(self): |
2592.3.219
by Robert Collins
Review feedback. |
1139 |
"""The maximum pack count is a function of the number of revisions."""
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1140 |
# no revisions - one pack, so that we can have a revision free repo
|
1141 |
# without it blowing up
|
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1142 |
packs = self.get_packs() |
2592.3.84
by Robert Collins
Start of autopacking logic. |
1143 |
self.assertEqual(1, packs._max_pack_count(0)) |
1144 |
# after that the sum of the digits, - check the first 1-9
|
|
1145 |
self.assertEqual(1, packs._max_pack_count(1)) |
|
1146 |
self.assertEqual(2, packs._max_pack_count(2)) |
|
1147 |
self.assertEqual(3, packs._max_pack_count(3)) |
|
1148 |
self.assertEqual(4, packs._max_pack_count(4)) |
|
1149 |
self.assertEqual(5, packs._max_pack_count(5)) |
|
1150 |
self.assertEqual(6, packs._max_pack_count(6)) |
|
1151 |
self.assertEqual(7, packs._max_pack_count(7)) |
|
1152 |
self.assertEqual(8, packs._max_pack_count(8)) |
|
1153 |
self.assertEqual(9, packs._max_pack_count(9)) |
|
1154 |
# check the boundary cases with two digits for the next decade
|
|
1155 |
self.assertEqual(1, packs._max_pack_count(10)) |
|
1156 |
self.assertEqual(2, packs._max_pack_count(11)) |
|
1157 |
self.assertEqual(10, packs._max_pack_count(19)) |
|
1158 |
self.assertEqual(2, packs._max_pack_count(20)) |
|
1159 |
self.assertEqual(3, packs._max_pack_count(21)) |
|
1160 |
# check some arbitrary big numbers
|
|
1161 |
self.assertEqual(25, packs._max_pack_count(112894)) |
|
1162 |
||
1163 |
def test_pack_distribution_zero(self): |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1164 |
packs = self.get_packs() |
2592.3.84
by Robert Collins
Start of autopacking logic. |
1165 |
self.assertEqual([0], packs.pack_distribution(0)) |
3052.1.6
by John Arbash Meinel
Change the lock check to raise ObjectNotLocked. |
1166 |
|
1167 |
def test_ensure_loaded_unlocked(self): |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1168 |
packs = self.get_packs() |
3052.1.6
by John Arbash Meinel
Change the lock check to raise ObjectNotLocked. |
1169 |
self.assertRaises(errors.ObjectNotLocked, |
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1170 |
packs.ensure_loaded) |
3052.1.6
by John Arbash Meinel
Change the lock check to raise ObjectNotLocked. |
1171 |
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1172 |
def test_pack_distribution_one_to_nine(self): |
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1173 |
packs = self.get_packs() |
2592.3.84
by Robert Collins
Start of autopacking logic. |
1174 |
self.assertEqual([1], |
1175 |
packs.pack_distribution(1)) |
|
1176 |
self.assertEqual([1, 1], |
|
1177 |
packs.pack_distribution(2)) |
|
1178 |
self.assertEqual([1, 1, 1], |
|
1179 |
packs.pack_distribution(3)) |
|
1180 |
self.assertEqual([1, 1, 1, 1], |
|
1181 |
packs.pack_distribution(4)) |
|
1182 |
self.assertEqual([1, 1, 1, 1, 1], |
|
1183 |
packs.pack_distribution(5)) |
|
1184 |
self.assertEqual([1, 1, 1, 1, 1, 1], |
|
1185 |
packs.pack_distribution(6)) |
|
1186 |
self.assertEqual([1, 1, 1, 1, 1, 1, 1], |
|
1187 |
packs.pack_distribution(7)) |
|
1188 |
self.assertEqual([1, 1, 1, 1, 1, 1, 1, 1], |
|
1189 |
packs.pack_distribution(8)) |
|
1190 |
self.assertEqual([1, 1, 1, 1, 1, 1, 1, 1, 1], |
|
1191 |
packs.pack_distribution(9)) |
|
1192 |
||
1193 |
def test_pack_distribution_stable_at_boundaries(self): |
|
1194 |
"""When there are multi-rev packs the counts are stable."""
|
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1195 |
packs = self.get_packs() |
2592.3.84
by Robert Collins
Start of autopacking logic. |
1196 |
# in 10s:
|
1197 |
self.assertEqual([10], packs.pack_distribution(10)) |
|
1198 |
self.assertEqual([10, 1], packs.pack_distribution(11)) |
|
1199 |
self.assertEqual([10, 10], packs.pack_distribution(20)) |
|
1200 |
self.assertEqual([10, 10, 1], packs.pack_distribution(21)) |
|
1201 |
# 100s
|
|
1202 |
self.assertEqual([100], packs.pack_distribution(100)) |
|
1203 |
self.assertEqual([100, 1], packs.pack_distribution(101)) |
|
1204 |
self.assertEqual([100, 10, 1], packs.pack_distribution(111)) |
|
1205 |
self.assertEqual([100, 100], packs.pack_distribution(200)) |
|
1206 |
self.assertEqual([100, 100, 1], packs.pack_distribution(201)) |
|
1207 |
self.assertEqual([100, 100, 10, 1], packs.pack_distribution(211)) |
|
1208 |
||
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1209 |
def test_plan_pack_operations_2009_revisions_skip_all_packs(self): |
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1210 |
packs = self.get_packs() |
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1211 |
existing_packs = [(2000, "big"), (9, "medium")] |
1212 |
# rev count - 2009 -> 2x1000 + 9x1
|
|
1213 |
pack_operations = packs.plan_autopack_combinations( |
|
1214 |
existing_packs, [1000, 1000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) |
|
1215 |
self.assertEqual([], pack_operations) |
|
1216 |
||
1217 |
def test_plan_pack_operations_2010_revisions_skip_all_packs(self): |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1218 |
packs = self.get_packs() |
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1219 |
existing_packs = [(2000, "big"), (9, "medium"), (1, "single")] |
1220 |
# rev count - 2010 -> 2x1000 + 1x10
|
|
1221 |
pack_operations = packs.plan_autopack_combinations( |
|
1222 |
existing_packs, [1000, 1000, 10]) |
|
1223 |
self.assertEqual([], pack_operations) |
|
1224 |
||
1225 |
def test_plan_pack_operations_2010_combines_smallest_two(self): |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1226 |
packs = self.get_packs() |
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1227 |
existing_packs = [(1999, "big"), (9, "medium"), (1, "single2"), |
1228 |
(1, "single1")] |
|
1229 |
# rev count - 2010 -> 2x1000 + 1x10 (3)
|
|
1230 |
pack_operations = packs.plan_autopack_combinations( |
|
1231 |
existing_packs, [1000, 1000, 10]) |
|
3711.4.2
by John Arbash Meinel
Change the logic to solve it in a different way. |
1232 |
self.assertEqual([[2, ["single2", "single1"]]], pack_operations) |
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1233 |
|
3711.4.2
by John Arbash Meinel
Change the logic to solve it in a different way. |
1234 |
def test_plan_pack_operations_creates_a_single_op(self): |
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1235 |
packs = self.get_packs() |
3711.4.2
by John Arbash Meinel
Change the logic to solve it in a different way. |
1236 |
existing_packs = [(50, 'a'), (40, 'b'), (30, 'c'), (10, 'd'), |
1237 |
(10, 'e'), (6, 'f'), (4, 'g')] |
|
1238 |
# rev count 150 -> 1x100 and 5x10
|
|
1239 |
# The two size 10 packs do not need to be touched. The 50, 40, 30 would
|
|
1240 |
# be combined into a single 120 size pack, and the 6 & 4 would
|
|
1241 |
# becombined into a size 10 pack. However, if we have to rewrite them,
|
|
1242 |
# we save a pack file with no increased I/O by putting them into the
|
|
1243 |
# same file.
|
|
1244 |
distribution = packs.pack_distribution(150) |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1245 |
pack_operations = packs.plan_autopack_combinations(existing_packs, |
3711.4.2
by John Arbash Meinel
Change the logic to solve it in a different way. |
1246 |
distribution) |
1247 |
self.assertEqual([[130, ['a', 'b', 'c', 'f', 'g']]], pack_operations) |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1248 |
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1249 |
def test_all_packs_none(self): |
1250 |
format = self.get_format() |
|
1251 |
tree = self.make_branch_and_tree('.', format=format) |
|
1252 |
tree.lock_read() |
|
1253 |
self.addCleanup(tree.unlock) |
|
2592.3.232
by Martin Pool
Disambiguate two member variables called _packs into _packs_by_name and _pack_collection |
1254 |
packs = tree.branch.repository._pack_collection |
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1255 |
packs.ensure_loaded() |
1256 |
self.assertEqual([], packs.all_packs()) |
|
1257 |
||
1258 |
def test_all_packs_one(self): |
|
1259 |
format = self.get_format() |
|
1260 |
tree = self.make_branch_and_tree('.', format=format) |
|
1261 |
tree.commit('start') |
|
1262 |
tree.lock_read() |
|
1263 |
self.addCleanup(tree.unlock) |
|
2592.3.232
by Martin Pool
Disambiguate two member variables called _packs into _packs_by_name and _pack_collection |
1264 |
packs = tree.branch.repository._pack_collection |
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1265 |
packs.ensure_loaded() |
2592.3.176
by Robert Collins
Various pack refactorings. |
1266 |
self.assertEqual([ |
1267 |
packs.get_pack_by_name(packs.names()[0])], |
|
1268 |
packs.all_packs()) |
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1269 |
|
1270 |
def test_all_packs_two(self): |
|
1271 |
format = self.get_format() |
|
1272 |
tree = self.make_branch_and_tree('.', format=format) |
|
1273 |
tree.commit('start') |
|
1274 |
tree.commit('continue') |
|
1275 |
tree.lock_read() |
|
1276 |
self.addCleanup(tree.unlock) |
|
2592.3.232
by Martin Pool
Disambiguate two member variables called _packs into _packs_by_name and _pack_collection |
1277 |
packs = tree.branch.repository._pack_collection |
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1278 |
packs.ensure_loaded() |
1279 |
self.assertEqual([ |
|
2592.3.176
by Robert Collins
Various pack refactorings. |
1280 |
packs.get_pack_by_name(packs.names()[0]), |
1281 |
packs.get_pack_by_name(packs.names()[1]), |
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1282 |
], packs.all_packs()) |
1283 |
||
2592.3.176
by Robert Collins
Various pack refactorings. |
1284 |
def test_get_pack_by_name(self): |
1285 |
format = self.get_format() |
|
1286 |
tree = self.make_branch_and_tree('.', format=format) |
|
1287 |
tree.commit('start') |
|
1288 |
tree.lock_read() |
|
1289 |
self.addCleanup(tree.unlock) |
|
2592.3.232
by Martin Pool
Disambiguate two member variables called _packs into _packs_by_name and _pack_collection |
1290 |
packs = tree.branch.repository._pack_collection |
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
1291 |
packs.reset() |
2592.3.176
by Robert Collins
Various pack refactorings. |
1292 |
packs.ensure_loaded() |
1293 |
name = packs.names()[0] |
|
1294 |
pack_1 = packs.get_pack_by_name(name) |
|
1295 |
# the pack should be correctly initialised
|
|
3517.4.5
by Martin Pool
Correct use of packs._names in test_get_pack_by_name |
1296 |
sizes = packs._names[name] |
3221.12.4
by Robert Collins
Implement basic repository supporting external references. |
1297 |
rev_index = GraphIndex(packs._index_transport, name + '.rix', sizes[0]) |
1298 |
inv_index = GraphIndex(packs._index_transport, name + '.iix', sizes[1]) |
|
1299 |
txt_index = GraphIndex(packs._index_transport, name + '.tix', sizes[2]) |
|
1300 |
sig_index = GraphIndex(packs._index_transport, name + '.six', sizes[3]) |
|
2592.3.191
by Robert Collins
Give Pack responsibility for index naming, and two concrete classes - NewPack for new packs and ExistingPack for packs we read from disk. |
1301 |
self.assertEqual(pack_repo.ExistingPack(packs._pack_transport, |
2592.3.219
by Robert Collins
Review feedback. |
1302 |
name, rev_index, inv_index, txt_index, sig_index), pack_1) |
2592.3.176
by Robert Collins
Various pack refactorings. |
1303 |
# and the same instance should be returned on successive calls.
|
1304 |
self.assertTrue(pack_1 is packs.get_pack_by_name(name)) |
|
1305 |
||
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1306 |
def test_reload_pack_names_new_entry(self): |
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1307 |
tree, r, packs, revs = self.make_packs_and_alt_repo() |
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1308 |
names = packs.names() |
1309 |
# Add a new pack file into the repository
|
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1310 |
rev4 = tree.commit('four') |
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1311 |
new_names = tree.branch.repository._pack_collection.names() |
1312 |
new_name = set(new_names).difference(names) |
|
1313 |
self.assertEqual(1, len(new_name)) |
|
1314 |
new_name = new_name.pop() |
|
1315 |
# The old collection hasn't noticed yet
|
|
1316 |
self.assertEqual(names, packs.names()) |
|
3789.1.8
by John Arbash Meinel
Change the api of reload_pack_names(). |
1317 |
self.assertTrue(packs.reload_pack_names()) |
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1318 |
self.assertEqual(new_names, packs.names()) |
1319 |
# And the repository can access the new revision
|
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1320 |
self.assertEqual({rev4:(revs[-1],)}, r.get_parent_map([rev4])) |
3789.1.8
by John Arbash Meinel
Change the api of reload_pack_names(). |
1321 |
self.assertFalse(packs.reload_pack_names()) |
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1322 |
|
1323 |
def test_reload_pack_names_added_and_removed(self): |
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1324 |
tree, r, packs, revs = self.make_packs_and_alt_repo() |
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1325 |
names = packs.names() |
1326 |
# Now repack the whole thing
|
|
1327 |
tree.branch.repository.pack() |
|
1328 |
new_names = tree.branch.repository._pack_collection.names() |
|
1329 |
# The other collection hasn't noticed yet
|
|
1330 |
self.assertEqual(names, packs.names()) |
|
3789.1.8
by John Arbash Meinel
Change the api of reload_pack_names(). |
1331 |
self.assertTrue(packs.reload_pack_names()) |
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1332 |
self.assertEqual(new_names, packs.names()) |
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1333 |
self.assertEqual({revs[-1]:(revs[-2],)}, r.get_parent_map([revs[-1]])) |
3789.1.8
by John Arbash Meinel
Change the api of reload_pack_names(). |
1334 |
self.assertFalse(packs.reload_pack_names()) |
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1335 |
|
3789.2.20
by John Arbash Meinel
The autopack code can now trigger itself to retry when _copy_revision_texts fails. |
1336 |
def test_autopack_reloads_and_stops(self): |
1337 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1338 |
# After we have determined what needs to be autopacked, trigger a
|
|
1339 |
# full-pack via the other repo which will cause us to re-evaluate and
|
|
1340 |
# decide we don't need to do anything
|
|
1341 |
orig_execute = packs._execute_pack_operations |
|
1342 |
def _munged_execute_pack_ops(*args, **kwargs): |
|
1343 |
tree.branch.repository.pack() |
|
1344 |
return orig_execute(*args, **kwargs) |
|
1345 |
packs._execute_pack_operations = _munged_execute_pack_ops |
|
1346 |
packs._max_pack_count = lambda x: 1 |
|
1347 |
packs.pack_distribution = lambda x: [10] |
|
1348 |
self.assertFalse(packs.autopack()) |
|
1349 |
self.assertEqual(1, len(packs.names())) |
|
1350 |
self.assertEqual(tree.branch.repository._pack_collection.names(), |
|
1351 |
packs.names()) |
|
1352 |
||
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1353 |
|
1354 |
class TestPack(TestCaseWithTransport): |
|
1355 |
"""Tests for the Pack object."""
|
|
1356 |
||
1357 |
def assertCurrentlyEqual(self, left, right): |
|
1358 |
self.assertTrue(left == right) |
|
1359 |
self.assertTrue(right == left) |
|
1360 |
self.assertFalse(left != right) |
|
1361 |
self.assertFalse(right != left) |
|
1362 |
||
1363 |
def assertCurrentlyNotEqual(self, left, right): |
|
1364 |
self.assertFalse(left == right) |
|
1365 |
self.assertFalse(right == left) |
|
1366 |
self.assertTrue(left != right) |
|
1367 |
self.assertTrue(right != left) |
|
1368 |
||
1369 |
def test___eq____ne__(self): |
|
2592.3.191
by Robert Collins
Give Pack responsibility for index naming, and two concrete classes - NewPack for new packs and ExistingPack for packs we read from disk. |
1370 |
left = pack_repo.ExistingPack('', '', '', '', '', '') |
1371 |
right = pack_repo.ExistingPack('', '', '', '', '', '') |
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1372 |
self.assertCurrentlyEqual(left, right) |
1373 |
# change all attributes and ensure equality changes as we do.
|
|
1374 |
left.revision_index = 'a' |
|
1375 |
self.assertCurrentlyNotEqual(left, right) |
|
1376 |
right.revision_index = 'a' |
|
1377 |
self.assertCurrentlyEqual(left, right) |
|
1378 |
left.inventory_index = 'a' |
|
1379 |
self.assertCurrentlyNotEqual(left, right) |
|
1380 |
right.inventory_index = 'a' |
|
1381 |
self.assertCurrentlyEqual(left, right) |
|
1382 |
left.text_index = 'a' |
|
1383 |
self.assertCurrentlyNotEqual(left, right) |
|
1384 |
right.text_index = 'a' |
|
1385 |
self.assertCurrentlyEqual(left, right) |
|
1386 |
left.signature_index = 'a' |
|
1387 |
self.assertCurrentlyNotEqual(left, right) |
|
1388 |
right.signature_index = 'a' |
|
1389 |
self.assertCurrentlyEqual(left, right) |
|
1390 |
left.name = 'a' |
|
1391 |
self.assertCurrentlyNotEqual(left, right) |
|
1392 |
right.name = 'a' |
|
1393 |
self.assertCurrentlyEqual(left, right) |
|
1394 |
left.transport = 'a' |
|
1395 |
self.assertCurrentlyNotEqual(left, right) |
|
1396 |
right.transport = 'a' |
|
1397 |
self.assertCurrentlyEqual(left, right) |
|
2592.3.179
by Robert Collins
Generate the revision_index_map for packing during the core operation, from the pack objects. |
1398 |
|
1399 |
def test_file_name(self): |
|
2592.3.191
by Robert Collins
Give Pack responsibility for index naming, and two concrete classes - NewPack for new packs and ExistingPack for packs we read from disk. |
1400 |
pack = pack_repo.ExistingPack('', 'a_name', '', '', '', '') |
2592.3.179
by Robert Collins
Generate the revision_index_map for packing during the core operation, from the pack objects. |
1401 |
self.assertEqual('a_name.pack', pack.file_name()) |
2592.3.192
by Robert Collins
Move new revision index management to NewPack. |
1402 |
|
1403 |
||
1404 |
class TestNewPack(TestCaseWithTransport): |
|
1405 |
"""Tests for pack_repo.NewPack."""
|
|
1406 |
||
2592.3.193
by Robert Collins
Move hash tracking of new packs into NewPack. |
1407 |
def test_new_instance_attributes(self): |
2592.3.194
by Robert Collins
Output the revision index from NewPack.finish |
1408 |
upload_transport = self.get_transport('upload') |
1409 |
pack_transport = self.get_transport('pack') |
|
1410 |
index_transport = self.get_transport('index') |
|
1411 |
upload_transport.mkdir('.') |
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
1412 |
collection = pack_repo.RepositoryPackCollection( |
1413 |
repo=None, |
|
3830.3.1
by Martin Pool
NewPack should be constructed from the PackCollection, rather than attributes of it |
1414 |
transport=self.get_transport('.'), |
1415 |
index_transport=index_transport, |
|
1416 |
upload_transport=upload_transport, |
|
1417 |
pack_transport=pack_transport, |
|
1418 |
index_builder_class=BTreeBuilder, |
|
4241.6.8
by Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil
Add --development6-rich-root, disabling the legacy and unneeded development2 format, and activating the tests for CHK features disabled pending this format. (Robert Collins, John Arbash Meinel, Ian Clatworthy, Vincent Ladeuil) |
1419 |
index_class=BTreeGraphIndex, |
1420 |
use_chk_index=False) |
|
3830.3.1
by Martin Pool
NewPack should be constructed from the PackCollection, rather than attributes of it |
1421 |
pack = pack_repo.NewPack(collection) |
3735.1.1
by Robert Collins
Add development2 formats using BTree indices. |
1422 |
self.assertIsInstance(pack.revision_index, BTreeBuilder) |
1423 |
self.assertIsInstance(pack.inventory_index, BTreeBuilder) |
|
2929.3.5
by Vincent Ladeuil
New files, same warnings, same fixes. |
1424 |
self.assertIsInstance(pack._hash, type(osutils.md5())) |
2592.3.194
by Robert Collins
Output the revision index from NewPack.finish |
1425 |
self.assertTrue(pack.upload_transport is upload_transport) |
1426 |
self.assertTrue(pack.index_transport is index_transport) |
|
1427 |
self.assertTrue(pack.pack_transport is pack_transport) |
|
1428 |
self.assertEqual(None, pack.index_sizes) |
|
1429 |
self.assertEqual(20, len(pack.random_name)) |
|
1430 |
self.assertIsInstance(pack.random_name, str) |
|
1431 |
self.assertIsInstance(pack.start_time, float) |
|
2951.1.2
by Robert Collins
Partial refactoring of pack_repo to create a Packer object for packing. |
1432 |
|
1433 |
||
1434 |
class TestPacker(TestCaseWithTransport): |
|
1435 |
"""Tests for the packs repository Packer class."""
|
|
2951.1.10
by Robert Collins
Peer review feedback with Ian. |
1436 |
|
3824.2.4
by John Arbash Meinel
Add a test that ensures the pack ordering changes as part of calling .pack() |
1437 |
def test_pack_optimizes_pack_order(self): |
4617.8.1
by Robert Collins
Lock down another test assuming the default was a PackRepository. |
1438 |
builder = self.make_branch_builder('.', format="1.9") |
3824.2.4
by John Arbash Meinel
Add a test that ensures the pack ordering changes as part of calling .pack() |
1439 |
builder.start_series() |
1440 |
builder.build_snapshot('A', None, [ |
|
1441 |
('add', ('', 'root-id', 'directory', None)), |
|
1442 |
('add', ('f', 'f-id', 'file', 'content\n'))]) |
|
1443 |
builder.build_snapshot('B', ['A'], |
|
1444 |
[('modify', ('f-id', 'new-content\n'))]) |
|
1445 |
builder.build_snapshot('C', ['B'], |
|
1446 |
[('modify', ('f-id', 'third-content\n'))]) |
|
1447 |
builder.build_snapshot('D', ['C'], |
|
1448 |
[('modify', ('f-id', 'fourth-content\n'))]) |
|
1449 |
b = builder.get_branch() |
|
1450 |
b.lock_read() |
|
1451 |
builder.finish_series() |
|
1452 |
self.addCleanup(b.unlock) |
|
1453 |
# At this point, we should have 4 pack files available
|
|
1454 |
# Because of how they were built, they correspond to
|
|
1455 |
# ['D', 'C', 'B', 'A']
|
|
1456 |
packs = b.repository._pack_collection.packs |
|
1457 |
packer = pack_repo.Packer(b.repository._pack_collection, |
|
1458 |
packs, 'testing', |
|
1459 |
revision_ids=['B', 'C']) |
|
1460 |
# Now, when we are copying the B & C revisions, their pack files should
|
|
1461 |
# be moved to the front of the stack
|
|
3824.2.5
by Andrew Bennetts
Minor tweaks to comments etc. |
1462 |
# The new ordering moves B & C to the front of the .packs attribute,
|
1463 |
# and leaves the others in the original order.
|
|
3824.2.4
by John Arbash Meinel
Add a test that ensures the pack ordering changes as part of calling .pack() |
1464 |
new_packs = [packs[1], packs[2], packs[0], packs[3]] |
1465 |
new_pack = packer.pack() |
|
1466 |
self.assertEqual(new_packs, packer.packs) |
|
3146.6.1
by Aaron Bentley
InterDifferingSerializer shows a progress bar |
1467 |
|
1468 |
||
3777.5.4
by John Arbash Meinel
OptimisingPacker now sets the optimize flags for the indexes being built. |
1469 |
class TestOptimisingPacker(TestCaseWithTransport): |
1470 |
"""Tests for the OptimisingPacker class."""
|
|
1471 |
||
1472 |
def get_pack_collection(self): |
|
1473 |
repo = self.make_repository('.') |
|
1474 |
return repo._pack_collection |
|
1475 |
||
1476 |
def test_open_pack_will_optimise(self): |
|
1477 |
packer = pack_repo.OptimisingPacker(self.get_pack_collection(), |
|
1478 |
[], '.test') |
|
1479 |
new_pack = packer.open_pack() |
|
1480 |
self.assertIsInstance(new_pack, pack_repo.NewPack) |
|
1481 |
self.assertTrue(new_pack.revision_index._optimize_for_size) |
|
1482 |
self.assertTrue(new_pack.inventory_index._optimize_for_size) |
|
1483 |
self.assertTrue(new_pack.text_index._optimize_for_size) |
|
1484 |
self.assertTrue(new_pack.signature_index._optimize_for_size) |
|
4462.2.6
by Robert Collins
Cause StreamSink to partially pack repositories after cross format fetches when beneficial. |
1485 |
|
1486 |
||
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
1487 |
class TestCrossFormatPacks(TestCaseWithTransport): |
1488 |
||
1489 |
def log_pack(self, hint=None): |
|
1490 |
self.calls.append(('pack', hint)) |
|
1491 |
self.orig_pack(hint=hint) |
|
1492 |
if self.expect_hint: |
|
1493 |
self.assertTrue(hint) |
|
1494 |
||
1495 |
def run_stream(self, src_fmt, target_fmt, expect_pack_called): |
|
1496 |
self.expect_hint = expect_pack_called |
|
1497 |
self.calls = [] |
|
1498 |
source_tree = self.make_branch_and_tree('src', format=src_fmt) |
|
1499 |
source_tree.lock_write() |
|
1500 |
self.addCleanup(source_tree.unlock) |
|
1501 |
tip = source_tree.commit('foo') |
|
1502 |
target = self.make_repository('target', format=target_fmt) |
|
1503 |
target.lock_write() |
|
1504 |
self.addCleanup(target.unlock) |
|
1505 |
source = source_tree.branch.repository._get_source(target._format) |
|
1506 |
self.orig_pack = target.pack |
|
1507 |
target.pack = self.log_pack |
|
1508 |
search = target.search_missing_revision_ids( |
|
1509 |
source_tree.branch.repository, tip) |
|
1510 |
stream = source.get_stream(search) |
|
1511 |
from_format = source_tree.branch.repository._format |
|
1512 |
sink = target._get_sink() |
|
1513 |
sink.insert_stream(stream, from_format, []) |
|
1514 |
if expect_pack_called: |
|
1515 |
self.assertLength(1, self.calls) |
|
1516 |
else: |
|
1517 |
self.assertLength(0, self.calls) |
|
1518 |
||
1519 |
def run_fetch(self, src_fmt, target_fmt, expect_pack_called): |
|
1520 |
self.expect_hint = expect_pack_called |
|
1521 |
self.calls = [] |
|
1522 |
source_tree = self.make_branch_and_tree('src', format=src_fmt) |
|
1523 |
source_tree.lock_write() |
|
1524 |
self.addCleanup(source_tree.unlock) |
|
1525 |
tip = source_tree.commit('foo') |
|
1526 |
target = self.make_repository('target', format=target_fmt) |
|
1527 |
target.lock_write() |
|
1528 |
self.addCleanup(target.unlock) |
|
1529 |
source = source_tree.branch.repository |
|
1530 |
self.orig_pack = target.pack |
|
1531 |
target.pack = self.log_pack |
|
1532 |
target.fetch(source) |
|
1533 |
if expect_pack_called: |
|
1534 |
self.assertLength(1, self.calls) |
|
1535 |
else: |
|
1536 |
self.assertLength(0, self.calls) |
|
1537 |
||
1538 |
def test_sink_format_hint_no(self): |
|
1539 |
# When the target format says packing makes no difference, pack is not
|
|
1540 |
# called.
|
|
1541 |
self.run_stream('1.9', 'rich-root-pack', False) |
|
1542 |
||
1543 |
def test_sink_format_hint_yes(self): |
|
1544 |
# When the target format says packing makes a difference, pack is
|
|
1545 |
# called.
|
|
1546 |
self.run_stream('1.9', '2a', True) |
|
1547 |
||
1548 |
def test_sink_format_same_no(self): |
|
1549 |
# When the formats are the same, pack is not called.
|
|
1550 |
self.run_stream('2a', '2a', False) |
|
1551 |
||
1552 |
def test_IDS_format_hint_no(self): |
|
1553 |
# When the target format says packing makes no difference, pack is not
|
|
1554 |
# called.
|
|
1555 |
self.run_fetch('1.9', 'rich-root-pack', False) |
|
1556 |
||
1557 |
def test_IDS_format_hint_yes(self): |
|
1558 |
# When the target format says packing makes a difference, pack is
|
|
1559 |
# called.
|
|
1560 |
self.run_fetch('1.9', '2a', True) |
|
1561 |
||
1562 |
def test_IDS_format_same_no(self): |
|
1563 |
# When the formats are the same, pack is not called.
|
|
1564 |
self.run_fetch('2a', '2a', False) |