3553
3553
return InterRepository._same_model(source, target)
3556
class InterWeaveRepo(InterSameDataRepository):
3557
"""Optimised code paths between Weave based repositories.
3559
This should be in bzrlib/repofmt/weaverepo.py but we have not yet
3560
implemented lazy inter-object optimisation.
3564
def _get_repo_format_to_test(self):
3565
from bzrlib.repofmt import weaverepo
3566
return weaverepo.RepositoryFormat7()
3569
def is_compatible(source, target):
3570
"""Be compatible with known Weave formats.
3572
We don't test for the stores being of specific types because that
3573
could lead to confusing results, and there is no need to be
3576
from bzrlib.repofmt.weaverepo import (
3582
return (isinstance(source._format, (RepositoryFormat5,
3584
RepositoryFormat7)) and
3585
isinstance(target._format, (RepositoryFormat5,
3587
RepositoryFormat7)))
3588
except AttributeError:
3592
def copy_content(self, revision_id=None):
3593
"""See InterRepository.copy_content()."""
3594
# weave specific optimised path:
3596
self.target.set_make_working_trees(self.source.make_working_trees())
3597
except (errors.RepositoryUpgradeRequired, NotImplemented):
3599
# FIXME do not peek!
3600
if self.source._transport.listable():
3601
pb = ui.ui_factory.nested_progress_bar()
3603
self.target.texts.insert_record_stream(
3604
self.source.texts.get_record_stream(
3605
self.source.texts.keys(), 'topological', False))
3606
pb.update('Copying inventory', 0, 1)
3607
self.target.inventories.insert_record_stream(
3608
self.source.inventories.get_record_stream(
3609
self.source.inventories.keys(), 'topological', False))
3610
self.target.signatures.insert_record_stream(
3611
self.source.signatures.get_record_stream(
3612
self.source.signatures.keys(),
3614
self.target.revisions.insert_record_stream(
3615
self.source.revisions.get_record_stream(
3616
self.source.revisions.keys(),
3617
'topological', True))
3621
self.target.fetch(self.source, revision_id=revision_id)
3624
def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
3625
"""See InterRepository.missing_revision_ids()."""
3626
# we want all revisions to satisfy revision_id in source.
3627
# but we don't want to stat every file here and there.
3628
# we want then, all revisions other needs to satisfy revision_id
3629
# checked, but not those that we have locally.
3630
# so the first thing is to get a subset of the revisions to
3631
# satisfy revision_id in source, and then eliminate those that
3632
# we do already have.
3633
# this is slow on high latency connection to self, but as this
3634
# disk format scales terribly for push anyway due to rewriting
3635
# inventory.weave, this is considered acceptable.
3637
if revision_id is not None:
3638
source_ids = self.source.get_ancestry(revision_id)
3639
if source_ids[0] is not None:
3640
raise AssertionError()
3643
source_ids = self.source._all_possible_ids()
3644
source_ids_set = set(source_ids)
3645
# source_ids is the worst possible case we may need to pull.
3646
# now we want to filter source_ids against what we actually
3647
# have in target, but don't try to check for existence where we know
3648
# we do not have a revision as that would be pointless.
3649
target_ids = set(self.target._all_possible_ids())
3650
possibly_present_revisions = target_ids.intersection(source_ids_set)
3651
actually_present_revisions = set(
3652
self.target._eliminate_revisions_not_present(possibly_present_revisions))
3653
required_revisions = source_ids_set.difference(actually_present_revisions)
3654
if revision_id is not None:
3655
# we used get_ancestry to determine source_ids then we are assured all
3656
# revisions referenced are present as they are installed in topological order.
3657
# and the tip revision was validated by get_ancestry.
3658
result_set = required_revisions
3660
# if we just grabbed the possibly available ids, then
3661
# we only have an estimate of whats available and need to validate
3662
# that against the revision records.
3664
self.source._eliminate_revisions_not_present(required_revisions))
3665
return self.source.revision_ids_to_search_result(result_set)
3668
class InterKnitRepo(InterSameDataRepository):
3669
"""Optimised code paths between Knit based repositories."""
3672
def _get_repo_format_to_test(self):
3673
from bzrlib.repofmt import knitrepo
3674
return knitrepo.RepositoryFormatKnit1()
3677
def is_compatible(source, target):
3678
"""Be compatible with known Knit formats.
3680
We don't test for the stores being of specific types because that
3681
could lead to confusing results, and there is no need to be
3684
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
3686
are_knits = (isinstance(source._format, RepositoryFormatKnit) and
3687
isinstance(target._format, RepositoryFormatKnit))
3688
except AttributeError:
3690
return are_knits and InterRepository._same_model(source, target)
3693
def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
3694
"""See InterRepository.missing_revision_ids()."""
3695
if revision_id is not None:
3696
source_ids = self.source.get_ancestry(revision_id)
3697
if source_ids[0] is not None:
3698
raise AssertionError()
3701
source_ids = self.source.all_revision_ids()
3702
source_ids_set = set(source_ids)
3703
# source_ids is the worst possible case we may need to pull.
3704
# now we want to filter source_ids against what we actually
3705
# have in target, but don't try to check for existence where we know
3706
# we do not have a revision as that would be pointless.
3707
target_ids = set(self.target.all_revision_ids())
3708
possibly_present_revisions = target_ids.intersection(source_ids_set)
3709
actually_present_revisions = set(
3710
self.target._eliminate_revisions_not_present(possibly_present_revisions))
3711
required_revisions = source_ids_set.difference(actually_present_revisions)
3712
if revision_id is not None:
3713
# we used get_ancestry to determine source_ids then we are assured all
3714
# revisions referenced are present as they are installed in topological order.
3715
# and the tip revision was validated by get_ancestry.
3716
result_set = required_revisions
3718
# if we just grabbed the possibly available ids, then
3719
# we only have an estimate of whats available and need to validate
3720
# that against the revision records.
3722
self.source._eliminate_revisions_not_present(required_revisions))
3723
return self.source.revision_ids_to_search_result(result_set)
3726
3556
class InterDifferingSerializer(InterRepository):