~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
    lockdir,
35
35
    osutils,
36
36
    registry,
 
37
    remote,
37
38
    revision as _mod_revision,
38
39
    symbol_versioning,
39
40
    transactions,
1210
1211
 
1211
1212
        :param a_bzrdir: The bzrdir to put the new repository in it.
1212
1213
        :param shared: The repository should be initialized as a sharable one.
1213
 
 
 
1214
        :returns: The new repository object.
 
1215
        
1214
1216
        This may raise UninitializableFormat if shared repository are not
1215
1217
        compatible the a_bzrdir.
1216
1218
        """
 
1219
        raise NotImplementedError(self.initialize)
1217
1220
 
1218
1221
    def is_supported(self):
1219
1222
        """Is this format supported?
1687
1690
        return f.count_copied, f.failed_revisions
1688
1691
 
1689
1692
 
 
1693
class InterRemoteRepository(InterRepository):
 
1694
    """Code for converting between RemoteRepository objects.
 
1695
 
 
1696
    This just gets an non-remote repository from the RemoteRepository, and calls
 
1697
    InterRepository.get again.
 
1698
    """
 
1699
 
 
1700
    def __init__(self, source, target):
 
1701
        if isinstance(source, remote.RemoteRepository):
 
1702
            source._ensure_real()
 
1703
            real_source = source._real_repository
 
1704
        else:
 
1705
            real_source = source
 
1706
        if isinstance(target, remote.RemoteRepository):
 
1707
            target._ensure_real()
 
1708
            real_target = target._real_repository
 
1709
        else:
 
1710
            real_target = target
 
1711
        self.real_inter = InterRepository.get(real_source, real_target)
 
1712
 
 
1713
    @staticmethod
 
1714
    def is_compatible(source, target):
 
1715
        if isinstance(source, remote.RemoteRepository):
 
1716
            return True
 
1717
        if isinstance(target, remote.RemoteRepository):
 
1718
            return True
 
1719
        return False
 
1720
 
 
1721
    def copy_content(self, revision_id=None):
 
1722
        self.real_inter.copy_content(revision_id=revision_id)
 
1723
 
 
1724
    def fetch(self, revision_id=None, pb=None):
 
1725
        self.real_inter.fetch(revision_id=revision_id, pb=pb)
 
1726
 
 
1727
    @classmethod
 
1728
    def _get_repo_format_to_test(self):
 
1729
        return None
 
1730
 
 
1731
 
1690
1732
InterRepository.register_optimiser(InterSameDataRepository)
1691
1733
InterRepository.register_optimiser(InterWeaveRepo)
1692
1734
InterRepository.register_optimiser(InterKnitRepo)
1693
1735
InterRepository.register_optimiser(InterModel1and2)
1694
1736
InterRepository.register_optimiser(InterKnit1and2)
 
1737
InterRepository.register_optimiser(InterRemoteRepository)
1695
1738
 
1696
1739
 
1697
1740
class RepositoryTestProviderAdapter(object):
1703
1746
    to make it easy to identify.
1704
1747
    """
1705
1748
 
1706
 
    def __init__(self, transport_server, transport_readonly_server, formats):
 
1749
    def __init__(self, transport_server, transport_readonly_server, formats,
 
1750
                 vfs_transport_factory=None):
1707
1751
        self._transport_server = transport_server
1708
1752
        self._transport_readonly_server = transport_readonly_server
 
1753
        self._vfs_transport_factory = vfs_transport_factory
1709
1754
        self._formats = formats
1710
1755
    
1711
1756
    def adapt(self, test):
1715
1760
            new_test = deepcopy(test)
1716
1761
            new_test.transport_server = self._transport_server
1717
1762
            new_test.transport_readonly_server = self._transport_readonly_server
 
1763
            # Only override the test's vfs_transport_factory if one was
 
1764
            # specified, otherwise just leave the default in place.
 
1765
            if self._vfs_transport_factory:
 
1766
                new_test.vfs_transport_factory = self._vfs_transport_factory
1718
1767
            new_test.bzrdir_format = bzrdir_format
1719
1768
            new_test.repository_format = repository_format
1720
1769
            def make_new_test_id():