1
# Copyright (C) 2007-2011 Canonical Ltd
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.
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.
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
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
"""Knit-based pack repository formats."""
19
from bzrlib.lazy_import import lazy_import
20
lazy_import(globals(), """
32
from bzrlib.index import (
36
from bzrlib.repofmt.pack_repo import (
40
PackRootCommitBuilder,
44
class RepositoryFormatKnitPack1(RepositoryFormatPack):
45
"""A no-subtrees parameterized Pack repository.
47
This format was introduced in 0.92.
50
repository_class = KnitPackRepository
51
_commit_builder_class = PackCommitBuilder
53
def _serializer(self):
54
return xml5.serializer_v5
55
# What index classes to use
56
index_builder_class = InMemoryGraphIndex
57
index_class = GraphIndex
59
def _get_matching_bzrdir(self):
60
return bzrdir.format_registry.make_bzrdir('pack-0.92')
62
def _ignore_setting_bzrdir(self, format):
65
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
67
def get_format_string(self):
68
"""See RepositoryFormat.get_format_string()."""
69
return "Bazaar pack repository format 1 (needs bzr 0.92)\n"
71
def get_format_description(self):
72
"""See RepositoryFormat.get_format_description()."""
73
return "Packs containing knits without subtree support"
76
class RepositoryFormatKnitPack3(RepositoryFormatPack):
77
"""A subtrees parameterized Pack repository.
79
This repository format uses the xml7 serializer to get:
80
- support for recording full info about the tree root
81
- support for recording tree-references
83
This format was introduced in 0.92.
86
repository_class = KnitPackRepository
87
_commit_builder_class = PackRootCommitBuilder
90
supports_tree_reference = True
92
def _serializer(self):
93
return xml7.serializer_v7
94
# What index classes to use
95
index_builder_class = InMemoryGraphIndex
96
index_class = GraphIndex
98
def _get_matching_bzrdir(self):
99
return bzrdir.format_registry.make_bzrdir(
102
def _ignore_setting_bzrdir(self, format):
105
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
107
def get_format_string(self):
108
"""See RepositoryFormat.get_format_string()."""
109
return "Bazaar pack repository format 1 with subtree support (needs bzr 0.92)\n"
111
def get_format_description(self):
112
"""See RepositoryFormat.get_format_description()."""
113
return "Packs containing knits with subtree support\n"
116
class RepositoryFormatKnitPack4(RepositoryFormatPack):
117
"""A rich-root, no subtrees parameterized Pack repository.
119
This repository format uses the xml6 serializer to get:
120
- support for recording full info about the tree root
122
This format was introduced in 1.0.
125
repository_class = KnitPackRepository
126
_commit_builder_class = PackRootCommitBuilder
127
rich_root_data = True
128
supports_tree_reference = False
130
def _serializer(self):
131
return xml6.serializer_v6
132
# What index classes to use
133
index_builder_class = InMemoryGraphIndex
134
index_class = GraphIndex
136
def _get_matching_bzrdir(self):
137
return bzrdir.format_registry.make_bzrdir(
140
def _ignore_setting_bzrdir(self, format):
143
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
145
def get_format_string(self):
146
"""See RepositoryFormat.get_format_string()."""
147
return ("Bazaar pack repository format 1 with rich root"
148
" (needs bzr 1.0)\n")
150
def get_format_description(self):
151
"""See RepositoryFormat.get_format_description()."""
152
return "Packs containing knits with rich root support\n"
155
class RepositoryFormatKnitPack5(RepositoryFormatPack):
156
"""Repository that supports external references to allow stacking.
160
Supports external lookups, which results in non-truncated ghosts after
161
reconcile compared to pack-0.92 formats.
164
repository_class = KnitPackRepository
165
_commit_builder_class = PackCommitBuilder
166
supports_external_lookups = True
167
# What index classes to use
168
index_builder_class = InMemoryGraphIndex
169
index_class = GraphIndex
172
def _serializer(self):
173
return xml5.serializer_v5
175
def _get_matching_bzrdir(self):
176
return bzrdir.format_registry.make_bzrdir('1.6')
178
def _ignore_setting_bzrdir(self, format):
181
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
183
def get_format_string(self):
184
"""See RepositoryFormat.get_format_string()."""
185
return "Bazaar RepositoryFormatKnitPack5 (bzr 1.6)\n"
187
def get_format_description(self):
188
"""See RepositoryFormat.get_format_description()."""
189
return "Packs 5 (adds stacking support, requires bzr 1.6)"
192
class RepositoryFormatKnitPack5RichRoot(RepositoryFormatPack):
193
"""A repository with rich roots and stacking.
195
New in release 1.6.1.
197
Supports stacking on other repositories, allowing data to be accessed
198
without being stored locally.
201
repository_class = KnitPackRepository
202
_commit_builder_class = PackRootCommitBuilder
203
rich_root_data = True
204
supports_tree_reference = False # no subtrees
205
supports_external_lookups = True
206
# What index classes to use
207
index_builder_class = InMemoryGraphIndex
208
index_class = GraphIndex
211
def _serializer(self):
212
return xml6.serializer_v6
214
def _get_matching_bzrdir(self):
215
return bzrdir.format_registry.make_bzrdir(
218
def _ignore_setting_bzrdir(self, format):
221
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
223
def get_format_string(self):
224
"""See RepositoryFormat.get_format_string()."""
225
return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6.1)\n"
227
def get_format_description(self):
228
return "Packs 5 rich-root (adds stacking support, requires bzr 1.6.1)"
231
class RepositoryFormatKnitPack5RichRootBroken(RepositoryFormatPack):
232
"""A repository with rich roots and external references.
236
Supports external lookups, which results in non-truncated ghosts after
237
reconcile compared to pack-0.92 formats.
239
This format was deprecated because the serializer it uses accidentally
240
supported subtrees, when the format was not intended to. This meant that
241
someone could accidentally fetch from an incorrect repository.
244
repository_class = KnitPackRepository
245
_commit_builder_class = PackRootCommitBuilder
246
rich_root_data = True
247
supports_tree_reference = False # no subtrees
249
supports_external_lookups = True
250
# What index classes to use
251
index_builder_class = InMemoryGraphIndex
252
index_class = GraphIndex
255
def _serializer(self):
256
return xml7.serializer_v7
258
def _get_matching_bzrdir(self):
259
matching = bzrdir.format_registry.make_bzrdir(
261
matching.repository_format = self
264
def _ignore_setting_bzrdir(self, format):
267
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
269
def get_format_string(self):
270
"""See RepositoryFormat.get_format_string()."""
271
return "Bazaar RepositoryFormatKnitPack5RichRoot (bzr 1.6)\n"
273
def get_format_description(self):
274
return ("Packs 5 rich-root (adds stacking support, requires bzr 1.6)"
277
def is_deprecated(self):
281
class RepositoryFormatKnitPack6(RepositoryFormatPack):
282
"""A repository with stacking and btree indexes,
283
without rich roots or subtrees.
285
This is equivalent to pack-1.6 with B+Tree indices.
288
repository_class = KnitPackRepository
289
_commit_builder_class = PackCommitBuilder
290
supports_external_lookups = True
291
# What index classes to use
292
index_builder_class = btree_index.BTreeBuilder
293
index_class = btree_index.BTreeGraphIndex
296
def _serializer(self):
297
return xml5.serializer_v5
299
def _get_matching_bzrdir(self):
300
return bzrdir.format_registry.make_bzrdir('1.9')
302
def _ignore_setting_bzrdir(self, format):
305
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
307
def get_format_string(self):
308
"""See RepositoryFormat.get_format_string()."""
309
return "Bazaar RepositoryFormatKnitPack6 (bzr 1.9)\n"
311
def get_format_description(self):
312
"""See RepositoryFormat.get_format_description()."""
313
return "Packs 6 (uses btree indexes, requires bzr 1.9)"
316
class RepositoryFormatKnitPack6RichRoot(RepositoryFormatPack):
317
"""A repository with rich roots, no subtrees, stacking and btree indexes.
319
1.6-rich-root with B+Tree indices.
322
repository_class = KnitPackRepository
323
_commit_builder_class = PackRootCommitBuilder
324
rich_root_data = True
325
supports_tree_reference = False # no subtrees
326
supports_external_lookups = True
327
# What index classes to use
328
index_builder_class = btree_index.BTreeBuilder
329
index_class = btree_index.BTreeGraphIndex
332
def _serializer(self):
333
return xml6.serializer_v6
335
def _get_matching_bzrdir(self):
336
return bzrdir.format_registry.make_bzrdir(
339
def _ignore_setting_bzrdir(self, format):
342
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
344
def get_format_string(self):
345
"""See RepositoryFormat.get_format_string()."""
346
return "Bazaar RepositoryFormatKnitPack6RichRoot (bzr 1.9)\n"
348
def get_format_description(self):
349
return "Packs 6 rich-root (uses btree indexes, requires bzr 1.9)"
352
class RepositoryFormatPackDevelopment2Subtree(RepositoryFormatPack):
353
"""A subtrees development repository.
355
This format should be retained in 2.3, to provide an upgrade path from this
356
to RepositoryFormat2aSubtree. It can be removed in later releases.
358
1.6.1-subtree[as it might have been] with B+Tree indices.
361
repository_class = KnitPackRepository
362
_commit_builder_class = PackRootCommitBuilder
363
rich_root_data = True
365
supports_tree_reference = True
366
supports_external_lookups = True
367
# What index classes to use
368
index_builder_class = btree_index.BTreeBuilder
369
index_class = btree_index.BTreeGraphIndex
372
def _serializer(self):
373
return xml7.serializer_v7
375
def _get_matching_bzrdir(self):
376
return bzrdir.format_registry.make_bzrdir(
377
'development5-subtree')
379
def _ignore_setting_bzrdir(self, format):
382
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
384
def get_format_string(self):
385
"""See RepositoryFormat.get_format_string()."""
386
return ("Bazaar development format 2 with subtree support "
387
"(needs bzr.dev from before 1.8)\n")
389
def get_format_description(self):
390
"""See RepositoryFormat.get_format_description()."""
391
return ("Development repository format, currently the same as "
392
"1.6.1-subtree with B+Tree indices.\n")