~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Vincent Ladeuil
  • Date: 2010-11-24 16:01:57 UTC
  • mfrom: (4597.13.7 cleanup)
  • mto: This revision was merged to the branch mainline in revision 5558.
  • Revision ID: v.ladeuil+lp@free.fr-20101124160157-kieuslo7wj9abdmb
Merge cleanup into 638451-malformed

Show diffs side-by-side

added added

removed removed

Lines of Context:
3352
3352
    'bzrlib.repofmt.pack_repo',
3353
3353
    'RepositoryFormatKnitPack6RichRoot',
3354
3354
    )
 
3355
format_registry.register_lazy(
 
3356
    'Bazaar repository format 2a (needs bzr 1.16 or later)\n',
 
3357
    'bzrlib.repofmt.groupcompress_repo',
 
3358
    'RepositoryFormat2a',
 
3359
    )
3355
3360
 
3356
3361
# Development formats.
3357
 
# Obsolete but kept pending a CHK based subtree format.
 
3362
# Check their docstrings to see if/when they are obsolete.
3358
3363
format_registry.register_lazy(
3359
3364
    ("Bazaar development format 2 with subtree support "
3360
3365
        "(needs bzr.dev from before 1.8)\n"),
3361
3366
    'bzrlib.repofmt.pack_repo',
3362
3367
    'RepositoryFormatPackDevelopment2Subtree',
3363
3368
    )
3364
 
 
3365
 
# 1.14->1.16 go below here
3366
 
format_registry.register_lazy(
3367
 
    'Bazaar development format - group compression and chk inventory'
3368
 
        ' (needs bzr.dev from 1.14)\n',
3369
 
    'bzrlib.repofmt.groupcompress_repo',
3370
 
    'RepositoryFormatCHK1',
3371
 
    )
3372
 
 
3373
 
format_registry.register_lazy(
3374
 
    'Bazaar development format - chk repository with bencode revision '
3375
 
        'serialization (needs bzr.dev from 1.16)\n',
3376
 
    'bzrlib.repofmt.groupcompress_repo',
3377
 
    'RepositoryFormatCHK2',
3378
 
    )
3379
 
format_registry.register_lazy(
3380
 
    'Bazaar repository format 2a (needs bzr 1.16 or later)\n',
3381
 
    'bzrlib.repofmt.groupcompress_repo',
3382
 
    'RepositoryFormat2a',
3383
 
    )
3384
3369
format_registry.register_lazy(
3385
3370
    'Bazaar development format 8\n',
3386
3371
    'bzrlib.repofmt.groupcompress_repo',
3568
3553
        return InterRepository._same_model(source, target)
3569
3554
 
3570
3555
 
3571
 
class InterWeaveRepo(InterSameDataRepository):
3572
 
    """Optimised code paths between Weave based repositories.
3573
 
 
3574
 
    This should be in bzrlib/repofmt/weaverepo.py but we have not yet
3575
 
    implemented lazy inter-object optimisation.
3576
 
    """
3577
 
 
3578
 
    @classmethod
3579
 
    def _get_repo_format_to_test(self):
3580
 
        from bzrlib.repofmt import weaverepo
3581
 
        return weaverepo.RepositoryFormat7()
3582
 
 
3583
 
    @staticmethod
3584
 
    def is_compatible(source, target):
3585
 
        """Be compatible with known Weave formats.
3586
 
 
3587
 
        We don't test for the stores being of specific types because that
3588
 
        could lead to confusing results, and there is no need to be
3589
 
        overly general.
3590
 
        """
3591
 
        from bzrlib.repofmt.weaverepo import (
3592
 
                RepositoryFormat5,
3593
 
                RepositoryFormat6,
3594
 
                RepositoryFormat7,
3595
 
                )
3596
 
        try:
3597
 
            return (isinstance(source._format, (RepositoryFormat5,
3598
 
                                                RepositoryFormat6,
3599
 
                                                RepositoryFormat7)) and
3600
 
                    isinstance(target._format, (RepositoryFormat5,
3601
 
                                                RepositoryFormat6,
3602
 
                                                RepositoryFormat7)))
3603
 
        except AttributeError:
3604
 
            return False
3605
 
 
3606
 
    @needs_write_lock
3607
 
    def copy_content(self, revision_id=None):
3608
 
        """See InterRepository.copy_content()."""
3609
 
        # weave specific optimised path:
3610
 
        try:
3611
 
            self.target.set_make_working_trees(self.source.make_working_trees())
3612
 
        except (errors.RepositoryUpgradeRequired, NotImplemented):
3613
 
            pass
3614
 
        # FIXME do not peek!
3615
 
        if self.source._transport.listable():
3616
 
            pb = ui.ui_factory.nested_progress_bar()
3617
 
            try:
3618
 
                self.target.texts.insert_record_stream(
3619
 
                    self.source.texts.get_record_stream(
3620
 
                        self.source.texts.keys(), 'topological', False))
3621
 
                pb.update('Copying inventory', 0, 1)
3622
 
                self.target.inventories.insert_record_stream(
3623
 
                    self.source.inventories.get_record_stream(
3624
 
                        self.source.inventories.keys(), 'topological', False))
3625
 
                self.target.signatures.insert_record_stream(
3626
 
                    self.source.signatures.get_record_stream(
3627
 
                        self.source.signatures.keys(),
3628
 
                        'unordered', True))
3629
 
                self.target.revisions.insert_record_stream(
3630
 
                    self.source.revisions.get_record_stream(
3631
 
                        self.source.revisions.keys(),
3632
 
                        'topological', True))
3633
 
            finally:
3634
 
                pb.finished()
3635
 
        else:
3636
 
            self.target.fetch(self.source, revision_id=revision_id)
3637
 
 
3638
 
    @needs_read_lock
3639
 
    def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
3640
 
        """See InterRepository.missing_revision_ids()."""
3641
 
        # we want all revisions to satisfy revision_id in source.
3642
 
        # but we don't want to stat every file here and there.
3643
 
        # we want then, all revisions other needs to satisfy revision_id
3644
 
        # checked, but not those that we have locally.
3645
 
        # so the first thing is to get a subset of the revisions to
3646
 
        # satisfy revision_id in source, and then eliminate those that
3647
 
        # we do already have.
3648
 
        # this is slow on high latency connection to self, but as this
3649
 
        # disk format scales terribly for push anyway due to rewriting
3650
 
        # inventory.weave, this is considered acceptable.
3651
 
        # - RBC 20060209
3652
 
        if revision_id is not None:
3653
 
            source_ids = self.source.get_ancestry(revision_id)
3654
 
            if source_ids[0] is not None:
3655
 
                raise AssertionError()
3656
 
            source_ids.pop(0)
3657
 
        else:
3658
 
            source_ids = self.source._all_possible_ids()
3659
 
        source_ids_set = set(source_ids)
3660
 
        # source_ids is the worst possible case we may need to pull.
3661
 
        # now we want to filter source_ids against what we actually
3662
 
        # have in target, but don't try to check for existence where we know
3663
 
        # we do not have a revision as that would be pointless.
3664
 
        target_ids = set(self.target._all_possible_ids())
3665
 
        possibly_present_revisions = target_ids.intersection(source_ids_set)
3666
 
        actually_present_revisions = set(
3667
 
            self.target._eliminate_revisions_not_present(possibly_present_revisions))
3668
 
        required_revisions = source_ids_set.difference(actually_present_revisions)
3669
 
        if revision_id is not None:
3670
 
            # we used get_ancestry to determine source_ids then we are assured all
3671
 
            # revisions referenced are present as they are installed in topological order.
3672
 
            # and the tip revision was validated by get_ancestry.
3673
 
            result_set = required_revisions
3674
 
        else:
3675
 
            # if we just grabbed the possibly available ids, then
3676
 
            # we only have an estimate of whats available and need to validate
3677
 
            # that against the revision records.
3678
 
            result_set = set(
3679
 
                self.source._eliminate_revisions_not_present(required_revisions))
3680
 
        return self.source.revision_ids_to_search_result(result_set)
3681
 
 
3682
 
 
3683
 
class InterKnitRepo(InterSameDataRepository):
3684
 
    """Optimised code paths between Knit based repositories."""
3685
 
 
3686
 
    @classmethod
3687
 
    def _get_repo_format_to_test(self):
3688
 
        from bzrlib.repofmt import knitrepo
3689
 
        return knitrepo.RepositoryFormatKnit1()
3690
 
 
3691
 
    @staticmethod
3692
 
    def is_compatible(source, target):
3693
 
        """Be compatible with known Knit formats.
3694
 
 
3695
 
        We don't test for the stores being of specific types because that
3696
 
        could lead to confusing results, and there is no need to be
3697
 
        overly general.
3698
 
        """
3699
 
        from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
3700
 
        try:
3701
 
            are_knits = (isinstance(source._format, RepositoryFormatKnit) and
3702
 
                isinstance(target._format, RepositoryFormatKnit))
3703
 
        except AttributeError:
3704
 
            return False
3705
 
        return are_knits and InterRepository._same_model(source, target)
3706
 
 
3707
 
    @needs_read_lock
3708
 
    def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
3709
 
        """See InterRepository.missing_revision_ids()."""
3710
 
        if revision_id is not None:
3711
 
            source_ids = self.source.get_ancestry(revision_id)
3712
 
            if source_ids[0] is not None:
3713
 
                raise AssertionError()
3714
 
            source_ids.pop(0)
3715
 
        else:
3716
 
            source_ids = self.source.all_revision_ids()
3717
 
        source_ids_set = set(source_ids)
3718
 
        # source_ids is the worst possible case we may need to pull.
3719
 
        # now we want to filter source_ids against what we actually
3720
 
        # have in target, but don't try to check for existence where we know
3721
 
        # we do not have a revision as that would be pointless.
3722
 
        target_ids = set(self.target.all_revision_ids())
3723
 
        possibly_present_revisions = target_ids.intersection(source_ids_set)
3724
 
        actually_present_revisions = set(
3725
 
            self.target._eliminate_revisions_not_present(possibly_present_revisions))
3726
 
        required_revisions = source_ids_set.difference(actually_present_revisions)
3727
 
        if revision_id is not None:
3728
 
            # we used get_ancestry to determine source_ids then we are assured all
3729
 
            # revisions referenced are present as they are installed in topological order.
3730
 
            # and the tip revision was validated by get_ancestry.
3731
 
            result_set = required_revisions
3732
 
        else:
3733
 
            # if we just grabbed the possibly available ids, then
3734
 
            # we only have an estimate of whats available and need to validate
3735
 
            # that against the revision records.
3736
 
            result_set = set(
3737
 
                self.source._eliminate_revisions_not_present(required_revisions))
3738
 
        return self.source.revision_ids_to_search_result(result_set)
3739
 
 
3740
 
 
3741
3556
class InterDifferingSerializer(InterRepository):
3742
3557
 
3743
3558
    @classmethod
4079
3894
 
4080
3895
InterRepository.register_optimiser(InterDifferingSerializer)
4081
3896
InterRepository.register_optimiser(InterSameDataRepository)
4082
 
InterRepository.register_optimiser(InterWeaveRepo)
4083
 
InterRepository.register_optimiser(InterKnitRepo)
4084
3897
 
4085
3898
 
4086
3899
class CopyConverter(object):