~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Aaron Bentley
  • Date: 2006-08-22 16:14:17 UTC
  • mto: (1910.2.43 format-bumps)
  • mto: This revision was merged to the branch mainline in revision 1997.
  • Revision ID: abentley@panoramicfeedback.com-20060822161417-29c1eb4790285db9
Back out inter.get changes, make optimizers an ordered list

Show diffs side-by-side

added added

removed removed

Lines of Context:
1656
1656
    InterRepository.get(other).method_name(parameters).
1657
1657
    """
1658
1658
 
1659
 
    _optimisers = set()
 
1659
    _optimisers = []
1660
1660
    """The available optimised InterRepository types."""
1661
1661
 
 
1662
    def copy_content(self, revision_id=None, basis=None):
 
1663
        raise NotImplementedError(self.copy_content)
 
1664
 
 
1665
    def fetch(self, revision_id=None, pb=None):
 
1666
        raise NotImplementedError(self.fetch)
 
1667
   
 
1668
    @needs_read_lock
 
1669
    def missing_revision_ids(self, revision_id=None):
 
1670
        """Return the revision ids that source has that target does not.
 
1671
        
 
1672
        These are returned in topological order.
 
1673
 
 
1674
        :param revision_id: only return revision ids included by this
 
1675
                            revision_id.
 
1676
        """
 
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
 
1682
            source_ids.pop(0)
 
1683
        else:
 
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]
 
1690
 
 
1691
 
 
1692
class InterSameDataRepository(InterRepository):
 
1693
    """Code for converting between repositories that represent the same data.
 
1694
    
 
1695
    Data format and model must match for this to work.
 
1696
    """
 
1697
 
 
1698
    _matching_repo_format = RepositoryFormat4()
 
1699
    """Repository format for testing with."""
 
1700
 
1662
1701
    @staticmethod
1663
1702
    def is_compatible(source, target):
 
1703
        if not isinstance(source, Repository):
 
1704
            return False
 
1705
        if not isinstance(target, Repository):
 
1706
            return False
1664
1707
        if source._format.rich_root_data == target._format.rich_root_data:
1665
1708
            return True
1666
1709
        else:
1706
1749
        """
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,
1713
1757
                               pb=pb)
1714
1758
        return f.count_copied, f.failed_revisions
1715
1759
 
1716
 
    @needs_read_lock
1717
 
    def missing_revision_ids(self, revision_id=None):
1718
 
        """Return the revision ids that source has that target does not.
1719
 
        
1720
 
        These are returned in topological order.
1721
 
 
1722
 
        :param revision_id: only return revision ids included by this
1723
 
                            revision_id.
1724
 
        """
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
1730
 
            source_ids.pop(0)
1731
 
        else:
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]
1738
 
 
1739
 
 
1740
 
class InterWeaveRepo(InterRepository):
 
1760
 
 
1761
class InterWeaveRepo(InterSameDataRepository):
1741
1762
    """Optimised code paths between Weave based repositories."""
1742
1763
 
1743
1764
    _matching_repo_format = RepositoryFormat7()
1855
1876
            return self.source._eliminate_revisions_not_present(required_topo_revisions)
1856
1877
 
1857
1878
 
1858
 
class InterKnitRepo(InterRepository):
 
1879
class InterKnitRepo(InterSameDataRepository):
1859
1880
    """Optimised code paths between Knit based repositories."""
1860
1881
 
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)
1919
1940
 
 
1941
InterRepository.register_optimiser(InterSameDataRepository)
1920
1942
InterRepository.register_optimiser(InterWeaveRepo)
1921
1943
InterRepository.register_optimiser(InterKnitRepo)
1922
1944