1656
1656
InterRepository.get(other).method_name(parameters).
1660
1660
"""The available optimised InterRepository types."""
1662
def copy_content(self, revision_id=None, basis=None):
1663
raise NotImplementedError(self.copy_content)
1665
def fetch(self, revision_id=None, pb=None):
1666
raise NotImplementedError(self.fetch)
1669
def missing_revision_ids(self, revision_id=None):
1670
"""Return the revision ids that source has that target does not.
1672
These are returned in topological order.
1674
:param revision_id: only return revision ids included by this
1677
# generic, possibly worst case, slow code path.
1678
target_ids = set(self.target.all_revision_ids())
1679
if revision_id is not None:
1680
source_ids = self.source.get_ancestry(revision_id)
1681
assert source_ids[0] == None
1684
source_ids = self.source.all_revision_ids()
1685
result_set = set(source_ids).difference(target_ids)
1686
# this may look like a no-op: its not. It preserves the ordering
1687
# other_ids had while only returning the members from other_ids
1688
# that we've decided we need.
1689
return [rev_id for rev_id in source_ids if rev_id in result_set]
1692
class InterSameDataRepository(InterRepository):
1693
"""Code for converting between repositories that represent the same data.
1695
Data format and model must match for this to work.
1698
_matching_repo_format = RepositoryFormat4()
1699
"""Repository format for testing with."""
1663
1702
def is_compatible(source, target):
1703
if not isinstance(source, Repository):
1705
if not isinstance(target, Repository):
1664
1707
if source._format.rich_root_data == target._format.rich_root_data:
1707
1750
from bzrlib.fetch import GenericRepoFetcher
1708
1751
mutter("Using fetch logic to copy between %s(%s) and %s(%s)",
1709
self.source, self.source._format, self.target, self.target._format)
1752
self.source, self.source._format, self.target,
1753
self.target._format)
1710
1754
f = GenericRepoFetcher(to_repository=self.target,
1711
1755
from_repository=self.source,
1712
1756
last_revision=revision_id,
1714
1758
return f.count_copied, f.failed_revisions
1717
def missing_revision_ids(self, revision_id=None):
1718
"""Return the revision ids that source has that target does not.
1720
These are returned in topological order.
1722
:param revision_id: only return revision ids included by this
1725
# generic, possibly worst case, slow code path.
1726
target_ids = set(self.target.all_revision_ids())
1727
if revision_id is not None:
1728
source_ids = self.source.get_ancestry(revision_id)
1729
assert source_ids[0] == None
1732
source_ids = self.source.all_revision_ids()
1733
result_set = set(source_ids).difference(target_ids)
1734
# this may look like a no-op: its not. It preserves the ordering
1735
# other_ids had while only returning the members from other_ids
1736
# that we've decided we need.
1737
return [rev_id for rev_id in source_ids if rev_id in result_set]
1740
class InterWeaveRepo(InterRepository):
1761
class InterWeaveRepo(InterSameDataRepository):
1741
1762
"""Optimised code paths between Weave based repositories."""
1743
1764
_matching_repo_format = RepositoryFormat7()
1855
1876
return self.source._eliminate_revisions_not_present(required_topo_revisions)
1858
class InterKnitRepo(InterRepository):
1879
class InterKnitRepo(InterSameDataRepository):
1859
1880
"""Optimised code paths between Knit based repositories."""
1861
1882
_matching_repo_format = RepositoryFormatKnit1()
1917
1938
# that against the revision records.
1918
1939
return self.source._eliminate_revisions_not_present(required_topo_revisions)
1941
InterRepository.register_optimiser(InterSameDataRepository)
1920
1942
InterRepository.register_optimiser(InterWeaveRepo)
1921
1943
InterRepository.register_optimiser(InterKnitRepo)