1
# Copyright (C) 2007-2010 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
13
13
# You should have received a copy of the GNU General Public License
14
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
17
from bzrlib.lazy_import import lazy_import
18
18
lazy_import(globals(), """
53
53
def __repr__(self):
54
54
return 'KnitParentsProvider(%r)' % self._knit
56
@symbol_versioning.deprecated_method(symbol_versioning.one_one)
57
def get_parents(self, revision_ids):
58
"""See graph._StackedParentsProvider.get_parents"""
59
parent_map = self.get_parent_map(revision_ids)
60
return [parent_map.get(r, None) for r in revision_ids]
56
62
def get_parent_map(self, keys):
57
"""See graph.StackedParentsProvider.get_parent_map"""
63
"""See graph._StackedParentsProvider.get_parent_map"""
59
65
for revision_id in keys:
60
66
if revision_id is None:
85
91
return 'KnitsParentsProvider(%r)' % self._knit
87
93
def get_parent_map(self, keys):
88
"""See graph.StackedParentsProvider.get_parent_map"""
94
"""See graph._StackedParentsProvider.get_parent_map"""
89
95
parent_map = self._knit.get_parent_map(
90
96
[self._prefix + (key,) for key in keys])
229
235
def _make_parents_provider(self):
230
236
return _KnitsParentsProvider(self.revisions)
232
def _find_inconsistent_revision_parents(self, revisions_iterator=None):
238
def _find_inconsistent_revision_parents(self):
233
239
"""Find revisions with different parent lists in the revision object
234
240
and in the index graph.
236
:param revisions_iterator: None, or an iterator of (revid,
237
Revision-or-None). This iterator controls the revisions checked.
238
242
:returns: an iterator yielding tuples of (revison-id, parents-in-index,
239
243
parents-in-revision).
241
245
if not self.is_locked():
242
246
raise AssertionError()
243
247
vf = self.revisions
244
if revisions_iterator is None:
245
revisions_iterator = self._iter_revisions(None)
246
for revid, revision in revisions_iterator:
249
parent_map = vf.get_parent_map([(revid,)])
248
for index_version in vf.keys():
249
parent_map = vf.get_parent_map([index_version])
250
250
parents_according_to_index = tuple(parent[-1] for parent in
251
parent_map[(revid,)])
251
parent_map[index_version])
252
revision = self.get_revision(index_version[-1])
252
253
parents_according_to_revision = tuple(revision.parent_ids)
253
254
if parents_according_to_index != parents_according_to_revision:
254
yield (revid, parents_according_to_index,
255
yield (index_version[-1], parents_according_to_index,
255
256
parents_according_to_revision)
257
258
def _check_for_inconsistent_revision_parents(self):
296
297
supports_ghosts = True
297
298
# External lookups are not supported in this format.
298
299
supports_external_lookups = False
300
supports_chks = False
301
300
_fetch_order = 'topological'
302
301
_fetch_uses_deltas = True
305
303
def _get_inventories(self, repo_transport, repo, name='inventory'):
306
304
mapper = versionedfile.ConstantMapper(name)
342
340
:param shared: If true the repository will be initialized as a shared
345
trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
343
mutter('creating repository in %s.', a_bzrdir.transport.base)
348
346
utf8_files = [('format', self.get_format_string())]
360
358
result.revisions.get_parent_map([('A',)])
361
359
result.signatures.get_parent_map([('A',)])
363
self._run_post_repo_init_hooks(result, a_bzrdir, shared)
366
363
def open(self, a_bzrdir, _found=False, _override_transport=None):
387
384
repo.signatures = self._get_signatures(repo_transport, repo)
388
385
repo.inventories = self._get_inventories(repo_transport, repo)
389
386
repo.texts = self._get_texts(repo_transport, repo)
390
repo.chk_bytes = None
391
387
repo._transport = repo_transport
425
421
"""See RepositoryFormat.get_format_description()."""
426
422
return "Knit repository format 1"
424
def check_conversion_target(self, target_format):
429
428
class RepositoryFormatKnit3(RepositoryFormatKnit):
430
429
"""Bzr repository knit format 3.
460
458
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
460
def check_conversion_target(self, target_format):
461
if not target_format.rich_root_data:
462
raise errors.BadConversionTarget(
463
'Does not support rich root data.', target_format)
464
if not getattr(target_format, 'supports_tree_reference', False):
465
raise errors.BadConversionTarget(
466
'Does not support nested trees', target_format)
462
468
def get_format_string(self):
463
469
"""See RepositoryFormat.get_format_string()."""
464
470
return "Bazaar Knit Repository Format 3 (bzr 0.15)\n"
501
507
_matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
509
def check_conversion_target(self, target_format):
510
if not target_format.rich_root_data:
511
raise errors.BadConversionTarget(
512
'Does not support rich root data.', target_format)
503
514
def get_format_string(self):
504
515
"""See RepositoryFormat.get_format_string()."""
505
516
return 'Bazaar Knit Repository Format 4 (bzr 1.0)\n'