738
741
paths = list(relpaths)
739
742
return set([self._mapper.unmap(path) for path in paths])
745
class InterWeaveRepo(InterSameDataRepository):
746
"""Optimised code paths between Weave based repositories.
750
def _get_repo_format_to_test(self):
751
return RepositoryFormat7()
754
def is_compatible(source, target):
755
"""Be compatible with known Weave formats.
757
We don't test for the stores being of specific types because that
758
could lead to confusing results, and there is no need to be
762
return (isinstance(source._format, (RepositoryFormat5,
764
RepositoryFormat7)) and
765
isinstance(target._format, (RepositoryFormat5,
768
except AttributeError:
772
def copy_content(self, revision_id=None):
773
"""See InterRepository.copy_content()."""
774
# weave specific optimised path:
776
self.target.set_make_working_trees(self.source.make_working_trees())
777
except (errors.RepositoryUpgradeRequired, NotImplemented):
780
if self.source._transport.listable():
781
pb = ui.ui_factory.nested_progress_bar()
783
self.target.texts.insert_record_stream(
784
self.source.texts.get_record_stream(
785
self.source.texts.keys(), 'topological', False))
786
pb.update('Copying inventory', 0, 1)
787
self.target.inventories.insert_record_stream(
788
self.source.inventories.get_record_stream(
789
self.source.inventories.keys(), 'topological', False))
790
self.target.signatures.insert_record_stream(
791
self.source.signatures.get_record_stream(
792
self.source.signatures.keys(),
794
self.target.revisions.insert_record_stream(
795
self.source.revisions.get_record_stream(
796
self.source.revisions.keys(),
797
'topological', True))
801
self.target.fetch(self.source, revision_id=revision_id)
804
def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
805
"""See InterRepository.missing_revision_ids()."""
806
# we want all revisions to satisfy revision_id in source.
807
# but we don't want to stat every file here and there.
808
# we want then, all revisions other needs to satisfy revision_id
809
# checked, but not those that we have locally.
810
# so the first thing is to get a subset of the revisions to
811
# satisfy revision_id in source, and then eliminate those that
812
# we do already have.
813
# this is slow on high latency connection to self, but as this
814
# disk format scales terribly for push anyway due to rewriting
815
# inventory.weave, this is considered acceptable.
817
if revision_id is not None:
818
source_ids = self.source.get_ancestry(revision_id)
819
if source_ids[0] is not None:
820
raise AssertionError()
823
source_ids = self.source._all_possible_ids()
824
source_ids_set = set(source_ids)
825
# source_ids is the worst possible case we may need to pull.
826
# now we want to filter source_ids against what we actually
827
# have in target, but don't try to check for existence where we know
828
# we do not have a revision as that would be pointless.
829
target_ids = set(self.target._all_possible_ids())
830
possibly_present_revisions = target_ids.intersection(source_ids_set)
831
actually_present_revisions = set(
832
self.target._eliminate_revisions_not_present(possibly_present_revisions))
833
required_revisions = source_ids_set.difference(actually_present_revisions)
834
if revision_id is not None:
835
# we used get_ancestry to determine source_ids then we are assured all
836
# revisions referenced are present as they are installed in topological order.
837
# and the tip revision was validated by get_ancestry.
838
result_set = required_revisions
840
# if we just grabbed the possibly available ids, then
841
# we only have an estimate of whats available and need to validate
842
# that against the revision records.
844
self.source._eliminate_revisions_not_present(required_revisions))
845
return self.source.revision_ids_to_search_result(result_set)
741
848
_legacy_formats = [RepositoryFormat4(),
742
849
RepositoryFormat5(),
743
850
RepositoryFormat6()]
853
InterRepository.register_optimiser(InterWeaveRepo)