bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2006-2012, 2016 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 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
27 |
import breezy |
28 |
from breezy.errors import ( |
|
|
5651.3.1
by Jelmer Vernooij
Add RepositoryFormatRegistry. |
29 |
UnknownFormatError, |
30 |
UnsupportedFormatError, |
|
31 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
32 |
from breezy import ( |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
33 |
tests, |
|
5609.9.1
by Martin
Blindly change all users of get_transport to address the function via the transport module |
34 |
transport, |
|
6670.4.1
by Jelmer Vernooij
Update imports. |
35 |
)
|
36 |
from breezy.bzr import ( |
|
37 |
bzrdir, |
|
38 |
btree_index, |
|
39 |
inventory, |
|
40 |
repository as bzrrepository, |
|
41 |
versionedfile, |
|
42 |
vf_repository, |
|
|
6341.1.4
by Jelmer Vernooij
Move more functionality to vf_search. |
43 |
vf_search, |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
44 |
)
|
|
6670.4.1
by Jelmer Vernooij
Update imports. |
45 |
from breezy.bzr.btree_index import BTreeBuilder, BTreeGraphIndex |
46 |
from breezy.bzr.index import GraphIndex |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
47 |
from breezy.repository import RepositoryFormat |
48 |
from breezy.tests import ( |
|
|
2670.3.5
by Andrew Bennetts
Remove get_stream_as_bytes from KnitVersionedFile's API, make it a function in knitrepo.py instead. |
49 |
TestCase, |
50 |
TestCaseWithTransport, |
|
51 |
)
|
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
52 |
from breezy import ( |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
53 |
controldir, |
|
2535.3.41
by Andrew Bennetts
Add tests for InterRemoteToOther.is_compatible. |
54 |
errors, |
|
2929.3.5
by Vincent Ladeuil
New files, same warnings, same fixes. |
55 |
osutils, |
|
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
56 |
repository, |
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
57 |
revision as _mod_revision, |
|
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
58 |
upgrade, |
59 |
workingtree, |
|
60 |
)
|
|
|
6670.4.5
by Jelmer Vernooij
Move breezy.repofmt contents to breezy.bzr. |
61 |
from breezy.bzr import ( |
|
3735.42.5
by John Arbash Meinel
Change the tests so we now just use a direct test that _get_source is |
62 |
groupcompress_repo, |
63 |
knitrepo, |
|
|
5757.2.2
by Jelmer Vernooij
Fix imports. |
64 |
knitpack_repo, |
|
3735.42.5
by John Arbash Meinel
Change the tests so we now just use a direct test that _get_source is |
65 |
pack_repo, |
66 |
)
|
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
67 |
|
68 |
||
69 |
class TestDefaultFormat(TestCase): |
|
70 |
||
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
71 |
def test_get_set_default_format(self): |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
72 |
old_default = controldir.format_registry.get('default') |
|
2204.5.3
by Aaron Bentley
zap old repository default handling |
73 |
private_default = old_default().repository_format.__class__ |
|
5651.3.2
by Jelmer Vernooij
Fix deprecation warnings in test suite. |
74 |
old_format = repository.format_registry.get_default() |
|
1910.2.33
by Aaron Bentley
Fix default format test |
75 |
self.assertTrue(isinstance(old_format, private_default)) |
|
2204.5.3
by Aaron Bentley
zap old repository default handling |
76 |
def make_sample_bzrdir(): |
77 |
my_bzrdir = bzrdir.BzrDirMetaFormat1() |
|
78 |
my_bzrdir.repository_format = SampleRepositoryFormat() |
|
79 |
return my_bzrdir |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
80 |
controldir.format_registry.remove('default') |
81 |
controldir.format_registry.register('sample', make_sample_bzrdir, '') |
|
82 |
controldir.format_registry.set_default('sample') |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
83 |
# creating a repository should now create an instrumented dir.
|
84 |
try: |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
85 |
# the default branch format is used by the meta dir format
|
86 |
# which is not the default bzrdir format at this point
|
|
|
1685.1.63
by Martin Pool
Small Transport fixups |
87 |
dir = bzrdir.BzrDirMetaFormat1().initialize('memory:///') |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
88 |
result = dir.create_repository() |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
89 |
self.assertEqual(result, 'A bzr repository dir') |
|
2241.1.1
by Martin Pool
Change RepositoryFormat to use a Registry rather than ad-hoc dictionary |
90 |
finally: |
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
91 |
controldir.format_registry.remove('default') |
92 |
controldir.format_registry.remove('sample') |
|
93 |
controldir.format_registry.register('default', old_default, '') |
|
|
5651.3.2
by Jelmer Vernooij
Fix deprecation warnings in test suite. |
94 |
self.assertIsInstance(repository.format_registry.get_default(), |
|
2204.5.3
by Aaron Bentley
zap old repository default handling |
95 |
old_format.__class__) |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
96 |
|
97 |
||
|
6653.2.1
by Jelmer Vernooij
Move bzr-specific repository code out of breezy.bzrrepository. |
98 |
class SampleRepositoryFormat(bzrrepository.RepositoryFormatMetaDir): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
99 |
"""A sample format |
100 |
||
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
101 |
this format is initializable, unsupported to aid in testing the
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
102 |
open and open(unsupported=True) routines.
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
103 |
"""
|
104 |
||
|
6349.2.6
by Jelmer Vernooij
Add test for RepositoryFormatMetaDir.from_string. |
105 |
@classmethod
|
106 |
def get_format_string(cls): |
|
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
107 |
"""See RepositoryFormat.get_format_string().""" |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
108 |
return b"Sample .bzr repository format." |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
109 |
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
110 |
def initialize(self, a_controldir, shared=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
111 |
"""Initialize a repository in a BzrDir""" |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
112 |
t = a_controldir.get_repository_transport(self) |
|
1955.3.13
by John Arbash Meinel
Run the full test suite, and fix up any deprecation warnings. |
113 |
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. |
114 |
return 'A bzr repository dir' |
115 |
||
116 |
def is_supported(self): |
|
117 |
return False |
|
118 |
||
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
119 |
def open(self, a_controldir, _found=False): |
|
1534.4.40
by Robert Collins
Add RepositoryFormats and allow bzrdir.open or create _repository to be used. |
120 |
return "opened repository." |
|
1534.4.41
by Robert Collins
Branch now uses BzrDir reasonably sanely. |
121 |
|
122 |
||
|
5651.3.5
by Jelmer Vernooij
add tests for 'extra' repository formats. |
123 |
class SampleExtraRepositoryFormat(repository.RepositoryFormat): |
124 |
"""A sample format that can not be used in a metadir |
|
125 |
||
126 |
"""
|
|
127 |
||
128 |
def get_format_string(self): |
|
129 |
raise NotImplementedError |
|
130 |
||
131 |
||
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
132 |
class TestRepositoryFormat(TestCaseWithTransport): |
133 |
"""Tests for the Repository format detection used by the bzr meta dir facility.BzrBranchFormat facility.""" |
|
134 |
||
135 |
def test_find_format(self): |
|
136 |
# is the right format object found for a repository?
|
|
137 |
# create a branch with a few known format objects.
|
|
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
138 |
# this is not quite the same as
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
139 |
self.build_tree(["foo/", "bar/"]) |
140 |
def check_format(format, url): |
|
|
6746.2.1
by Jelmer Vernooij
Rename matchingbzrdir to matchingcontroldir. |
141 |
dir = format._matchingcontroldir.initialize(url) |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
142 |
format.initialize(dir) |
|
6083.1.1
by Jelmer Vernooij
Use get_transport_from_{url,path} in more places. |
143 |
t = transport.get_transport_from_path(url) |
|
6653.2.2
by Jelmer Vernooij
Fix imports. |
144 |
found_format = bzrrepository.RepositoryFormatMetaDir.find_format(dir) |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
145 |
self.assertIsInstance(found_format, format.__class__) |
|
5582.10.54
by Jelmer Vernooij
Use default format rather than RepositoryFormat7. |
146 |
check_format(repository.format_registry.get_default(), "bar") |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
147 |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
148 |
def test_find_format_no_repository(self): |
149 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
150 |
self.assertRaises(errors.NoRepositoryPresent, |
|
|
6653.2.2
by Jelmer Vernooij
Fix imports. |
151 |
bzrrepository.RepositoryFormatMetaDir.find_format, |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
152 |
dir) |
153 |
||
|
6349.2.6
by Jelmer Vernooij
Add test for RepositoryFormatMetaDir.from_string. |
154 |
def test_from_string(self): |
155 |
self.assertIsInstance( |
|
156 |
SampleRepositoryFormat.from_string( |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
157 |
b"Sample .bzr repository format."), |
|
6349.2.6
by Jelmer Vernooij
Add test for RepositoryFormatMetaDir.from_string. |
158 |
SampleRepositoryFormat) |
|
6213.1.54
by Jelmer Vernooij
Fix tests. |
159 |
self.assertRaises(AssertionError, |
|
6349.2.6
by Jelmer Vernooij
Add test for RepositoryFormatMetaDir.from_string. |
160 |
SampleRepositoryFormat.from_string, |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
161 |
b"Different .bzr repository format.") |
|
6349.2.6
by Jelmer Vernooij
Add test for RepositoryFormatMetaDir.from_string. |
162 |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
163 |
def test_find_format_unknown_format(self): |
164 |
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
165 |
SampleRepositoryFormat().initialize(dir) |
|
166 |
self.assertRaises(UnknownFormatError, |
|
|
6653.2.2
by Jelmer Vernooij
Fix imports. |
167 |
bzrrepository.RepositoryFormatMetaDir.find_format, |
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
168 |
dir) |
169 |
||
|
6213.1.16
by Jelmer Vernooij
Feature support in repository. |
170 |
def test_find_format_with_features(self): |
171 |
tree = self.make_branch_and_tree('.', format='2a') |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
172 |
tree.branch.repository.update_feature_flags({b"name": b"necessity"}) |
|
6653.6.4
by Jelmer Vernooij
Merge trunk. |
173 |
found_format = bzrrepository.RepositoryFormatMetaDir.find_format(tree.controldir) |
|
6653.2.2
by Jelmer Vernooij
Fix imports. |
174 |
self.assertIsInstance(found_format, bzrrepository.RepositoryFormatMetaDir) |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
175 |
self.assertEqual(found_format.features.get(b"name"), b"necessity") |
|
6731.1.3
by Jelmer Vernooij
Move MissingFeature error to breezy.bzr.bzrdir. |
176 |
self.assertRaises(bzrdir.MissingFeature, found_format.check_support_status, |
|
6213.1.32
by Jelmer Vernooij
Fix check support status. |
177 |
True) |
|
6653.2.2
by Jelmer Vernooij
Fix imports. |
178 |
self.addCleanup(bzrrepository.RepositoryFormatMetaDir.unregister_feature, |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
179 |
b"name") |
180 |
bzrrepository.RepositoryFormatMetaDir.register_feature(b"name") |
|
|
6213.1.32
by Jelmer Vernooij
Fix check support status. |
181 |
found_format.check_support_status(True) |
|
6213.1.16
by Jelmer Vernooij
Feature support in repository. |
182 |
|
|
1534.4.47
by Robert Collins
Split out repository into .bzr/repository |
183 |
|
|
5651.3.1
by Jelmer Vernooij
Add RepositoryFormatRegistry. |
184 |
class TestRepositoryFormatRegistry(TestCase): |
185 |
||
186 |
def setUp(self): |
|
187 |
super(TestRepositoryFormatRegistry, self).setUp() |
|
188 |
self.registry = repository.RepositoryFormatRegistry() |
|
189 |
||
190 |
def test_register_unregister_format(self): |
|
191 |
format = SampleRepositoryFormat() |
|
192 |
self.registry.register(format) |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
193 |
self.assertEqual(format, self.registry.get(b"Sample .bzr repository format.")) |
|
5651.3.1
by Jelmer Vernooij
Add RepositoryFormatRegistry. |
194 |
self.registry.remove(format) |
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
195 |
self.assertRaises(KeyError, self.registry.get, b"Sample .bzr repository format.") |
|
5651.3.1
by Jelmer Vernooij
Add RepositoryFormatRegistry. |
196 |
|
|
5651.3.2
by Jelmer Vernooij
Fix deprecation warnings in test suite. |
197 |
def test_get_all(self): |
|
5651.3.1
by Jelmer Vernooij
Add RepositoryFormatRegistry. |
198 |
format = SampleRepositoryFormat() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
199 |
self.assertEqual([], self.registry._get_all()) |
|
5651.3.1
by Jelmer Vernooij
Add RepositoryFormatRegistry. |
200 |
self.registry.register(format) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
201 |
self.assertEqual([format], self.registry._get_all()) |
|
5651.3.5
by Jelmer Vernooij
add tests for 'extra' repository formats. |
202 |
|
203 |
def test_register_extra(self): |
|
204 |
format = SampleExtraRepositoryFormat() |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
205 |
self.assertEqual([], self.registry._get_all()) |
|
5651.3.5
by Jelmer Vernooij
add tests for 'extra' repository formats. |
206 |
self.registry.register_extra(format) |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
207 |
self.assertEqual([format], self.registry._get_all()) |
|
5651.3.5
by Jelmer Vernooij
add tests for 'extra' repository formats. |
208 |
|
209 |
def test_register_extra_lazy(self): |
|
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
210 |
self.assertEqual([], self.registry._get_all()) |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
211 |
self.registry.register_extra_lazy("breezy.tests.test_repository", |
|
5651.3.5
by Jelmer Vernooij
add tests for 'extra' repository formats. |
212 |
"SampleExtraRepositoryFormat") |
|
5651.3.7
by Jelmer Vernooij
Fix tests. |
213 |
formats = self.registry._get_all() |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
214 |
self.assertEqual(1, len(formats)) |
|
5651.3.5
by Jelmer Vernooij
add tests for 'extra' repository formats. |
215 |
self.assertIsInstance(formats[0], SampleExtraRepositoryFormat) |
|
5651.3.1
by Jelmer Vernooij
Add RepositoryFormatRegistry. |
216 |
|
217 |
||
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
218 |
class TestFormatKnit1(TestCaseWithTransport): |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
219 |
|
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
220 |
def test_attribute__fetch_order(self): |
221 |
"""Knits need topological data insertion.""" |
|
222 |
repo = self.make_repository('.', |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
223 |
format=controldir.format_registry.get('knit')()) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
224 |
self.assertEqual('topological', repo._format._fetch_order) |
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
225 |
|
226 |
def test_attribute__fetch_uses_deltas(self): |
|
227 |
"""Knits reuse deltas.""" |
|
228 |
repo = self.make_repository('.', |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
229 |
format=controldir.format_registry.get('knit')()) |
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
230 |
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 |
231 |
|
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
232 |
def test_disk_layout(self): |
233 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
234 |
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 |
235 |
# in case of side effects of locking.
|
236 |
repo.lock_write() |
|
237 |
repo.unlock() |
|
238 |
# we want:
|
|
239 |
# format 'Bazaar-NG Knit Repository Format 1'
|
|
|
1553.5.62
by Martin Pool
Add tests that MetaDir repositories use LockDirs |
240 |
# 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 |
241 |
# inventory.weave == empty_weave
|
242 |
# empty revision-store directory
|
|
243 |
# empty weaves directory
|
|
244 |
t = control.get_repository_transport(None) |
|
|
6973.6.3
by Jelmer Vernooij
More fixes. |
245 |
with t.get('format') as f: |
246 |
self.assertEqualDiff(b'Bazaar-NG Knit Repository Format 1', |
|
247 |
f.read()) |
|
|
1553.5.57
by Martin Pool
[merge] sync from bzr.dev |
248 |
# XXX: no locks left when unlocked at the moment
|
249 |
# 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 |
250 |
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. |
251 |
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. |
252 |
# Check per-file knits.
|
253 |
branch = control.create_branch() |
|
254 |
tree = control.create_workingtree() |
|
|
6973.6.3
by Jelmer Vernooij
More fixes. |
255 |
tree.add(['foo'], [b'Nasty-IdC:'], ['file']) |
256 |
tree.put_file_bytes_non_atomic('foo', b'') |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
257 |
tree.commit('1st post', rev_id=b'foo') |
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
258 |
self.assertHasKnit(t, b'knits/e8/%254easty-%2549d%2543%253a', |
259 |
b'\nfoo fulltext 0 81 :') |
|
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
260 |
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
261 |
def assertHasKnit(self, t, knit_name, extra_content=b''): |
|
1654.1.3
by Robert Collins
Refactor repository knit tests slightly to remove duplication - add a assertHasKnit method. |
262 |
"""Assert that knit_name exists on t.""" |
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
263 |
self.assertEqualDiff(b'# 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. |
264 |
t.get(knit_name + '.kndx').read()) |
265 |
||
|
1563.2.35
by Robert Collins
cleanup deprecation warnings and finish conversion so the inventory is knit based too. |
266 |
def check_knits(self, t): |
267 |
"""check knit content for a repository.""" |
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
268 |
self.assertHasKnit(t, b'inventory') |
269 |
self.assertHasKnit(t, b'revisions') |
|
270 |
self.assertHasKnit(t, b'signatures') |
|
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
271 |
|
272 |
def test_shared_disk_layout(self): |
|
273 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
274 |
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 |
275 |
# we want:
|
276 |
# format 'Bazaar-NG Knit Repository Format 1'
|
|
|
1553.5.62
by Martin Pool
Add tests that MetaDir repositories use LockDirs |
277 |
# 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 |
278 |
# inventory.weave == empty_weave
|
279 |
# empty revision-store directory
|
|
280 |
# empty weaves directory
|
|
281 |
# a 'shared-storage' marker file.
|
|
282 |
t = control.get_repository_transport(None) |
|
283 |
self.assertEqualDiff('Bazaar-NG Knit Repository Format 1', |
|
284 |
t.get('format').read()) |
|
|
1553.5.57
by Martin Pool
[merge] sync from bzr.dev |
285 |
# XXX: no locks left when unlocked at the moment
|
286 |
# 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 |
287 |
self.assertEqualDiff('', t.get('shared-storage').read()) |
288 |
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. |
289 |
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 |
290 |
|
291 |
def test_shared_no_tree_disk_layout(self): |
|
292 |
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url()) |
|
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
293 |
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 |
294 |
repo.set_make_working_trees(False) |
295 |
# we want:
|
|
296 |
# format 'Bazaar-NG Knit Repository Format 1'
|
|
297 |
# lock ''
|
|
298 |
# inventory.weave == empty_weave
|
|
299 |
# empty revision-store directory
|
|
300 |
# empty weaves directory
|
|
301 |
# a 'shared-storage' marker file.
|
|
302 |
t = control.get_repository_transport(None) |
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
303 |
self.assertEqualDiff(b'Bazaar-NG Knit Repository Format 1', |
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
304 |
t.get('format').read()) |
|
1553.5.57
by Martin Pool
[merge] sync from bzr.dev |
305 |
# XXX: no locks left when unlocked at the moment
|
306 |
# self.assertEqualDiff('', t.get('lock').read())
|
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
307 |
self.assertEqualDiff(b'', t.get('shared-storage').read()) |
308 |
self.assertEqualDiff(b'', t.get('no-working-trees').read()) |
|
|
1556.1.3
by Robert Collins
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids |
309 |
repo.set_make_working_trees(True) |
310 |
self.assertFalse(t.has('no-working-trees')) |
|
311 |
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. |
312 |
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 |
313 |
|
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
314 |
def test_deserialise_sets_root_revision(self): |
315 |
"""We must have a inventory.root.revision |
|
316 |
||
317 |
Old versions of the XML5 serializer did not set the revision_id for
|
|
318 |
the whole inventory. So we grab the one from the expected text. Which
|
|
319 |
is valid when the api is not being abused.
|
|
320 |
"""
|
|
321 |
repo = self.make_repository('.', |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
322 |
format=controldir.format_registry.get('knit')()) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
323 |
inv_xml = b'<inventory format="5">\n</inventory>\n' |
324 |
inv = repo._deserialise_inventory(b'test-rev-id', inv_xml) |
|
325 |
self.assertEqual(b'test-rev-id', inv.root.revision) |
|
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
326 |
|
327 |
def test_deserialise_uses_global_revision_id(self): |
|
328 |
"""If it is set, then we re-use the global revision id""" |
|
329 |
repo = self.make_repository('.', |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
330 |
format=controldir.format_registry.get('knit')()) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
331 |
inv_xml = (b'<inventory format="5" revision_id="other-rev-id">\n' |
332 |
b'</inventory>\n') |
|
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
333 |
# Arguably, the deserialise_inventory should detect a mismatch, and
|
334 |
# raise an error, rather than silently using one revision_id over the
|
|
335 |
# other.
|
|
|
4988.3.3
by Jelmer Vernooij
rename Repository.deserialise_inventory to Repository._deserialise_inventory. |
336 |
self.assertRaises(AssertionError, repo._deserialise_inventory, |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
337 |
b'test-rev-id', inv_xml) |
338 |
inv = repo._deserialise_inventory(b'other-rev-id', inv_xml) |
|
339 |
self.assertEqual(b'other-rev-id', inv.root.revision) |
|
|
2917.2.1
by John Arbash Meinel
Fix bug #152360. The xml5 serializer should be using |
340 |
|
|
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
341 |
def test_supports_external_lookups(self): |
342 |
repo = self.make_repository('.', |
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
343 |
format=controldir.format_registry.get('knit')()) |
|
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
344 |
self.assertFalse(repo._format.supports_external_lookups) |
345 |
||
|
2535.3.53
by Andrew Bennetts
Remove get_stream_as_bytes from KnitVersionedFile's API, make it a function in knitrepo.py instead. |
346 |
|
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
347 |
class DummyRepository(object): |
348 |
"""A dummy repository for testing.""" |
|
349 |
||
|
3452.2.11
by Andrew Bennetts
Merge thread. |
350 |
_format = None |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
351 |
_serializer = None |
352 |
||
353 |
def supports_rich_root(self): |
|
|
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
354 |
if self._format is not None: |
355 |
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. |
356 |
return False |
357 |
||
|
3709.5.10
by Andrew Bennetts
Fix test failure caused by missing attributes on DummyRepository. |
358 |
def get_graph(self): |
359 |
raise NotImplementedError |
|
360 |
||
361 |
def get_parent_map(self, revision_ids): |
|
362 |
raise NotImplementedError |
|
363 |
||
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
364 |
|
365 |
class InterDummy(repository.InterRepository): |
|
366 |
"""An inter-repository optimised code path for DummyRepository. |
|
367 |
||
368 |
This is for use during testing where we use DummyRepository as repositories
|
|
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
369 |
so that none of the default regsitered inter-repository classes will
|
|
2818.4.2
by Robert Collins
Review feedback. |
370 |
MATCH.
|
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
371 |
"""
|
372 |
||
373 |
@staticmethod
|
|
374 |
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. |
375 |
"""InterDummy is compatible with DummyRepository.""" |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
376 |
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. |
377 |
isinstance(repo_target, DummyRepository)) |
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
378 |
|
379 |
||
|
1534.1.27
by Robert Collins
Start InterRepository with InterRepository.get. |
380 |
class TestInterRepository(TestCaseWithTransport): |
381 |
||
382 |
def test_get_default_inter_repository(self): |
|
383 |
# test that the InterRepository.get(repo_a, repo_b) probes
|
|
384 |
# for a inter_repo class where is_compatible(repo_a, repo_b) returns
|
|
385 |
# true and returns a default inter_repo otherwise.
|
|
386 |
# This also tests that the default registered optimised interrepository
|
|
387 |
# classes do not barf inappropriately when a surprising repository type
|
|
388 |
# 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. |
389 |
dummy_a = DummyRepository() |
|
5815.4.19
by Jelmer Vernooij
Fix test failures. |
390 |
dummy_a._format = RepositoryFormat() |
391 |
dummy_a._format.supports_full_versioned_files = True |
|
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
392 |
dummy_b = DummyRepository() |
|
5815.4.19
by Jelmer Vernooij
Fix test failures. |
393 |
dummy_b._format = RepositoryFormat() |
394 |
dummy_b._format.supports_full_versioned_files = True |
|
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
395 |
self.assertGetsDefaultInterRepository(dummy_a, dummy_b) |
396 |
||
397 |
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. |
398 |
"""Asserts that InterRepository.get(repo_a, repo_b) -> the default. |
|
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
399 |
|
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
400 |
The effective default is now InterSameDataRepository because there is
|
401 |
no actual sane default in the presence of incompatible data models.
|
|
402 |
"""
|
|
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
403 |
inter_repo = repository.InterRepository.get(repo_a, repo_b) |
|
5815.4.19
by Jelmer Vernooij
Fix test failures. |
404 |
self.assertEqual(vf_repository.InterSameDataRepository, |
|
1534.1.27
by Robert Collins
Start InterRepository with InterRepository.get. |
405 |
inter_repo.__class__) |
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
406 |
self.assertEqual(repo_a, inter_repo.source) |
407 |
self.assertEqual(repo_b, inter_repo.target) |
|
408 |
||
409 |
def test_register_inter_repository_class(self): |
|
410 |
# test that a optimised code path provider - a
|
|
411 |
# InterRepository subclass can be registered and unregistered
|
|
412 |
# and that it is correctly selected when given a repository
|
|
413 |
# pair that it returns true on for the is_compatible static method
|
|
414 |
# check
|
|
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
415 |
dummy_a = DummyRepository() |
|
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
416 |
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. |
417 |
dummy_b = DummyRepository() |
|
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
418 |
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. |
419 |
repo = self.make_repository('.') |
420 |
# hack dummies to look like repo somewhat.
|
|
421 |
dummy_a._serializer = repo._serializer |
|
|
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
422 |
dummy_a._format.supports_tree_reference = repo._format.supports_tree_reference |
423 |
dummy_a._format.rich_root_data = repo._format.rich_root_data |
|
|
5815.4.19
by Jelmer Vernooij
Fix test failures. |
424 |
dummy_a._format.supports_full_versioned_files = repo._format.supports_full_versioned_files |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
425 |
dummy_b._serializer = repo._serializer |
|
4606.4.1
by Robert Collins
Prepare test_repository's inter_repository tests for 2a. |
426 |
dummy_b._format.supports_tree_reference = repo._format.supports_tree_reference |
427 |
dummy_b._format.rich_root_data = repo._format.rich_root_data |
|
|
5815.4.19
by Jelmer Vernooij
Fix test failures. |
428 |
dummy_b._format.supports_full_versioned_files = repo._format.supports_full_versioned_files |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
429 |
repository.InterRepository.register_optimiser(InterDummy) |
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
430 |
try: |
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
431 |
# we should get the default for something InterDummy returns False
|
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
432 |
# to
|
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
433 |
self.assertFalse(InterDummy.is_compatible(dummy_a, repo)) |
434 |
self.assertGetsDefaultInterRepository(dummy_a, repo) |
|
435 |
# and we should get an InterDummy for a pair it 'likes'
|
|
436 |
self.assertTrue(InterDummy.is_compatible(dummy_a, dummy_b)) |
|
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
437 |
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. |
438 |
self.assertEqual(InterDummy, inter_repo.__class__) |
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
439 |
self.assertEqual(dummy_a, inter_repo.source) |
440 |
self.assertEqual(dummy_b, inter_repo.target) |
|
441 |
finally: |
|
|
2305.2.3
by Andrew Bennetts
Bring across test_repository improvements from the hpss branch to fix the last test failures. |
442 |
repository.InterRepository.unregister_optimiser(InterDummy) |
|
1534.1.28
by Robert Collins
Allow for optimised InterRepository selection. |
443 |
# now we should get the default InterRepository object again.
|
444 |
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. |
445 |
|
|
2241.1.17
by Martin Pool
Restore old InterWeave tests |
446 |
|
|
5671.4.2
by Jelmer Vernooij
Use stub formats to test CopyConverter. |
447 |
class TestRepositoryFormat1(knitrepo.RepositoryFormatKnit1): |
448 |
||
|
6213.1.16
by Jelmer Vernooij
Feature support in repository. |
449 |
@classmethod
|
450 |
def get_format_string(cls): |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
451 |
return b"Test Format 1" |
|
5671.4.2
by Jelmer Vernooij
Use stub formats to test CopyConverter. |
452 |
|
453 |
||
454 |
class TestRepositoryFormat2(knitrepo.RepositoryFormatKnit1): |
|
455 |
||
|
6213.1.16
by Jelmer Vernooij
Feature support in repository. |
456 |
@classmethod
|
457 |
def get_format_string(cls): |
|
|
6855.2.2
by Jelmer Vernooij
Format strings are bytes. |
458 |
return b"Test Format 2" |
|
5671.4.2
by Jelmer Vernooij
Use stub formats to test CopyConverter. |
459 |
|
460 |
||
|
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. |
461 |
class TestRepositoryConverter(TestCaseWithTransport): |
462 |
||
463 |
def test_convert_empty(self): |
|
|
5671.4.2
by Jelmer Vernooij
Use stub formats to test CopyConverter. |
464 |
source_format = TestRepositoryFormat1() |
465 |
target_format = TestRepositoryFormat2() |
|
466 |
repository.format_registry.register(source_format) |
|
467 |
self.addCleanup(repository.format_registry.remove, |
|
468 |
source_format) |
|
469 |
repository.format_registry.register(target_format) |
|
470 |
self.addCleanup(repository.format_registry.remove, |
|
471 |
target_format) |
|
|
5609.9.4
by Vincent Ladeuil
Use self.get_transport instead of transport.get_transport where possible. |
472 |
t = self.get_transport() |
|
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. |
473 |
t.mkdir('repository') |
474 |
repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository') |
|
|
5671.4.2
by Jelmer Vernooij
Use stub formats to test CopyConverter. |
475 |
repo = TestRepositoryFormat1().initialize(repo_dir) |
|
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. |
476 |
converter = repository.CopyConverter(target_format) |
|
6861.4.1
by Jelmer Vernooij
Make progress bars context managers. |
477 |
with breezy.ui.ui_factory.nested_progress_bar() as pb: |
|
1594.1.3
by Robert Collins
Fixup pb usage to use nested_progress_bar. |
478 |
converter.convert(repo, pb) |
|
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. |
479 |
repo = repo_dir.open_repository() |
480 |
self.assertTrue(isinstance(target_format, repo._format.__class__)) |
|
|
1843.2.5
by Aaron Bentley
Add test of _unescape_xml |
481 |
|
482 |
||
|
2255.2.211
by Robert Collins
Remove knit2 repository format- it has never been supported. |
483 |
class TestRepositoryFormatKnit3(TestCaseWithTransport): |
|
1910.2.13
by Aaron Bentley
Start work on converter |
484 |
|
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
485 |
def test_attribute__fetch_order(self): |
486 |
"""Knits need topological data insertion.""" |
|
487 |
format = bzrdir.BzrDirMetaFormat1() |
|
488 |
format.repository_format = knitrepo.RepositoryFormatKnit3() |
|
489 |
repo = self.make_repository('.', format=format) |
|
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
490 |
self.assertEqual('topological', repo._format._fetch_order) |
|
3565.3.1
by Robert Collins
* The generic fetch code now uses two attributes on Repository objects |
491 |
|
492 |
def test_attribute__fetch_uses_deltas(self): |
|
493 |
"""Knits reuse deltas.""" |
|
494 |
format = bzrdir.BzrDirMetaFormat1() |
|
495 |
format.repository_format = knitrepo.RepositoryFormatKnit3() |
|
496 |
repo = self.make_repository('.', format=format) |
|
|
4053.1.4
by Robert Collins
Move the fetch control attributes from Repository to RepositoryFormat. |
497 |
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 |
498 |
|
|
1910.2.13
by Aaron Bentley
Start work on converter |
499 |
def test_convert(self): |
500 |
"""Ensure the upgrade adds weaves for roots""" |
|
|
1910.2.35
by Aaron Bentley
Better fix for convesion test |
501 |
format = bzrdir.BzrDirMetaFormat1() |
|
2241.1.6
by Martin Pool
Move Knit repositories into the submodule bzrlib.repofmt.knitrepo and |
502 |
format.repository_format = knitrepo.RepositoryFormatKnit1() |
|
1910.2.35
by Aaron Bentley
Better fix for convesion test |
503 |
tree = self.make_branch_and_tree('.', format) |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
504 |
tree.commit("Dull commit", rev_id=b"dull") |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
505 |
revision_tree = tree.branch.repository.revision_tree(b'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. |
506 |
revision_tree.lock_read() |
507 |
try: |
|
508 |
self.assertRaises(errors.NoSuchFile, revision_tree.get_file_lines, |
|
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
509 |
u'', revision_tree.get_root_id()) |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
510 |
finally: |
511 |
revision_tree.unlock() |
|
|
1910.2.13
by Aaron Bentley
Start work on converter |
512 |
format = bzrdir.BzrDirMetaFormat1() |
|
2255.2.211
by Robert Collins
Remove knit2 repository format- it has never been supported. |
513 |
format.repository_format = knitrepo.RepositoryFormatKnit3() |
|
1910.2.13
by Aaron Bentley
Start work on converter |
514 |
upgrade.Convert('.', format) |
|
1910.2.27
by Aaron Bentley
Fixed conversion test |
515 |
tree = workingtree.WorkingTree.open('.') |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
516 |
revision_tree = tree.branch.repository.revision_tree(b'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. |
517 |
revision_tree.lock_read() |
518 |
try: |
|
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
519 |
revision_tree.get_file_lines(u'', revision_tree.get_root_id()) |
|
3350.6.4
by Robert Collins
First cut at pluralised VersionedFiles. Some rather massive API incompatabilities, primarily because of the difficulty of coherence among competing stores. |
520 |
finally: |
521 |
revision_tree.unlock() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
522 |
tree.commit("Another dull commit", rev_id=b'dull2') |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
523 |
revision_tree = tree.branch.repository.revision_tree(b'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. |
524 |
revision_tree.lock_read() |
525 |
self.addCleanup(revision_tree.unlock) |
|
|
7045.2.17
by Jelmer Vernooij
Some more. |
526 |
self.assertEqual(b'dull', |
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
527 |
revision_tree.get_file_revision(u'', revision_tree.get_root_id())) |
|
2220.2.2
by Martin Pool
Add tag command and basic implementation |
528 |
|
|
3221.3.1
by Robert Collins
* Repository formats have a new supported-feature attribute |
529 |
def test_supports_external_lookups(self): |
530 |
format = bzrdir.BzrDirMetaFormat1() |
|
531 |
format.repository_format = knitrepo.RepositoryFormatKnit3() |
|
532 |
repo = self.make_repository('.', format=format) |
|
533 |
self.assertFalse(repo._format.supports_external_lookups) |
|
534 |
||
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
535 |
|
|
4667.1.1
by John Arbash Meinel
Drop the Test2a test times from 5+s down to 1.4s |
536 |
class Test2a(tests.TestCaseWithMemoryTransport): |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
537 |
|
|
5365.5.20
by John Arbash Meinel
Add some tests that check the leaf factory is correct. |
538 |
def test_chk_bytes_uses_custom_btree_parser(self): |
539 |
mt = self.make_branch_and_memory_tree('test', format='2a') |
|
540 |
mt.lock_write() |
|
541 |
self.addCleanup(mt.unlock) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
542 |
mt.add([''], [b'root-id']) |
|
5365.5.20
by John Arbash Meinel
Add some tests that check the leaf factory is correct. |
543 |
mt.commit('first') |
544 |
index = mt.branch.repository.chk_bytes._index._graph_index._indices[0] |
|
545 |
self.assertEqual(btree_index._gcchk_factory, index._leaf_factory) |
|
546 |
# It should also work if we re-open the repo
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
547 |
repo = mt.branch.repository.controldir.open_repository() |
|
5365.5.20
by John Arbash Meinel
Add some tests that check the leaf factory is correct. |
548 |
repo.lock_read() |
549 |
self.addCleanup(repo.unlock) |
|
550 |
index = repo.chk_bytes._index._graph_index._indices[0] |
|
551 |
self.assertEqual(btree_index._gcchk_factory, index._leaf_factory) |
|
552 |
||
|
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. |
553 |
def test_fetch_combines_groups(self): |
554 |
builder = self.make_branch_builder('source', format='2a') |
|
555 |
builder.start_series() |
|
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
556 |
builder.build_snapshot(None, [ |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
557 |
('add', ('', b'root-id', 'directory', '')), |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
558 |
('add', ('file', b'file-id', 'file', b'content\n'))], |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
559 |
revision_id=b'1') |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
560 |
builder.build_snapshot([b'1'], [ |
561 |
('modify', ('file', b'content-2\n'))], |
|
562 |
revision_id=b'2') |
|
563 |
builder.finish_series() |
|
564 |
source = builder.get_branch() |
|
565 |
target = self.make_repository('target', format='2a') |
|
566 |
target.fetch(source.repository) |
|
567 |
target.lock_read() |
|
568 |
self.addCleanup(target.unlock) |
|
569 |
details = target.texts._index.get_build_details( |
|
570 |
[(b'file-id', b'1',), (b'file-id', b'2',)]) |
|
571 |
file_1_details = details[(b'file-id', b'1')] |
|
572 |
file_2_details = details[(b'file-id', b'2')] |
|
573 |
# The index, and what to read off disk, should be the same for both
|
|
574 |
# versions of the file.
|
|
575 |
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3]) |
|
576 |
||
577 |
def test_fetch_combines_groups(self): |
|
578 |
builder = self.make_branch_builder('source', format='2a') |
|
579 |
builder.start_series() |
|
580 |
builder.build_snapshot(None, [ |
|
581 |
('add', ('', b'root-id', 'directory', '')), |
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
582 |
('add', ('file', b'file-id', 'file', b'content\n'))], |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
583 |
revision_id=b'1') |
584 |
builder.build_snapshot([b'1'], [ |
|
585 |
('modify', ('file', b'content-2\n'))], |
|
586 |
revision_id=b'2') |
|
587 |
builder.finish_series() |
|
588 |
source = builder.get_branch() |
|
589 |
target = self.make_repository('target', format='2a') |
|
590 |
target.fetch(source.repository) |
|
591 |
target.lock_read() |
|
592 |
self.addCleanup(target.unlock) |
|
593 |
details = target.texts._index.get_build_details( |
|
594 |
[(b'file-id', b'1',), (b'file-id', b'2',)]) |
|
595 |
file_1_details = details[(b'file-id', b'1')] |
|
596 |
file_2_details = details[(b'file-id', b'2')] |
|
597 |
# The index, and what to read off disk, should be the same for both
|
|
598 |
# versions of the file.
|
|
599 |
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3]) |
|
600 |
||
601 |
def test_fetch_combines_groups(self): |
|
602 |
builder = self.make_branch_builder('source', format='2a') |
|
603 |
builder.start_series() |
|
604 |
builder.build_snapshot(None, [ |
|
605 |
('add', ('', b'root-id', 'directory', '')), |
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
606 |
('add', ('file', b'file-id', 'file', b'content\n'))], |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
607 |
revision_id=b'1') |
608 |
builder.build_snapshot([b'1'], [ |
|
609 |
('modify', ('file', b'content-2\n'))], |
|
610 |
revision_id=b'2') |
|
611 |
builder.finish_series() |
|
612 |
source = builder.get_branch() |
|
613 |
target = self.make_repository('target', format='2a') |
|
614 |
target.fetch(source.repository) |
|
615 |
target.lock_read() |
|
616 |
self.addCleanup(target.unlock) |
|
617 |
details = target.texts._index.get_build_details( |
|
618 |
[(b'file-id', b'1',), (b'file-id', b'2',)]) |
|
619 |
file_1_details = details[(b'file-id', b'1')] |
|
620 |
file_2_details = details[(b'file-id', b'2')] |
|
|
4634.23.1
by Robert Collins
Cherrypick from bzr.dev: Fix bug 402652: recompress badly packed groups during fetch. (John Arbash Meinel, Robert Collins) |
621 |
# The index, and what to read off disk, should be the same for both
|
622 |
# versions of the file.
|
|
623 |
self.assertEqual(file_1_details[0][:3], file_2_details[0][:3]) |
|
624 |
||
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
625 |
def test_format_pack_compresses_True(self): |
626 |
repo = self.make_repository('repo', format='2a') |
|
627 |
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. |
628 |
|
629 |
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 |
630 |
tree = self.make_branch_and_memory_tree('repo', format="2a") |
631 |
tree.lock_write() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
632 |
tree.add([''], [b'TREE_ROOT']) |
|
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
633 |
revid = tree.commit("foo") |
|
4667.1.1
by John Arbash Meinel
Drop the Test2a test times from 5+s down to 1.4s |
634 |
tree.unlock() |
|
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
635 |
tree.lock_read() |
636 |
self.addCleanup(tree.unlock) |
|
637 |
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. |
638 |
self.assertNotEqual(None, inv.parent_id_basename_to_file_id) |
639 |
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. |
640 |
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) |
641 |
self.assertEqual(65536, inv.id_to_entry._root_node.maximum_size) |
642 |
self.assertEqual(65536, |
|
|
3735.2.41
by Robert Collins
Make the parent_id_basename index be updated during CHKInventory.apply_delta. |
643 |
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. |
644 |
|
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
645 |
def test_autopack_unchanged_chk_nodes(self): |
646 |
# at 20 unchanged commits, chk pages are packed that are split into
|
|
647 |
# two groups such that the new pack being made doesn't have all its
|
|
648 |
# 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 |
649 |
# Use a memory backed repository, we don't need to hit disk for this
|
650 |
tree = self.make_branch_and_memory_tree('tree', format='2a') |
|
651 |
tree.lock_write() |
|
652 |
self.addCleanup(tree.unlock) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
653 |
tree.add([''], [b'TREE_ROOT']) |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
654 |
for pos in range(20): |
655 |
tree.commit(str(pos)) |
|
656 |
||
657 |
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 |
658 |
tree = self.make_branch_and_memory_tree('tree', format='2a') |
659 |
tree.lock_write() |
|
660 |
self.addCleanup(tree.unlock) |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
661 |
tree.add([''], [b'TREE_ROOT']) |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
662 |
# 1 commit to leave untouched
|
663 |
tree.commit('1') |
|
664 |
to_keep = tree.branch.repository._pack_collection.names() |
|
665 |
# 2 to combine
|
|
666 |
tree.commit('2') |
|
667 |
tree.commit('3') |
|
668 |
all = tree.branch.repository._pack_collection.names() |
|
669 |
combine = list(set(all) - set(to_keep)) |
|
670 |
self.assertLength(3, all) |
|
671 |
self.assertLength(2, combine) |
|
672 |
tree.branch.repository.pack(hint=combine) |
|
673 |
final = tree.branch.repository._pack_collection.names() |
|
674 |
self.assertLength(2, final) |
|
675 |
self.assertFalse(combine[0] in final) |
|
676 |
self.assertFalse(combine[1] in final) |
|
677 |
self.assertSubset(to_keep, final) |
|
678 |
||
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
679 |
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. |
680 |
source = self.make_repository('source', format='2a') |
681 |
target = self.make_repository('target', format='2a') |
|
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
682 |
stream = source._get_source(target._format) |
683 |
self.assertIsInstance(stream, groupcompress_repo.GroupCHKStreamSource) |
|
684 |
||
685 |
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. |
686 |
source = self.make_repository('source', format='2a') |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
687 |
target = self.make_repository('target', format='rich-root-pack') |
688 |
stream = source._get_source(target._format) |
|
689 |
# We don't want the child GroupCHKStreamSource
|
|
|
5815.4.15
by Jelmer Vernooij
Fix some imports. |
690 |
self.assertIs(type(stream), vf_repository.StreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
691 |
|
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
692 |
def test_get_stream_for_missing_keys_includes_all_chk_refs(self): |
693 |
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. |
694 |
format='2a') |
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
695 |
# We have to build a fairly large tree, so that we are sure the chk
|
696 |
# pages will have split into multiple pages.
|
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
697 |
entries = [('add', ('', b'a-root-id', 'directory', None))] |
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
698 |
for i in 'abcdefghijklmnopqrstuvwxyz123456789': |
699 |
for j in 'abcdefghijklmnopqrstuvwxyz123456789': |
|
700 |
fname = i + j |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
701 |
fid = fname.encode('utf-8') + b'-id' |
|
7032.1.1
by Jelmer Vernooij
Fix some chk_map tests. |
702 |
content = b'content for %s\n' % (fname.encode('utf-8'),) |
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
703 |
entries.append(('add', (fname, fid, 'file', content))) |
704 |
source_builder.start_series() |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
705 |
source_builder.build_snapshot(None, entries, revision_id=b'rev-1') |
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
706 |
# Now change a few of them, so we get a few new pages for the second
|
707 |
# revision
|
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
708 |
source_builder.build_snapshot([b'rev-1'], [ |
|
6883.22.11
by Jelmer Vernooij
merge trunk |
709 |
('modify', ('aa', b'new content for aa-id\n')), |
710 |
('modify', ('cc', b'new content for cc-id\n')), |
|
711 |
('modify', ('zz', b'new content for zz-id\n')), |
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
712 |
], revision_id=b'rev-2') |
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
713 |
source_builder.finish_series() |
714 |
source_branch = source_builder.get_branch() |
|
715 |
source_branch.lock_read() |
|
716 |
self.addCleanup(source_branch.unlock) |
|
|
4462.2.1
by Robert Collins
Add new attribute to RepositoryFormat pack_compresses, hinting when pack can be useful. |
717 |
target = self.make_repository('target', format='2a') |
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
718 |
source = source_branch.repository._get_source(target._format) |
719 |
self.assertIsInstance(source, groupcompress_repo.GroupCHKStreamSource) |
|
720 |
||
721 |
# On a regular pass, getting the inventories and chk pages for rev-2
|
|
722 |
# would only get the newly created chk pages
|
|
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
723 |
search = vf_search.SearchResult({b'rev-2'}, {b'rev-1'}, 1, |
724 |
{b'rev-2'}) |
|
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
725 |
simple_chk_records = [] |
726 |
for vf_name, substream in source.get_stream(search): |
|
727 |
if vf_name == 'chk_bytes': |
|
728 |
for record in substream: |
|
729 |
simple_chk_records.append(record.key) |
|
730 |
else: |
|
731 |
for _ in substream: |
|
732 |
continue
|
|
733 |
# 3 pages, the root (InternalNode), + 2 pages which actually changed
|
|
|
7032.1.1
by Jelmer Vernooij
Fix some chk_map tests. |
734 |
self.assertEqual([(b'sha1:91481f539e802c76542ea5e4c83ad416bf219f73',), |
735 |
(b'sha1:4ff91971043668583985aec83f4f0ab10a907d3f',), |
|
736 |
(b'sha1:81e7324507c5ca132eedaf2d8414ee4bb2226187',), |
|
737 |
(b'sha1:b101b7da280596c71a4540e9a1eeba8045985ee0',)], |
|
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
738 |
simple_chk_records) |
739 |
# Now, when we do a similar call using 'get_stream_for_missing_keys'
|
|
740 |
# we should get a much larger set of pages.
|
|
|
7032.1.1
by Jelmer Vernooij
Fix some chk_map tests. |
741 |
missing = [('inventories', b'rev-2')] |
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
742 |
full_chk_records = [] |
743 |
for vf_name, substream in source.get_stream_for_missing_keys(missing): |
|
744 |
if vf_name == 'inventories': |
|
745 |
for record in substream: |
|
|
7032.1.1
by Jelmer Vernooij
Fix some chk_map tests. |
746 |
self.assertEqual((b'rev-2',), record.key) |
|
4360.4.9
by John Arbash Meinel
Merge bzr.dev, bringing in the gc stacking fixes. |
747 |
elif vf_name == 'chk_bytes': |
748 |
for record in substream: |
|
749 |
full_chk_records.append(record.key) |
|
750 |
else: |
|
751 |
self.fail('Should not be getting a stream of %s' % (vf_name,)) |
|
752 |
# We have 257 records now. This is because we have 1 root page, and 256
|
|
753 |
# leaf pages in a complete listing.
|
|
754 |
self.assertEqual(257, len(full_chk_records)) |
|
755 |
self.assertSubset(simple_chk_records, full_chk_records) |
|
756 |
||
|
4465.2.7
by Aaron Bentley
Move test_inconsistency_fatal to test_repository |
757 |
def test_inconsistency_fatal(self): |
758 |
repo = self.make_repository('repo', format='2a') |
|
759 |
self.assertTrue(repo.revisions._index._inconsistency_fatal) |
|
760 |
self.assertFalse(repo.texts._index._inconsistency_fatal) |
|
761 |
self.assertFalse(repo.inventories._index._inconsistency_fatal) |
|
762 |
self.assertFalse(repo.signatures._index._inconsistency_fatal) |
|
763 |
self.assertFalse(repo.chk_bytes._index._inconsistency_fatal) |
|
764 |
||
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
765 |
|
766 |
class TestKnitPackStreamSource(tests.TestCaseWithMemoryTransport): |
|
767 |
||
768 |
def test_source_to_exact_pack_092(self): |
|
769 |
source = self.make_repository('source', format='pack-0.92') |
|
770 |
target = self.make_repository('target', format='pack-0.92') |
|
771 |
stream_source = source._get_source(target._format) |
|
|
5757.2.2
by Jelmer Vernooij
Fix imports. |
772 |
self.assertIsInstance(stream_source, knitpack_repo.KnitPackStreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
773 |
|
774 |
def test_source_to_exact_pack_rich_root_pack(self): |
|
775 |
source = self.make_repository('source', format='rich-root-pack') |
|
776 |
target = self.make_repository('target', format='rich-root-pack') |
|
777 |
stream_source = source._get_source(target._format) |
|
|
5757.2.2
by Jelmer Vernooij
Fix imports. |
778 |
self.assertIsInstance(stream_source, knitpack_repo.KnitPackStreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
779 |
|
780 |
def test_source_to_exact_pack_19(self): |
|
781 |
source = self.make_repository('source', format='1.9') |
|
782 |
target = self.make_repository('target', format='1.9') |
|
783 |
stream_source = source._get_source(target._format) |
|
|
5757.2.2
by Jelmer Vernooij
Fix imports. |
784 |
self.assertIsInstance(stream_source, knitpack_repo.KnitPackStreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
785 |
|
786 |
def test_source_to_exact_pack_19_rich_root(self): |
|
787 |
source = self.make_repository('source', format='1.9-rich-root') |
|
788 |
target = self.make_repository('target', format='1.9-rich-root') |
|
789 |
stream_source = source._get_source(target._format) |
|
|
5757.2.2
by Jelmer Vernooij
Fix imports. |
790 |
self.assertIsInstance(stream_source, knitpack_repo.KnitPackStreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
791 |
|
792 |
def test_source_to_remote_exact_pack_19(self): |
|
793 |
trans = self.make_smart_server('target') |
|
794 |
trans.ensure_base() |
|
795 |
source = self.make_repository('source', format='1.9') |
|
796 |
target = self.make_repository('target', format='1.9') |
|
797 |
target = repository.Repository.open(trans.base) |
|
798 |
stream_source = source._get_source(target._format) |
|
|
5757.2.2
by Jelmer Vernooij
Fix imports. |
799 |
self.assertIsInstance(stream_source, knitpack_repo.KnitPackStreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
800 |
|
801 |
def test_stream_source_to_non_exact(self): |
|
802 |
source = self.make_repository('source', format='pack-0.92') |
|
803 |
target = self.make_repository('target', format='1.9') |
|
804 |
stream = source._get_source(target._format) |
|
|
5815.4.15
by Jelmer Vernooij
Fix some imports. |
805 |
self.assertIs(type(stream), vf_repository.StreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
806 |
|
807 |
def test_stream_source_to_non_exact_rich_root(self): |
|
808 |
source = self.make_repository('source', format='1.9') |
|
809 |
target = self.make_repository('target', format='1.9-rich-root') |
|
810 |
stream = source._get_source(target._format) |
|
|
5815.4.15
by Jelmer Vernooij
Fix some imports. |
811 |
self.assertIs(type(stream), vf_repository.StreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
812 |
|
813 |
def test_source_to_remote_non_exact_pack_19(self): |
|
814 |
trans = self.make_smart_server('target') |
|
815 |
trans.ensure_base() |
|
816 |
source = self.make_repository('source', format='1.9') |
|
817 |
target = self.make_repository('target', format='1.6') |
|
818 |
target = repository.Repository.open(trans.base) |
|
819 |
stream_source = source._get_source(target._format) |
|
|
5815.4.15
by Jelmer Vernooij
Fix some imports. |
820 |
self.assertIs(type(stream_source), vf_repository.StreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
821 |
|
822 |
def test_stream_source_to_knit(self): |
|
823 |
source = self.make_repository('source', format='pack-0.92') |
|
824 |
target = self.make_repository('target', format='dirstate') |
|
825 |
stream = source._get_source(target._format) |
|
|
5815.4.15
by Jelmer Vernooij
Fix some imports. |
826 |
self.assertIs(type(stream), vf_repository.StreamSource) |
|
4360.4.3
by John Arbash Meinel
Introduce a KnitPackStreamSource which is used when |
827 |
|
|
3735.2.40
by Robert Collins
Add development4 which has a parent_id to basename index on CHKInventory objects. |
828 |
|
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
829 |
class TestDevelopment6FindParentIdsOfRevisions(TestCaseWithTransport): |
830 |
"""Tests for _find_parent_ids_of_revisions.""" |
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
831 |
|
832 |
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. |
833 |
super(TestDevelopment6FindParentIdsOfRevisions, self).setUp() |
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
834 |
self.builder = self.make_branch_builder('source') |
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
835 |
self.builder.start_series() |
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
836 |
self.builder.build_snapshot(None, |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
837 |
[('add', ('', b'tree-root', 'directory', None))], |
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
838 |
revision_id=b'initial') |
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
839 |
self.repo = self.builder.get_branch().repository |
840 |
self.addCleanup(self.builder.finish_series) |
|
|
3735.2.99
by John Arbash Meinel
Merge bzr.dev 4034. Whitespace cleanup |
841 |
|
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
842 |
def assertParentIds(self, expected_result, rev_set): |
843 |
self.assertEqual(sorted(expected_result), |
|
844 |
sorted(self.repo._find_parent_ids_of_revisions(rev_set))) |
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
845 |
|
846 |
def test_simple(self): |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
847 |
self.builder.build_snapshot(None, [], revision_id=b'revid1') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
848 |
self.builder.build_snapshot([b'revid1'], [], revision_id=b'revid2') |
849 |
rev_set = [b'revid2'] |
|
850 |
self.assertParentIds([b'revid1'], rev_set) |
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
851 |
|
852 |
def test_not_first_parent(self): |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
853 |
self.builder.build_snapshot(None, [], revision_id=b'revid1') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
854 |
self.builder.build_snapshot([b'revid1'], [], revision_id=b'revid2') |
855 |
self.builder.build_snapshot([b'revid2'], [], revision_id=b'revid3') |
|
856 |
rev_set = [b'revid3', b'revid2'] |
|
857 |
self.assertParentIds([b'revid1'], rev_set) |
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
858 |
|
859 |
def test_not_null(self): |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
860 |
rev_set = [b'initial'] |
|
4343.3.32
by John Arbash Meinel
Change the tests for _find_revision_outside_set to the new _find_parent_ids function. |
861 |
self.assertParentIds([], rev_set) |
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
862 |
|
863 |
def test_not_null_set(self): |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
864 |
self.builder.build_snapshot(None, [], revision_id=b'revid1') |
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
865 |
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. |
866 |
self.assertParentIds([], rev_set) |
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
867 |
|
868 |
def test_ghost(self): |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
869 |
self.builder.build_snapshot(None, [], revision_id=b'revid1') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
870 |
rev_set = [b'ghost', b'revid1'] |
871 |
self.assertParentIds([b'initial'], rev_set) |
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
872 |
|
873 |
def test_ghost_parent(self): |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
874 |
self.builder.build_snapshot(None, [], revision_id=b'revid1') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
875 |
self.builder.build_snapshot([b'revid1', b'ghost'], [], revision_id=b'revid2') |
876 |
rev_set = [b'revid2', b'revid1'] |
|
877 |
self.assertParentIds([b'ghost', b'initial'], rev_set) |
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
878 |
|
879 |
def test_righthand_parent(self): |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
880 |
self.builder.build_snapshot(None, [], revision_id=b'revid1') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
881 |
self.builder.build_snapshot([b'revid1'], [], revision_id=b'revid2a') |
882 |
self.builder.build_snapshot([b'revid1'], [], revision_id=b'revid2b') |
|
883 |
self.builder.build_snapshot([b'revid2a', b'revid2b'], [], |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
884 |
revision_id=b'revid3') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
885 |
rev_set = [b'revid3', b'revid2a'] |
886 |
self.assertParentIds([b'revid1', b'revid2b'], rev_set) |
|
|
3735.4.1
by Andrew Bennetts
Add _find_revision_outside_set. |
887 |
|
888 |
||
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
889 |
class TestWithBrokenRepo(TestCaseWithTransport): |
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
890 |
"""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. |
891 |
|
892 |
def make_broken_repository(self): |
|
893 |
# XXX: This function is borrowed from Aaron's "Reconcile can fix bad
|
|
894 |
# parent references" branch which is due to land in bzr.dev soon. Once
|
|
895 |
# it does, this duplication should be removed.
|
|
896 |
repo = self.make_repository('broken-repo') |
|
897 |
cleanups = [] |
|
898 |
try: |
|
899 |
repo.lock_write() |
|
900 |
cleanups.append(repo.unlock) |
|
901 |
repo.start_write_group() |
|
902 |
cleanups.append(repo.commit_write_group) |
|
903 |
# make rev1a: A well-formed revision, containing 'file1'
|
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
904 |
inv = inventory.Inventory(revision_id=b'rev1a') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
905 |
inv.root.revision = b'rev1a' |
906 |
self.add_file(repo, inv, 'file1', b'rev1a', []) |
|
907 |
repo.texts.add_lines((inv.root.file_id, b'rev1a'), [], []) |
|
908 |
repo.add_inventory(b'rev1a', inv, []) |
|
909 |
revision = _mod_revision.Revision(b'rev1a', |
|
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
910 |
committer='jrandom@example.com', timestamp=0, |
911 |
inventory_sha1='', timezone=0, message='foo', parent_ids=[]) |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
912 |
repo.add_revision(b'rev1a', revision, inv) |
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
913 |
|
914 |
# make rev1b, which has no Revision, but has an Inventory, and
|
|
915 |
# file1
|
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
916 |
inv = inventory.Inventory(revision_id=b'rev1b') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
917 |
inv.root.revision = b'rev1b' |
918 |
self.add_file(repo, inv, 'file1', b'rev1b', []) |
|
919 |
repo.add_inventory(b'rev1b', inv, []) |
|
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
920 |
|
921 |
# make rev2, with file1 and file2
|
|
922 |
# file2 is sane
|
|
923 |
# file1 has 'rev1b' as an ancestor, even though this is not
|
|
924 |
# mentioned by 'rev1a', making it an unreferenced ancestor
|
|
925 |
inv = inventory.Inventory() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
926 |
self.add_file(repo, inv, 'file1', b'rev2', [b'rev1a', b'rev1b']) |
927 |
self.add_file(repo, inv, 'file2', b'rev2', []) |
|
928 |
self.add_revision(repo, b'rev2', inv, [b'rev1a']) |
|
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
929 |
|
930 |
# make ghost revision rev1c
|
|
931 |
inv = inventory.Inventory() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
932 |
self.add_file(repo, inv, 'file2', b'rev1c', []) |
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
933 |
|
934 |
# make rev3 with file2
|
|
935 |
# file2 refers to 'rev1c', which is a ghost in this repository, so
|
|
936 |
# file2 cannot have rev1c as its ancestor.
|
|
937 |
inv = inventory.Inventory() |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
938 |
self.add_file(repo, inv, 'file2', b'rev3', [b'rev1c']) |
939 |
self.add_revision(repo, b'rev3', inv, [b'rev1c']) |
|
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
940 |
return repo |
941 |
finally: |
|
942 |
for cleanup in reversed(cleanups): |
|
943 |
cleanup() |
|
944 |
||
945 |
def add_revision(self, repo, revision_id, inv, parent_ids): |
|
946 |
inv.revision_id = revision_id |
|
947 |
inv.root.revision = revision_id |
|
|
4634.35.21
by Andrew Bennetts
Fix test_insert_from_broken_repo in test_repository. |
948 |
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. |
949 |
repo.add_inventory(revision_id, inv, parent_ids) |
950 |
revision = _mod_revision.Revision(revision_id, |
|
951 |
committer='jrandom@example.com', timestamp=0, inventory_sha1='', |
|
952 |
timezone=0, message='foo', parent_ids=parent_ids) |
|
|
6351.3.2
by Jelmer Vernooij
Convert some gpg options to config stacks. |
953 |
repo.add_revision(revision_id, revision, inv) |
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
954 |
|
955 |
def add_file(self, repo, inv, filename, revision, parents): |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
956 |
file_id = filename + b'-id' |
957 |
entry = inventory.InventoryFile(file_id, filename, b'TREE_ROOT') |
|
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
958 |
entry.revision = revision |
|
2535.4.10
by Andrew Bennetts
Fix one failing test, disable another. |
959 |
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. |
960 |
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. |
961 |
text_key = (file_id, revision) |
962 |
parent_keys = [(file_id, parent) for parent in parents] |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
963 |
repo.texts.add_lines(text_key, parent_keys, [b'line\n']) |
|
2535.3.57
by Andrew Bennetts
Perform some sanity checking of data streams rather than blindly inserting them into our repository. |
964 |
|
965 |
def test_insert_from_broken_repo(self): |
|
966 |
"""Inserting a data stream from a broken repository won't silently |
|
967 |
corrupt the target repository.
|
|
968 |
"""
|
|
969 |
broken_repo = self.make_broken_repository() |
|
970 |
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. |
971 |
try: |
972 |
empty_repo.fetch(broken_repo) |
|
973 |
except (errors.RevisionNotPresent, errors.BzrCheckError): |
|
974 |
# Test successful: compression parent not being copied leads to
|
|
975 |
# error.
|
|
976 |
return
|
|
977 |
empty_repo.lock_read() |
|
978 |
self.addCleanup(empty_repo.unlock) |
|
|
6634.2.1
by Martin
Apply 2to3 next fixer and make compatible |
979 |
text = next(empty_repo.texts.get_record_stream( |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
980 |
[(b'file2-id', b'rev3')], 'topological', True)) |
981 |
self.assertEqual(b'line\n', text.get_bytes_as('fulltext')) |
|
|
2592.3.214
by Robert Collins
Merge bzr.dev. |
982 |
|
983 |
||
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
984 |
class TestRepositoryPackCollection(TestCaseWithTransport): |
985 |
||
986 |
def get_format(self): |
|
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
987 |
return controldir.format_registry.make_controldir('pack-0.92') |
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
988 |
|
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
989 |
def get_packs(self): |
990 |
format = self.get_format() |
|
991 |
repo = self.make_repository('.', format=format) |
|
992 |
return repo._pack_collection |
|
993 |
||
|
3789.2.20
by John Arbash Meinel
The autopack code can now trigger itself to retry when _copy_revision_texts fails. |
994 |
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 |
995 |
"""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. |
996 |
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 |
997 |
tree.lock_write() |
998 |
self.addCleanup(tree.unlock) |
|
999 |
rev1 = tree.commit('one') |
|
1000 |
rev2 = tree.commit('two') |
|
1001 |
rev3 = tree.commit('three') |
|
1002 |
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. |
1003 |
if write_lock: |
1004 |
r.lock_write() |
|
1005 |
else: |
|
1006 |
r.lock_read() |
|
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1007 |
self.addCleanup(r.unlock) |
1008 |
packs = r._pack_collection |
|
1009 |
packs.ensure_loaded() |
|
1010 |
return tree, r, packs, [rev1, rev2, rev3] |
|
1011 |
||
|
4634.127.1
by John Arbash Meinel
Partial fix for bug #507557. |
1012 |
def test__clear_obsolete_packs(self): |
1013 |
packs = self.get_packs() |
|
1014 |
obsolete_pack_trans = packs.transport.clone('obsolete_packs') |
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
1015 |
obsolete_pack_trans.put_bytes('a-pack.pack', b'content\n') |
1016 |
obsolete_pack_trans.put_bytes('a-pack.rix', b'content\n') |
|
1017 |
obsolete_pack_trans.put_bytes('a-pack.iix', b'content\n') |
|
1018 |
obsolete_pack_trans.put_bytes('another-pack.pack', b'foo\n') |
|
1019 |
obsolete_pack_trans.put_bytes('not-a-pack.rix', b'foo\n') |
|
|
4634.127.1
by John Arbash Meinel
Partial fix for bug #507557. |
1020 |
res = packs._clear_obsolete_packs() |
1021 |
self.assertEqual(['a-pack', 'another-pack'], sorted(res)) |
|
1022 |
self.assertEqual([], obsolete_pack_trans.list_dir('.')) |
|
1023 |
||
1024 |
def test__clear_obsolete_packs_preserve(self): |
|
1025 |
packs = self.get_packs() |
|
1026 |
obsolete_pack_trans = packs.transport.clone('obsolete_packs') |
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
1027 |
obsolete_pack_trans.put_bytes('a-pack.pack', b'content\n') |
1028 |
obsolete_pack_trans.put_bytes('a-pack.rix', b'content\n') |
|
1029 |
obsolete_pack_trans.put_bytes('a-pack.iix', b'content\n') |
|
1030 |
obsolete_pack_trans.put_bytes('another-pack.pack', b'foo\n') |
|
1031 |
obsolete_pack_trans.put_bytes('not-a-pack.rix', b'foo\n') |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1032 |
res = packs._clear_obsolete_packs(preserve={'a-pack'}) |
|
4634.127.1
by John Arbash Meinel
Partial fix for bug #507557. |
1033 |
self.assertEqual(['a-pack', 'another-pack'], sorted(res)) |
1034 |
self.assertEqual(['a-pack.iix', 'a-pack.pack', 'a-pack.rix'], |
|
1035 |
sorted(obsolete_pack_trans.list_dir('.'))) |
|
1036 |
||
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1037 |
def test__max_pack_count(self): |
|
2592.3.219
by Robert Collins
Review feedback. |
1038 |
"""The maximum pack count is a function of the number of revisions.""" |
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1039 |
# no revisions - one pack, so that we can have a revision free repo
|
1040 |
# without it blowing up
|
|
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1041 |
packs = self.get_packs() |
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1042 |
self.assertEqual(1, packs._max_pack_count(0)) |
1043 |
# after that the sum of the digits, - check the first 1-9
|
|
1044 |
self.assertEqual(1, packs._max_pack_count(1)) |
|
1045 |
self.assertEqual(2, packs._max_pack_count(2)) |
|
1046 |
self.assertEqual(3, packs._max_pack_count(3)) |
|
1047 |
self.assertEqual(4, packs._max_pack_count(4)) |
|
1048 |
self.assertEqual(5, packs._max_pack_count(5)) |
|
1049 |
self.assertEqual(6, packs._max_pack_count(6)) |
|
1050 |
self.assertEqual(7, packs._max_pack_count(7)) |
|
1051 |
self.assertEqual(8, packs._max_pack_count(8)) |
|
1052 |
self.assertEqual(9, packs._max_pack_count(9)) |
|
1053 |
# check the boundary cases with two digits for the next decade
|
|
1054 |
self.assertEqual(1, packs._max_pack_count(10)) |
|
1055 |
self.assertEqual(2, packs._max_pack_count(11)) |
|
1056 |
self.assertEqual(10, packs._max_pack_count(19)) |
|
1057 |
self.assertEqual(2, packs._max_pack_count(20)) |
|
1058 |
self.assertEqual(3, packs._max_pack_count(21)) |
|
1059 |
# check some arbitrary big numbers
|
|
1060 |
self.assertEqual(25, packs._max_pack_count(112894)) |
|
1061 |
||
|
4928.1.1
by Martin Pool
Give RepositoryPackCollection a repr |
1062 |
def test_repr(self): |
1063 |
packs = self.get_packs() |
|
1064 |
self.assertContainsRe(repr(packs), |
|
1065 |
'RepositoryPackCollection(.*Repository(.*))') |
|
1066 |
||
|
4634.127.2
by John Arbash Meinel
Change the _obsolete_packs code to handle files that are already gone. |
1067 |
def test__obsolete_packs(self): |
1068 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1069 |
names = packs.names() |
|
1070 |
pack = packs.get_pack_by_name(names[0]) |
|
1071 |
# Schedule this one for removal
|
|
1072 |
packs._remove_pack_from_memory(pack) |
|
1073 |
# Simulate a concurrent update by renaming the .pack file and one of
|
|
1074 |
# the indices
|
|
1075 |
packs.transport.rename('packs/%s.pack' % (names[0],), |
|
1076 |
'obsolete_packs/%s.pack' % (names[0],)) |
|
1077 |
packs.transport.rename('indices/%s.iix' % (names[0],), |
|
1078 |
'obsolete_packs/%s.iix' % (names[0],)) |
|
1079 |
# Now trigger the obsoletion, and ensure that all the remaining files
|
|
1080 |
# are still renamed
|
|
1081 |
packs._obsolete_packs([pack]) |
|
1082 |
self.assertEqual([n + '.pack' for n in names[1:]], |
|
1083 |
sorted(packs._pack_transport.list_dir('.'))) |
|
1084 |
# names[0] should not be present in the index anymore
|
|
1085 |
self.assertEqual(names[1:], |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1086 |
sorted({osutils.splitext(n)[0] for n in |
1087 |
packs._index_transport.list_dir('.')})) |
|
|
4634.127.2
by John Arbash Meinel
Change the _obsolete_packs code to handle files that are already gone. |
1088 |
|
|
6225.2.8
by Jelmer Vernooij
Fix creation of obsolete_packs if it is missing. |
1089 |
def test__obsolete_packs_missing_directory(self): |
1090 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1091 |
r.control_transport.rmdir('obsolete_packs') |
|
1092 |
names = packs.names() |
|
1093 |
pack = packs.get_pack_by_name(names[0]) |
|
1094 |
# Schedule this one for removal
|
|
1095 |
packs._remove_pack_from_memory(pack) |
|
1096 |
# Now trigger the obsoletion, and ensure that all the remaining files
|
|
1097 |
# are still renamed
|
|
1098 |
packs._obsolete_packs([pack]) |
|
1099 |
self.assertEqual([n + '.pack' for n in names[1:]], |
|
1100 |
sorted(packs._pack_transport.list_dir('.'))) |
|
1101 |
# names[0] should not be present in the index anymore
|
|
1102 |
self.assertEqual(names[1:], |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1103 |
sorted({osutils.splitext(n)[0] for n in |
1104 |
packs._index_transport.list_dir('.')})) |
|
|
6225.2.8
by Jelmer Vernooij
Fix creation of obsolete_packs if it is missing. |
1105 |
|
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1106 |
def test_pack_distribution_zero(self): |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1107 |
packs = self.get_packs() |
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1108 |
self.assertEqual([0], packs.pack_distribution(0)) |
|
3052.1.6
by John Arbash Meinel
Change the lock check to raise ObjectNotLocked. |
1109 |
|
1110 |
def test_ensure_loaded_unlocked(self): |
|
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1111 |
packs = self.get_packs() |
|
3052.1.6
by John Arbash Meinel
Change the lock check to raise ObjectNotLocked. |
1112 |
self.assertRaises(errors.ObjectNotLocked, |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1113 |
packs.ensure_loaded) |
|
3052.1.6
by John Arbash Meinel
Change the lock check to raise ObjectNotLocked. |
1114 |
|
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1115 |
def test_pack_distribution_one_to_nine(self): |
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1116 |
packs = self.get_packs() |
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1117 |
self.assertEqual([1], |
1118 |
packs.pack_distribution(1)) |
|
1119 |
self.assertEqual([1, 1], |
|
1120 |
packs.pack_distribution(2)) |
|
1121 |
self.assertEqual([1, 1, 1], |
|
1122 |
packs.pack_distribution(3)) |
|
1123 |
self.assertEqual([1, 1, 1, 1], |
|
1124 |
packs.pack_distribution(4)) |
|
1125 |
self.assertEqual([1, 1, 1, 1, 1], |
|
1126 |
packs.pack_distribution(5)) |
|
1127 |
self.assertEqual([1, 1, 1, 1, 1, 1], |
|
1128 |
packs.pack_distribution(6)) |
|
1129 |
self.assertEqual([1, 1, 1, 1, 1, 1, 1], |
|
1130 |
packs.pack_distribution(7)) |
|
1131 |
self.assertEqual([1, 1, 1, 1, 1, 1, 1, 1], |
|
1132 |
packs.pack_distribution(8)) |
|
1133 |
self.assertEqual([1, 1, 1, 1, 1, 1, 1, 1, 1], |
|
1134 |
packs.pack_distribution(9)) |
|
1135 |
||
1136 |
def test_pack_distribution_stable_at_boundaries(self): |
|
1137 |
"""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, |
1138 |
packs = self.get_packs() |
|
2592.3.84
by Robert Collins
Start of autopacking logic. |
1139 |
# in 10s:
|
1140 |
self.assertEqual([10], packs.pack_distribution(10)) |
|
1141 |
self.assertEqual([10, 1], packs.pack_distribution(11)) |
|
1142 |
self.assertEqual([10, 10], packs.pack_distribution(20)) |
|
1143 |
self.assertEqual([10, 10, 1], packs.pack_distribution(21)) |
|
1144 |
# 100s
|
|
1145 |
self.assertEqual([100], packs.pack_distribution(100)) |
|
1146 |
self.assertEqual([100, 1], packs.pack_distribution(101)) |
|
1147 |
self.assertEqual([100, 10, 1], packs.pack_distribution(111)) |
|
1148 |
self.assertEqual([100, 100], packs.pack_distribution(200)) |
|
1149 |
self.assertEqual([100, 100, 1], packs.pack_distribution(201)) |
|
1150 |
self.assertEqual([100, 100, 10, 1], packs.pack_distribution(211)) |
|
1151 |
||
|
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1152 |
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, |
1153 |
packs = self.get_packs() |
|
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1154 |
existing_packs = [(2000, "big"), (9, "medium")] |
1155 |
# rev count - 2009 -> 2x1000 + 9x1
|
|
1156 |
pack_operations = packs.plan_autopack_combinations( |
|
1157 |
existing_packs, [1000, 1000, 1, 1, 1, 1, 1, 1, 1, 1, 1]) |
|
1158 |
self.assertEqual([], pack_operations) |
|
1159 |
||
1160 |
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, |
1161 |
packs = self.get_packs() |
|
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1162 |
existing_packs = [(2000, "big"), (9, "medium"), (1, "single")] |
1163 |
# rev count - 2010 -> 2x1000 + 1x10
|
|
1164 |
pack_operations = packs.plan_autopack_combinations( |
|
1165 |
existing_packs, [1000, 1000, 10]) |
|
1166 |
self.assertEqual([], pack_operations) |
|
1167 |
||
1168 |
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, |
1169 |
packs = self.get_packs() |
|
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1170 |
existing_packs = [(1999, "big"), (9, "medium"), (1, "single2"), |
1171 |
(1, "single1")] |
|
1172 |
# rev count - 2010 -> 2x1000 + 1x10 (3)
|
|
1173 |
pack_operations = packs.plan_autopack_combinations( |
|
1174 |
existing_packs, [1000, 1000, 10]) |
|
|
3711.4.2
by John Arbash Meinel
Change the logic to solve it in a different way. |
1175 |
self.assertEqual([[2, ["single2", "single1"]]], pack_operations) |
|
2592.3.85
by Robert Collins
Finish autopack corner cases. |
1176 |
|
|
3711.4.2
by John Arbash Meinel
Change the logic to solve it in a different way. |
1177 |
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, |
1178 |
packs = self.get_packs() |
|
3711.4.2
by John Arbash Meinel
Change the logic to solve it in a different way. |
1179 |
existing_packs = [(50, 'a'), (40, 'b'), (30, 'c'), (10, 'd'), |
1180 |
(10, 'e'), (6, 'f'), (4, 'g')] |
|
1181 |
# rev count 150 -> 1x100 and 5x10
|
|
1182 |
# The two size 10 packs do not need to be touched. The 50, 40, 30 would
|
|
1183 |
# be combined into a single 120 size pack, and the 6 & 4 would
|
|
1184 |
# becombined into a size 10 pack. However, if we have to rewrite them,
|
|
1185 |
# we save a pack file with no increased I/O by putting them into the
|
|
1186 |
# same file.
|
|
1187 |
distribution = packs.pack_distribution(150) |
|
|
3711.4.1
by John Arbash Meinel
Fix bug #242510, when determining the autopack sequence, |
1188 |
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. |
1189 |
distribution) |
1190 |
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, |
1191 |
|
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1192 |
def test_all_packs_none(self): |
1193 |
format = self.get_format() |
|
1194 |
tree = self.make_branch_and_tree('.', format=format) |
|
1195 |
tree.lock_read() |
|
1196 |
self.addCleanup(tree.unlock) |
|
|
2592.3.232
by Martin Pool
Disambiguate two member variables called _packs into _packs_by_name and _pack_collection |
1197 |
packs = tree.branch.repository._pack_collection |
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1198 |
packs.ensure_loaded() |
1199 |
self.assertEqual([], packs.all_packs()) |
|
1200 |
||
1201 |
def test_all_packs_one(self): |
|
1202 |
format = self.get_format() |
|
1203 |
tree = self.make_branch_and_tree('.', format=format) |
|
1204 |
tree.commit('start') |
|
1205 |
tree.lock_read() |
|
1206 |
self.addCleanup(tree.unlock) |
|
|
2592.3.232
by Martin Pool
Disambiguate two member variables called _packs into _packs_by_name and _pack_collection |
1207 |
packs = tree.branch.repository._pack_collection |
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1208 |
packs.ensure_loaded() |
|
2592.3.176
by Robert Collins
Various pack refactorings. |
1209 |
self.assertEqual([ |
1210 |
packs.get_pack_by_name(packs.names()[0])], |
|
1211 |
packs.all_packs()) |
|
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1212 |
|
1213 |
def test_all_packs_two(self): |
|
1214 |
format = self.get_format() |
|
1215 |
tree = self.make_branch_and_tree('.', format=format) |
|
1216 |
tree.commit('start') |
|
1217 |
tree.commit('continue') |
|
1218 |
tree.lock_read() |
|
1219 |
self.addCleanup(tree.unlock) |
|
|
2592.3.232
by Martin Pool
Disambiguate two member variables called _packs into _packs_by_name and _pack_collection |
1220 |
packs = tree.branch.repository._pack_collection |
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1221 |
packs.ensure_loaded() |
1222 |
self.assertEqual([ |
|
|
2592.3.176
by Robert Collins
Various pack refactorings. |
1223 |
packs.get_pack_by_name(packs.names()[0]), |
1224 |
packs.get_pack_by_name(packs.names()[1]), |
|
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1225 |
], packs.all_packs()) |
1226 |
||
|
2592.3.176
by Robert Collins
Various pack refactorings. |
1227 |
def test_get_pack_by_name(self): |
1228 |
format = self.get_format() |
|
1229 |
tree = self.make_branch_and_tree('.', format=format) |
|
1230 |
tree.commit('start') |
|
1231 |
tree.lock_read() |
|
1232 |
self.addCleanup(tree.unlock) |
|
|
2592.3.232
by Martin Pool
Disambiguate two member variables called _packs into _packs_by_name and _pack_collection |
1233 |
packs = tree.branch.repository._pack_collection |
|
4145.1.6
by Robert Collins
More test fallout, but all caught now. |
1234 |
packs.reset() |
|
2592.3.176
by Robert Collins
Various pack refactorings. |
1235 |
packs.ensure_loaded() |
1236 |
name = packs.names()[0] |
|
1237 |
pack_1 = packs.get_pack_by_name(name) |
|
1238 |
# the pack should be correctly initialised
|
|
|
3517.4.5
by Martin Pool
Correct use of packs._names in test_get_pack_by_name |
1239 |
sizes = packs._names[name] |
|
3221.12.4
by Robert Collins
Implement basic repository supporting external references. |
1240 |
rev_index = GraphIndex(packs._index_transport, name + '.rix', sizes[0]) |
1241 |
inv_index = GraphIndex(packs._index_transport, name + '.iix', sizes[1]) |
|
1242 |
txt_index = GraphIndex(packs._index_transport, name + '.tix', sizes[2]) |
|
1243 |
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. |
1244 |
self.assertEqual(pack_repo.ExistingPack(packs._pack_transport, |
|
2592.3.219
by Robert Collins
Review feedback. |
1245 |
name, rev_index, inv_index, txt_index, sig_index), pack_1) |
|
2592.3.176
by Robert Collins
Various pack refactorings. |
1246 |
# and the same instance should be returned on successive calls.
|
1247 |
self.assertTrue(pack_1 is packs.get_pack_by_name(name)) |
|
1248 |
||
|
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1249 |
def test_reload_pack_names_new_entry(self): |
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1250 |
tree, r, packs, revs = self.make_packs_and_alt_repo() |
|
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1251 |
names = packs.names() |
1252 |
# Add a new pack file into the repository
|
|
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1253 |
rev4 = tree.commit('four') |
|
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1254 |
new_names = tree.branch.repository._pack_collection.names() |
1255 |
new_name = set(new_names).difference(names) |
|
1256 |
self.assertEqual(1, len(new_name)) |
|
1257 |
new_name = new_name.pop() |
|
1258 |
# The old collection hasn't noticed yet
|
|
1259 |
self.assertEqual(names, packs.names()) |
|
|
3789.1.8
by John Arbash Meinel
Change the api of reload_pack_names(). |
1260 |
self.assertTrue(packs.reload_pack_names()) |
|
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1261 |
self.assertEqual(new_names, packs.names()) |
1262 |
# And the repository can access the new revision
|
|
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1263 |
self.assertEqual({rev4:(revs[-1],)}, r.get_parent_map([rev4])) |
|
3789.1.8
by John Arbash Meinel
Change the api of reload_pack_names(). |
1264 |
self.assertFalse(packs.reload_pack_names()) |
|
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1265 |
|
1266 |
def test_reload_pack_names_added_and_removed(self): |
|
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1267 |
tree, r, packs, revs = self.make_packs_and_alt_repo() |
|
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1268 |
names = packs.names() |
1269 |
# Now repack the whole thing
|
|
1270 |
tree.branch.repository.pack() |
|
1271 |
new_names = tree.branch.repository._pack_collection.names() |
|
1272 |
# The other collection hasn't noticed yet
|
|
1273 |
self.assertEqual(names, packs.names()) |
|
|
3789.1.8
by John Arbash Meinel
Change the api of reload_pack_names(). |
1274 |
self.assertTrue(packs.reload_pack_names()) |
|
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1275 |
self.assertEqual(new_names, packs.names()) |
|
3789.2.19
by John Arbash Meinel
Refactor to make the tests a bit simpler |
1276 |
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(). |
1277 |
self.assertFalse(packs.reload_pack_names()) |
|
3789.1.2
by John Arbash Meinel
Add RepositoryPackCollection.reload_pack_names() |
1278 |
|
|
4634.126.1
by John Arbash Meinel
(jam) Fix bug #507566, concurrent autopacking correctness. |
1279 |
def test_reload_pack_names_preserves_pending(self): |
1280 |
# TODO: Update this to also test for pending-deleted names
|
|
1281 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1282 |
# We will add one pack (via start_write_group + insert_record_stream),
|
|
1283 |
# and remove another pack (via _remove_pack_from_memory)
|
|
1284 |
orig_names = packs.names() |
|
1285 |
orig_at_load = packs._packs_at_load |
|
|
6634.2.1
by Martin
Apply 2to3 next fixer and make compatible |
1286 |
to_remove_name = next(iter(orig_names)) |
|
4634.126.1
by John Arbash Meinel
(jam) Fix bug #507566, concurrent autopacking correctness. |
1287 |
r.start_write_group() |
1288 |
self.addCleanup(r.abort_write_group) |
|
1289 |
r.texts.insert_record_stream([versionedfile.FulltextContentFactory( |
|
|
7027.3.3
by Jelmer Vernooij
Add some more bees; support writing both bytes and unicode strings in build_tree_contents. |
1290 |
(b'text', b'rev'), (), None, b'content\n')]) |
|
4634.126.1
by John Arbash Meinel
(jam) Fix bug #507566, concurrent autopacking correctness. |
1291 |
new_pack = packs._new_pack |
1292 |
self.assertTrue(new_pack.data_inserted()) |
|
1293 |
new_pack.finish() |
|
1294 |
packs.allocate(new_pack) |
|
1295 |
packs._new_pack = None |
|
1296 |
removed_pack = packs.get_pack_by_name(to_remove_name) |
|
1297 |
packs._remove_pack_from_memory(removed_pack) |
|
1298 |
names = packs.names() |
|
|
4634.127.3
by John Arbash Meinel
Add code so we don't try to obsolete files someone else has 'claimed'. |
1299 |
all_nodes, deleted_nodes, new_nodes, _ = packs._diff_pack_names() |
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1300 |
new_names = {x[0][0] for x in new_nodes} |
|
4634.126.1
by John Arbash Meinel
(jam) Fix bug #507566, concurrent autopacking correctness. |
1301 |
self.assertEqual(names, sorted([x[0][0] for x in all_nodes])) |
1302 |
self.assertEqual(set(names) - set(orig_names), new_names) |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1303 |
self.assertEqual({new_pack.name}, new_names) |
|
4634.126.1
by John Arbash Meinel
(jam) Fix bug #507566, concurrent autopacking correctness. |
1304 |
self.assertEqual([to_remove_name], |
1305 |
sorted([x[0][0] for x in deleted_nodes])) |
|
1306 |
packs.reload_pack_names() |
|
1307 |
reloaded_names = packs.names() |
|
1308 |
self.assertEqual(orig_at_load, packs._packs_at_load) |
|
1309 |
self.assertEqual(names, reloaded_names) |
|
|
4634.127.3
by John Arbash Meinel
Add code so we don't try to obsolete files someone else has 'claimed'. |
1310 |
all_nodes, deleted_nodes, new_nodes, _ = packs._diff_pack_names() |
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1311 |
new_names = {x[0][0] for x in new_nodes} |
|
4634.126.1
by John Arbash Meinel
(jam) Fix bug #507566, concurrent autopacking correctness. |
1312 |
self.assertEqual(names, sorted([x[0][0] for x in all_nodes])) |
1313 |
self.assertEqual(set(names) - set(orig_names), new_names) |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1314 |
self.assertEqual({new_pack.name}, new_names) |
|
4634.126.1
by John Arbash Meinel
(jam) Fix bug #507566, concurrent autopacking correctness. |
1315 |
self.assertEqual([to_remove_name], |
1316 |
sorted([x[0][0] for x in deleted_nodes])) |
|
1317 |
||
|
4634.127.5
by John Arbash Meinel
Possible fix for making sure packs triggering autopacking get cleaned up. |
1318 |
def test_autopack_obsoletes_new_pack(self): |
1319 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1320 |
packs._max_pack_count = lambda x: 1 |
|
1321 |
packs.pack_distribution = lambda x: [10] |
|
1322 |
r.start_write_group() |
|
1323 |
r.revisions.insert_record_stream([versionedfile.FulltextContentFactory( |
|
1324 |
('bogus-rev',), (), None, 'bogus-content\n')]) |
|
1325 |
# This should trigger an autopack, which will combine everything into a
|
|
1326 |
# single pack file.
|
|
1327 |
new_names = r.commit_write_group() |
|
1328 |
names = packs.names() |
|
1329 |
self.assertEqual(1, len(names)) |
|
1330 |
self.assertEqual([names[0] + '.pack'], |
|
1331 |
packs._pack_transport.list_dir('.')) |
|
1332 |
||
|
3789.2.20
by John Arbash Meinel
The autopack code can now trigger itself to retry when _copy_revision_texts fails. |
1333 |
def test_autopack_reloads_and_stops(self): |
1334 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1335 |
# After we have determined what needs to be autopacked, trigger a
|
|
1336 |
# full-pack via the other repo which will cause us to re-evaluate and
|
|
1337 |
# decide we don't need to do anything
|
|
1338 |
orig_execute = packs._execute_pack_operations |
|
1339 |
def _munged_execute_pack_ops(*args, **kwargs): |
|
1340 |
tree.branch.repository.pack() |
|
1341 |
return orig_execute(*args, **kwargs) |
|
1342 |
packs._execute_pack_operations = _munged_execute_pack_ops |
|
1343 |
packs._max_pack_count = lambda x: 1 |
|
1344 |
packs.pack_distribution = lambda x: [10] |
|
1345 |
self.assertFalse(packs.autopack()) |
|
1346 |
self.assertEqual(1, len(packs.names())) |
|
1347 |
self.assertEqual(tree.branch.repository._pack_collection.names(), |
|
1348 |
packs.names()) |
|
1349 |
||
|
4634.127.1
by John Arbash Meinel
Partial fix for bug #507557. |
1350 |
def test__save_pack_names(self): |
1351 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1352 |
names = packs.names() |
|
1353 |
pack = packs.get_pack_by_name(names[0]) |
|
1354 |
packs._remove_pack_from_memory(pack) |
|
1355 |
packs._save_pack_names(obsolete_packs=[pack]) |
|
1356 |
cur_packs = packs._pack_transport.list_dir('.') |
|
1357 |
self.assertEqual([n + '.pack' for n in names[1:]], sorted(cur_packs)) |
|
1358 |
# obsolete_packs will also have stuff like .rix and .iix present.
|
|
1359 |
obsolete_packs = packs.transport.list_dir('obsolete_packs') |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1360 |
obsolete_names = {osutils.splitext(n)[0] for n in obsolete_packs} |
|
4634.127.1
by John Arbash Meinel
Partial fix for bug #507557. |
1361 |
self.assertEqual([pack.name], sorted(obsolete_names)) |
1362 |
||
1363 |
def test__save_pack_names_already_obsoleted(self): |
|
1364 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1365 |
names = packs.names() |
|
1366 |
pack = packs.get_pack_by_name(names[0]) |
|
1367 |
packs._remove_pack_from_memory(pack) |
|
1368 |
# We are going to simulate a concurrent autopack by manually obsoleting
|
|
1369 |
# the pack directly.
|
|
1370 |
packs._obsolete_packs([pack]) |
|
1371 |
packs._save_pack_names(clear_obsolete_packs=True, |
|
1372 |
obsolete_packs=[pack]) |
|
1373 |
cur_packs = packs._pack_transport.list_dir('.') |
|
1374 |
self.assertEqual([n + '.pack' for n in names[1:]], sorted(cur_packs)) |
|
1375 |
# Note that while we set clear_obsolete_packs=True, it should not
|
|
1376 |
# delete a pack file that we have also scheduled for obsoletion.
|
|
1377 |
obsolete_packs = packs.transport.list_dir('obsolete_packs') |
|
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
1378 |
obsolete_names = {osutils.splitext(n)[0] for n in obsolete_packs} |
|
4634.127.1
by John Arbash Meinel
Partial fix for bug #507557. |
1379 |
self.assertEqual([pack.name], sorted(obsolete_names)) |
1380 |
||
|
6225.2.6
by Jelmer Vernooij
Move pack clear test to test_repository. |
1381 |
def test_pack_no_obsolete_packs_directory(self): |
1382 |
"""Bug #314314, don't fail if obsolete_packs directory does |
|
1383 |
not exist."""
|
|
1384 |
tree, r, packs, revs = self.make_packs_and_alt_repo(write_lock=True) |
|
1385 |
r.control_transport.rmdir('obsolete_packs') |
|
1386 |
packs._clear_obsolete_packs() |
|
|
4634.127.3
by John Arbash Meinel
Add code so we don't try to obsolete files someone else has 'claimed'. |
1387 |
|
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1388 |
|
1389 |
class TestPack(TestCaseWithTransport): |
|
1390 |
"""Tests for the Pack object.""" |
|
1391 |
||
1392 |
def assertCurrentlyEqual(self, left, right): |
|
1393 |
self.assertTrue(left == right) |
|
1394 |
self.assertTrue(right == left) |
|
1395 |
self.assertFalse(left != right) |
|
1396 |
self.assertFalse(right != left) |
|
1397 |
||
1398 |
def assertCurrentlyNotEqual(self, left, right): |
|
1399 |
self.assertFalse(left == right) |
|
1400 |
self.assertFalse(right == left) |
|
1401 |
self.assertTrue(left != right) |
|
1402 |
self.assertTrue(right != left) |
|
1403 |
||
1404 |
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. |
1405 |
left = pack_repo.ExistingPack('', '', '', '', '', '') |
1406 |
right = pack_repo.ExistingPack('', '', '', '', '', '') |
|
|
2592.3.173
by Robert Collins
Basic implementation of all_packs. |
1407 |
self.assertCurrentlyEqual(left, right) |
1408 |
# change all attributes and ensure equality changes as we do.
|
|
1409 |
left.revision_index = 'a' |
|
1410 |
self.assertCurrentlyNotEqual(left, right) |
|
1411 |
right.revision_index = 'a' |
|
1412 |
self.assertCurrentlyEqual(left, right) |
|
1413 |
left.inventory_index = 'a' |
|
1414 |
self.assertCurrentlyNotEqual(left, right) |
|
1415 |
right.inventory_index = 'a' |
|
1416 |
self.assertCurrentlyEqual(left, right) |
|
1417 |
left.text_index = 'a' |
|
1418 |
self.assertCurrentlyNotEqual(left, right) |
|
1419 |
right.text_index = 'a' |
|
1420 |
self.assertCurrentlyEqual(left, right) |
|
1421 |
left.signature_index = 'a' |
|
1422 |
self.assertCurrentlyNotEqual(left, right) |
|
1423 |
right.signature_index = 'a' |
|
1424 |
self.assertCurrentlyEqual(left, right) |
|
1425 |
left.name = 'a' |
|
1426 |
self.assertCurrentlyNotEqual(left, right) |
|
1427 |
right.name = 'a' |
|
1428 |
self.assertCurrentlyEqual(left, right) |
|
1429 |
left.transport = 'a' |
|
1430 |
self.assertCurrentlyNotEqual(left, right) |
|
1431 |
right.transport = 'a' |
|
1432 |
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. |
1433 |
|
1434 |
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. |
1435 |
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. |
1436 |
self.assertEqual('a_name.pack', pack.file_name()) |
|
2592.3.192
by Robert Collins
Move new revision index management to NewPack. |
1437 |
|
1438 |
||
1439 |
class TestNewPack(TestCaseWithTransport): |
|
1440 |
"""Tests for pack_repo.NewPack.""" |
|
1441 |
||
|
2592.3.193
by Robert Collins
Move hash tracking of new packs into NewPack. |
1442 |
def test_new_instance_attributes(self): |
|
2592.3.194
by Robert Collins
Output the revision index from NewPack.finish |
1443 |
upload_transport = self.get_transport('upload') |
1444 |
pack_transport = self.get_transport('pack') |
|
1445 |
index_transport = self.get_transport('index') |
|
1446 |
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) |
1447 |
collection = pack_repo.RepositoryPackCollection( |
1448 |
repo=None, |
|
|
3830.3.1
by Martin Pool
NewPack should be constructed from the PackCollection, rather than attributes of it |
1449 |
transport=self.get_transport('.'), |
1450 |
index_transport=index_transport, |
|
1451 |
upload_transport=upload_transport, |
|
1452 |
pack_transport=pack_transport, |
|
1453 |
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) |
1454 |
index_class=BTreeGraphIndex, |
1455 |
use_chk_index=False) |
|
|
3830.3.1
by Martin Pool
NewPack should be constructed from the PackCollection, rather than attributes of it |
1456 |
pack = pack_repo.NewPack(collection) |
|
4857.2.1
by John Arbash Meinel
2 test_repository tests weren't adding cleanups when opening files. |
1457 |
self.addCleanup(pack.abort) # Make sure the write stream gets closed |
|
3735.1.1
by Robert Collins
Add development2 formats using BTree indices. |
1458 |
self.assertIsInstance(pack.revision_index, BTreeBuilder) |
1459 |
self.assertIsInstance(pack.inventory_index, BTreeBuilder) |
|
|
2929.3.5
by Vincent Ladeuil
New files, same warnings, same fixes. |
1460 |
self.assertIsInstance(pack._hash, type(osutils.md5())) |
|
2592.3.194
by Robert Collins
Output the revision index from NewPack.finish |
1461 |
self.assertTrue(pack.upload_transport is upload_transport) |
1462 |
self.assertTrue(pack.index_transport is index_transport) |
|
1463 |
self.assertTrue(pack.pack_transport is pack_transport) |
|
1464 |
self.assertEqual(None, pack.index_sizes) |
|
1465 |
self.assertEqual(20, len(pack.random_name)) |
|
1466 |
self.assertIsInstance(pack.random_name, str) |
|
1467 |
self.assertIsInstance(pack.start_time, float) |
|
|
2951.1.2
by Robert Collins
Partial refactoring of pack_repo to create a Packer object for packing. |
1468 |
|
1469 |
||
1470 |
class TestPacker(TestCaseWithTransport): |
|
1471 |
"""Tests for the packs repository Packer class.""" |
|
|
2951.1.10
by Robert Collins
Peer review feedback with Ian. |
1472 |
|
|
3824.2.4
by John Arbash Meinel
Add a test that ensures the pack ordering changes as part of calling .pack() |
1473 |
def test_pack_optimizes_pack_order(self): |
|
4617.8.1
by Robert Collins
Lock down another test assuming the default was a PackRepository. |
1474 |
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() |
1475 |
builder.start_series() |
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
1476 |
builder.build_snapshot(None, [ |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1477 |
('add', ('', b'root-id', 'directory', None)), |
1478 |
('add', ('f', b'f-id', 'file', b'content\n'))], |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
1479 |
revision_id=b'A') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1480 |
builder.build_snapshot([b'A'], |
1481 |
[('modify', ('f', b'new-content\n'))], |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
1482 |
revision_id=b'B') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1483 |
builder.build_snapshot([b'B'], |
1484 |
[('modify', ('f', b'third-content\n'))], |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
1485 |
revision_id=b'C') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1486 |
builder.build_snapshot([b'C'], |
1487 |
[('modify', ('f', b'fourth-content\n'))], |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
1488 |
revision_id=b'D') |
|
3824.2.4
by John Arbash Meinel
Add a test that ensures the pack ordering changes as part of calling .pack() |
1489 |
b = builder.get_branch() |
1490 |
b.lock_read() |
|
1491 |
builder.finish_series() |
|
1492 |
self.addCleanup(b.unlock) |
|
1493 |
# At this point, we should have 4 pack files available
|
|
1494 |
# Because of how they were built, they correspond to
|
|
1495 |
# ['D', 'C', 'B', 'A']
|
|
1496 |
packs = b.repository._pack_collection.packs |
|
|
5757.7.5
by Jelmer Vernooij
Fix imports in tests. |
1497 |
packer = knitpack_repo.KnitPacker(b.repository._pack_collection, |
|
3824.2.4
by John Arbash Meinel
Add a test that ensures the pack ordering changes as part of calling .pack() |
1498 |
packs, 'testing', |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1499 |
revision_ids=[b'B', b'C']) |
|
3824.2.4
by John Arbash Meinel
Add a test that ensures the pack ordering changes as part of calling .pack() |
1500 |
# Now, when we are copying the B & C revisions, their pack files should
|
1501 |
# be moved to the front of the stack
|
|
|
3824.2.5
by Andrew Bennetts
Minor tweaks to comments etc. |
1502 |
# The new ordering moves B & C to the front of the .packs attribute,
|
1503 |
# 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() |
1504 |
new_packs = [packs[1], packs[2], packs[0], packs[3]] |
1505 |
new_pack = packer.pack() |
|
1506 |
self.assertEqual(new_packs, packer.packs) |
|
|
3146.6.1
by Aaron Bentley
InterDifferingSerializer shows a progress bar |
1507 |
|
1508 |
||
|
3777.5.4
by John Arbash Meinel
OptimisingPacker now sets the optimize flags for the indexes being built. |
1509 |
class TestOptimisingPacker(TestCaseWithTransport): |
1510 |
"""Tests for the OptimisingPacker class.""" |
|
1511 |
||
1512 |
def get_pack_collection(self): |
|
1513 |
repo = self.make_repository('.') |
|
1514 |
return repo._pack_collection |
|
1515 |
||
1516 |
def test_open_pack_will_optimise(self): |
|
|
5757.7.3
by Jelmer Vernooij
Move more knitpack-specific functionality out of Packer. |
1517 |
packer = knitpack_repo.OptimisingKnitPacker(self.get_pack_collection(), |
|
3777.5.4
by John Arbash Meinel
OptimisingPacker now sets the optimize flags for the indexes being built. |
1518 |
[], '.test') |
1519 |
new_pack = packer.open_pack() |
|
|
4857.2.1
by John Arbash Meinel
2 test_repository tests weren't adding cleanups when opening files. |
1520 |
self.addCleanup(new_pack.abort) # ensure cleanup |
|
3777.5.4
by John Arbash Meinel
OptimisingPacker now sets the optimize flags for the indexes being built. |
1521 |
self.assertIsInstance(new_pack, pack_repo.NewPack) |
1522 |
self.assertTrue(new_pack.revision_index._optimize_for_size) |
|
1523 |
self.assertTrue(new_pack.inventory_index._optimize_for_size) |
|
1524 |
self.assertTrue(new_pack.text_index._optimize_for_size) |
|
1525 |
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. |
1526 |
|
1527 |
||
|
4634.170.1
by John Arbash Meinel
Fix bug #437003. Autopacking should not fail for an |
1528 |
class TestGCCHKPacker(TestCaseWithTransport): |
1529 |
||
1530 |
def make_abc_branch(self): |
|
1531 |
builder = self.make_branch_builder('source') |
|
1532 |
builder.start_series() |
|
|
6816.2.3
by Jelmer Vernooij
Port over last uses of build_snapshot. |
1533 |
builder.build_snapshot(None, [ |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1534 |
('add', ('', b'root-id', 'directory', None)), |
1535 |
('add', ('file', b'file-id', 'file', b'content\n')), |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
1536 |
], revision_id=b'A') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1537 |
builder.build_snapshot([b'A'], [ |
1538 |
('add', ('dir', b'dir-id', 'directory', None))], |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
1539 |
revision_id=b'B') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
1540 |
builder.build_snapshot([b'B'], [ |
1541 |
('modify', ('file', b'new content\n'))], |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
1542 |
revision_id=b'C') |
|
4634.170.1
by John Arbash Meinel
Fix bug #437003. Autopacking should not fail for an |
1543 |
builder.finish_series() |
1544 |
return builder.get_branch() |
|
1545 |
||
1546 |
def make_branch_with_disjoint_inventory_and_revision(self): |
|
1547 |
"""a repo with separate packs for a revisions Revision and Inventory. |
|
1548 |
||
1549 |
There will be one pack file that holds the Revision content, and one
|
|
1550 |
for the Inventory content.
|
|
1551 |
||
1552 |
:return: (repository,
|
|
1553 |
pack_name_with_rev_A_Revision,
|
|
1554 |
pack_name_with_rev_A_Inventory,
|
|
1555 |
pack_name_with_rev_C_content)
|
|
1556 |
"""
|
|
1557 |
b_source = self.make_abc_branch() |
|
|
6973.5.2
by Jelmer Vernooij
Add more bees. |
1558 |
b_base = b_source.controldir.sprout('base', revision_id=b'A').open_branch() |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
1559 |
b_stacked = b_base.controldir.sprout('stacked', stacked=True).open_branch() |
|
4634.170.1
by John Arbash Meinel
Fix bug #437003. Autopacking should not fail for an |
1560 |
b_stacked.lock_write() |
1561 |
self.addCleanup(b_stacked.unlock) |
|
1562 |
b_stacked.fetch(b_source, 'B') |
|
1563 |
# Now re-open the stacked repo directly (no fallbacks) so that we can
|
|
1564 |
# fill in the A rev.
|
|
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
1565 |
repo_not_stacked = b_stacked.controldir.open_repository() |
|
4634.170.1
by John Arbash Meinel
Fix bug #437003. Autopacking should not fail for an |
1566 |
repo_not_stacked.lock_write() |
1567 |
self.addCleanup(repo_not_stacked.unlock) |
|
1568 |
# Now we should have a pack file with A's inventory, but not its
|
|
1569 |
# Revision
|
|
1570 |
self.assertEqual([('A',), ('B',)], |
|
1571 |
sorted(repo_not_stacked.inventories.keys())) |
|
1572 |
self.assertEqual([('B',)], |
|
1573 |
sorted(repo_not_stacked.revisions.keys())) |
|
1574 |
stacked_pack_names = repo_not_stacked._pack_collection.names() |
|
1575 |
# We have a couple names here, figure out which has A's inventory
|
|
1576 |
for name in stacked_pack_names: |
|
1577 |
pack = repo_not_stacked._pack_collection.get_pack_by_name(name) |
|
1578 |
keys = [n[1] for n in pack.inventory_index.iter_all_entries()] |
|
1579 |
if ('A',) in keys: |
|
1580 |
inv_a_pack_name = name |
|
1581 |
break
|
|
1582 |
else: |
|
1583 |
self.fail('Could not find pack containing A\'s inventory') |
|
1584 |
repo_not_stacked.fetch(b_source.repository, 'A') |
|
1585 |
self.assertEqual([('A',), ('B',)], |
|
1586 |
sorted(repo_not_stacked.revisions.keys())) |
|
1587 |
new_pack_names = set(repo_not_stacked._pack_collection.names()) |
|
1588 |
rev_a_pack_names = new_pack_names.difference(stacked_pack_names) |
|
1589 |
self.assertEqual(1, len(rev_a_pack_names)) |
|
1590 |
rev_a_pack_name = list(rev_a_pack_names)[0] |
|
1591 |
# Now fetch 'C', so we have a couple pack files to join
|
|
1592 |
repo_not_stacked.fetch(b_source.repository, 'C') |
|
1593 |
rev_c_pack_names = set(repo_not_stacked._pack_collection.names()) |
|
1594 |
rev_c_pack_names = rev_c_pack_names.difference(new_pack_names) |
|
1595 |
self.assertEqual(1, len(rev_c_pack_names)) |
|
1596 |
rev_c_pack_name = list(rev_c_pack_names)[0] |
|
1597 |
return (repo_not_stacked, rev_a_pack_name, inv_a_pack_name, |
|
1598 |
rev_c_pack_name) |
|
1599 |
||
1600 |
def test_pack_with_distant_inventories(self): |
|
1601 |
# See https://bugs.launchpad.net/bzr/+bug/437003
|
|
1602 |
# When repacking, it is possible to have an inventory in a different
|
|
1603 |
# pack file than the associated revision. An autopack can then come
|
|
1604 |
# along, and miss that inventory, and complain.
|
|
1605 |
(repo, rev_a_pack_name, inv_a_pack_name, rev_c_pack_name |
|
1606 |
) = self.make_branch_with_disjoint_inventory_and_revision() |
|
1607 |
a_pack = repo._pack_collection.get_pack_by_name(rev_a_pack_name) |
|
1608 |
c_pack = repo._pack_collection.get_pack_by_name(rev_c_pack_name) |
|
1609 |
packer = groupcompress_repo.GCCHKPacker(repo._pack_collection, |
|
1610 |
[a_pack, c_pack], '.test-pack') |
|
1611 |
# This would raise ValueError in bug #437003, but should not raise an
|
|
1612 |
# error once fixed.
|
|
1613 |
packer.pack() |
|
1614 |
||
1615 |
def test_pack_with_missing_inventory(self): |
|
1616 |
# Similar to test_pack_with_missing_inventory, but this time, we force
|
|
1617 |
# the A inventory to actually be gone from the repository.
|
|
1618 |
(repo, rev_a_pack_name, inv_a_pack_name, rev_c_pack_name |
|
1619 |
) = self.make_branch_with_disjoint_inventory_and_revision() |
|
1620 |
inv_a_pack = repo._pack_collection.get_pack_by_name(inv_a_pack_name) |
|
1621 |
repo._pack_collection._remove_pack_from_memory(inv_a_pack) |
|
1622 |
packer = groupcompress_repo.GCCHKPacker(repo._pack_collection, |
|
1623 |
repo._pack_collection.all_packs(), '.test-pack') |
|
1624 |
e = self.assertRaises(ValueError, packer.pack) |
|
1625 |
packer.new_pack.abort() |
|
|
4634.170.2
by John Arbash Meinel
Loosen the match a bit. Newer versions have StaticTuple. |
1626 |
self.assertContainsRe(str(e), |
1627 |
r"We are missing inventories for revisions: .*'A'") |
|
|
4634.170.1
by John Arbash Meinel
Fix bug #437003. Autopacking should not fail for an |
1628 |
|
1629 |
||
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
1630 |
class TestCrossFormatPacks(TestCaseWithTransport): |
1631 |
||
1632 |
def log_pack(self, hint=None): |
|
1633 |
self.calls.append(('pack', hint)) |
|
1634 |
self.orig_pack(hint=hint) |
|
1635 |
if self.expect_hint: |
|
1636 |
self.assertTrue(hint) |
|
1637 |
||
1638 |
def run_stream(self, src_fmt, target_fmt, expect_pack_called): |
|
1639 |
self.expect_hint = expect_pack_called |
|
1640 |
self.calls = [] |
|
1641 |
source_tree = self.make_branch_and_tree('src', format=src_fmt) |
|
1642 |
source_tree.lock_write() |
|
1643 |
self.addCleanup(source_tree.unlock) |
|
1644 |
tip = source_tree.commit('foo') |
|
1645 |
target = self.make_repository('target', format=target_fmt) |
|
1646 |
target.lock_write() |
|
1647 |
self.addCleanup(target.unlock) |
|
1648 |
source = source_tree.branch.repository._get_source(target._format) |
|
1649 |
self.orig_pack = target.pack |
|
|
5340.15.1
by John Arbash Meinel
supersede exc-info branch |
1650 |
self.overrideAttr(target, "pack", self.log_pack) |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
1651 |
search = target.search_missing_revision_ids( |
|
5539.2.11
by Andrew Bennetts
Fix deprecation warning from test suite. |
1652 |
source_tree.branch.repository, revision_ids=[tip]) |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
1653 |
stream = source.get_stream(search) |
1654 |
from_format = source_tree.branch.repository._format |
|
1655 |
sink = target._get_sink() |
|
1656 |
sink.insert_stream(stream, from_format, []) |
|
1657 |
if expect_pack_called: |
|
1658 |
self.assertLength(1, self.calls) |
|
1659 |
else: |
|
1660 |
self.assertLength(0, self.calls) |
|
1661 |
||
1662 |
def run_fetch(self, src_fmt, target_fmt, expect_pack_called): |
|
1663 |
self.expect_hint = expect_pack_called |
|
1664 |
self.calls = [] |
|
1665 |
source_tree = self.make_branch_and_tree('src', format=src_fmt) |
|
1666 |
source_tree.lock_write() |
|
1667 |
self.addCleanup(source_tree.unlock) |
|
1668 |
tip = source_tree.commit('foo') |
|
1669 |
target = self.make_repository('target', format=target_fmt) |
|
1670 |
target.lock_write() |
|
1671 |
self.addCleanup(target.unlock) |
|
1672 |
source = source_tree.branch.repository |
|
1673 |
self.orig_pack = target.pack |
|
|
5340.15.1
by John Arbash Meinel
supersede exc-info branch |
1674 |
self.overrideAttr(target, "pack", self.log_pack) |
|
4431.3.7
by Jonathan Lange
Cherrypick bzr.dev 4470, resolving conflicts. |
1675 |
target.fetch(source) |
1676 |
if expect_pack_called: |
|
1677 |
self.assertLength(1, self.calls) |
|
1678 |
else: |
|
1679 |
self.assertLength(0, self.calls) |
|
1680 |
||
1681 |
def test_sink_format_hint_no(self): |
|
1682 |
# When the target format says packing makes no difference, pack is not
|
|
1683 |
# called.
|
|
1684 |
self.run_stream('1.9', 'rich-root-pack', False) |
|
1685 |
||
1686 |
def test_sink_format_hint_yes(self): |
|
1687 |
# When the target format says packing makes a difference, pack is
|
|
1688 |
# called.
|
|
1689 |
self.run_stream('1.9', '2a', True) |
|
1690 |
||
1691 |
def test_sink_format_same_no(self): |
|
1692 |
# When the formats are the same, pack is not called.
|
|
1693 |
self.run_stream('2a', '2a', False) |
|
1694 |
||
1695 |
def test_IDS_format_hint_no(self): |
|
1696 |
# When the target format says packing makes no difference, pack is not
|
|
1697 |
# called.
|
|
1698 |
self.run_fetch('1.9', 'rich-root-pack', False) |
|
1699 |
||
1700 |
def test_IDS_format_hint_yes(self): |
|
1701 |
# When the target format says packing makes a difference, pack is
|
|
1702 |
# called.
|
|
1703 |
self.run_fetch('1.9', '2a', True) |
|
1704 |
||
1705 |
def test_IDS_format_same_no(self): |
|
1706 |
# When the formats are the same, pack is not called.
|
|
1707 |
self.run_fetch('2a', '2a', False) |
|
|
6015.20.1
by John Arbash Meinel
Add a __repr__ to _LazyListJoin to make it easier to debug. |
1708 |
|
1709 |
||
1710 |
class Test_LazyListJoin(tests.TestCase): |
|
1711 |
||
1712 |
def test__repr__(self): |
|
1713 |
lazy = repository._LazyListJoin(['a'], ['b']) |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
1714 |
self.assertEqual("breezy.repository._LazyListJoin((['a'], ['b']))", |
|
6015.20.1
by John Arbash Meinel
Add a __repr__ to _LazyListJoin to make it easier to debug. |
1715 |
repr(lazy)) |
|
6213.1.21
by Jelmer Vernooij
Add feature support for repository. |
1716 |
|
1717 |
||
1718 |
class TestFeatures(tests.TestCaseWithTransport): |
|
1719 |
||
1720 |
def test_open_with_present_feature(self): |
|
1721 |
self.addCleanup( |
|
|
6653.2.2
by Jelmer Vernooij
Fix imports. |
1722 |
bzrrepository.RepositoryFormatMetaDir.unregister_feature, |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
1723 |
b"makes-cheese-sandwich") |
|
6653.2.2
by Jelmer Vernooij
Fix imports. |
1724 |
bzrrepository.RepositoryFormatMetaDir.register_feature( |
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
1725 |
b"makes-cheese-sandwich") |
|
6213.1.21
by Jelmer Vernooij
Add feature support for repository. |
1726 |
repo = self.make_repository('.') |
1727 |
repo.lock_write() |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
1728 |
repo._format.features[b"makes-cheese-sandwich"] = b"required" |
|
6213.1.21
by Jelmer Vernooij
Add feature support for repository. |
1729 |
repo._format.check_support_status(False) |
1730 |
repo.unlock() |
|
1731 |
||
1732 |
def test_open_with_missing_required_feature(self): |
|
1733 |
repo = self.make_repository('.') |
|
1734 |
repo.lock_write() |
|
|
6855.4.5
by Jelmer Vernooij
Fix more bees, use with rather than try/finally for some files. |
1735 |
repo._format.features[b"makes-cheese-sandwich"] = b"required" |
|
6731.1.3
by Jelmer Vernooij
Move MissingFeature error to breezy.bzr.bzrdir. |
1736 |
self.assertRaises(bzrdir.MissingFeature, |
|
6213.1.21
by Jelmer Vernooij
Add feature support for repository. |
1737 |
repo._format.check_support_status, False) |