/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/knitrepo.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-18 18:18:36 UTC
  • mto: This revision was merged to the branch mainline in revision 4461.
  • Revision ID: john@arbash-meinel.com-20090618181836-biodfkat9a8eyzjz
The new add_inventory_by_delta is returning a CHKInventory when mapping from NULL
Which is completely valid, but 'broke' one of the tests.
So to fix it, changed the test to use CHKInventories on both sides, and add an __eq__
member. The nice thing is that CHKInventory.__eq__ is fairly cheap, since it only
has to check the root keys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
2
#
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
24
24
    lockdir,
25
25
    osutils,
26
26
    revision as _mod_revision,
27
 
    trace,
28
27
    transactions,
29
28
    versionedfile,
30
29
    xml5,
43
42
    RepositoryFormat,
44
43
    RootCommitBuilder,
45
44
    )
 
45
from bzrlib.trace import mutter, mutter_callsite
46
46
 
47
47
 
48
48
class _KnitParentsProvider(object):
229
229
    def _make_parents_provider(self):
230
230
        return _KnitsParentsProvider(self.revisions)
231
231
 
232
 
    def _find_inconsistent_revision_parents(self, revisions_iterator=None):
 
232
    def _find_inconsistent_revision_parents(self):
233
233
        """Find revisions with different parent lists in the revision object
234
234
        and in the index graph.
235
235
 
236
 
        :param revisions_iterator: None, or an iterator of (revid,
237
 
            Revision-or-None). This iterator controls the revisions checked.
238
236
        :returns: an iterator yielding tuples of (revison-id, parents-in-index,
239
237
            parents-in-revision).
240
238
        """
241
239
        if not self.is_locked():
242
240
            raise AssertionError()
243
241
        vf = self.revisions
244
 
        if revisions_iterator is None:
245
 
            revisions_iterator = self._iter_revisions(None)
246
 
        for revid, revision in revisions_iterator:
247
 
            if revision is None:
248
 
                pass
249
 
            parent_map = vf.get_parent_map([(revid,)])
 
242
        for index_version in vf.keys():
 
243
            parent_map = vf.get_parent_map([index_version])
250
244
            parents_according_to_index = tuple(parent[-1] for parent in
251
 
                parent_map[(revid,)])
 
245
                parent_map[index_version])
 
246
            revision = self.get_revision(index_version[-1])
252
247
            parents_according_to_revision = tuple(revision.parent_ids)
253
248
            if parents_according_to_index != parents_according_to_revision:
254
 
                yield (revid, parents_according_to_index,
 
249
                yield (index_version[-1], parents_according_to_index,
255
250
                    parents_according_to_revision)
256
251
 
257
252
    def _check_for_inconsistent_revision_parents(self):
342
337
        :param shared: If true the repository will be initialized as a shared
343
338
                       repository.
344
339
        """
345
 
        trace.mutter('creating repository in %s.', a_bzrdir.transport.base)
 
340
        mutter('creating repository in %s.', a_bzrdir.transport.base)
346
341
        dirs = ['knits']
347
342
        files = []
348
343
        utf8_files = [('format', self.get_format_string())]
360
355
        result.revisions.get_parent_map([('A',)])
361
356
        result.signatures.get_parent_map([('A',)])
362
357
        result.unlock()
363
 
        self._run_post_repo_init_hooks(result, a_bzrdir, shared)
364
358
        return result
365
359
 
366
360
    def open(self, a_bzrdir, _found=False, _override_transport=None):
425
419
        """See RepositoryFormat.get_format_description()."""
426
420
        return "Knit repository format 1"
427
421
 
 
422
    def check_conversion_target(self, target_format):
 
423
        pass
 
424
 
428
425
 
429
426
class RepositoryFormatKnit3(RepositoryFormatKnit):
430
427
    """Bzr repository knit format 3.
445
442
    repository_class = KnitRepository
446
443
    _commit_builder_class = RootCommitBuilder
447
444
    rich_root_data = True
448
 
    experimental = True
449
445
    supports_tree_reference = True
450
446
    @property
451
447
    def _serializer(self):
459
455
 
460
456
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
461
457
 
 
458
    def check_conversion_target(self, target_format):
 
459
        if not target_format.rich_root_data:
 
460
            raise errors.BadConversionTarget(
 
461
                'Does not support rich root data.', target_format)
 
462
        if not getattr(target_format, 'supports_tree_reference', False):
 
463
            raise errors.BadConversionTarget(
 
464
                'Does not support nested trees', target_format)
 
465
 
462
466
    def get_format_string(self):
463
467
        """See RepositoryFormat.get_format_string()."""
464
468
        return "Bazaar Knit Repository Format 3 (bzr 0.15)\n"
500
504
 
501
505
    _matchingbzrdir = property(_get_matching_bzrdir, _ignore_setting_bzrdir)
502
506
 
 
507
    def check_conversion_target(self, target_format):
 
508
        if not target_format.rich_root_data:
 
509
            raise errors.BadConversionTarget(
 
510
                'Does not support rich root data.', target_format)
 
511
 
503
512
    def get_format_string(self):
504
513
        """See RepositoryFormat.get_format_string()."""
505
514
        return 'Bazaar Knit Repository Format 4 (bzr 1.0)\n'