3568
3568
return InterRepository._same_model(source, target)
3571
class InterWeaveRepo(InterSameDataRepository):
3572
"""Optimised code paths between Weave based repositories.
3574
This should be in bzrlib/repofmt/weaverepo.py but we have not yet
3575
implemented lazy inter-object optimisation.
3579
def _get_repo_format_to_test(self):
3580
from bzrlib.repofmt import weaverepo
3581
return weaverepo.RepositoryFormat7()
3584
def is_compatible(source, target):
3585
"""Be compatible with known Weave formats.
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
3591
from bzrlib.repofmt.weaverepo import (
3597
return (isinstance(source._format, (RepositoryFormat5,
3599
RepositoryFormat7)) and
3600
isinstance(target._format, (RepositoryFormat5,
3602
RepositoryFormat7)))
3603
except AttributeError:
3607
def copy_content(self, revision_id=None):
3608
"""See InterRepository.copy_content()."""
3609
# weave specific optimised path:
3611
self.target.set_make_working_trees(self.source.make_working_trees())
3612
except (errors.RepositoryUpgradeRequired, NotImplemented):
3614
# FIXME do not peek!
3615
if self.source._transport.listable():
3616
pb = ui.ui_factory.nested_progress_bar()
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(),
3629
self.target.revisions.insert_record_stream(
3630
self.source.revisions.get_record_stream(
3631
self.source.revisions.keys(),
3632
'topological', True))
3636
self.target.fetch(self.source, revision_id=revision_id)
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.
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()
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
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.
3679
self.source._eliminate_revisions_not_present(required_revisions))
3680
return self.source.revision_ids_to_search_result(result_set)
3683
class InterKnitRepo(InterSameDataRepository):
3684
"""Optimised code paths between Knit based repositories."""
3687
def _get_repo_format_to_test(self):
3688
from bzrlib.repofmt import knitrepo
3689
return knitrepo.RepositoryFormatKnit1()
3692
def is_compatible(source, target):
3693
"""Be compatible with known Knit formats.
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
3699
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit
3701
are_knits = (isinstance(source._format, RepositoryFormatKnit) and
3702
isinstance(target._format, RepositoryFormatKnit))
3703
except AttributeError:
3705
return are_knits and InterRepository._same_model(source, target)
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()
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
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.
3737
self.source._eliminate_revisions_not_present(required_revisions))
3738
return self.source.revision_ids_to_search_result(result_set)
3741
3571
class InterDifferingSerializer(InterRepository):