~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
        """Return true if this bzrdir is one whose format we can convert from."""
96
96
        return True
97
97
 
 
98
    def check_conversion_target(self, target_format):
 
99
        target_repo_format = target_format.repository_format
 
100
        source_repo_format = self._format.repository_format
 
101
        source_repo_format.check_conversion_target(target_repo_format)
 
102
 
98
103
    @staticmethod
99
104
    def _check_supported(format, allow_unsupported):
100
105
        """Check whether format is a supported format.
578
583
        except errors.NoWorkingTree:
579
584
            return False
580
585
 
 
586
    def cloning_metadir(self, basis=None):
 
587
        """Produce a metadir suitable for cloning with"""
 
588
        def related_repository(bzrdir):
 
589
            try:
 
590
                branch = bzrdir.open_branch()
 
591
                return branch.repository
 
592
            except errors.NotBranchError:
 
593
                source_branch = None
 
594
                return bzrdir.open_repository()
 
595
        result_format = self._format.__class__()
 
596
        try:
 
597
            try:
 
598
                source_repository = related_repository(self)
 
599
            except errors.NoRepositoryPresent:
 
600
                if basis is None:
 
601
                    raise
 
602
                source_repository = related_repository(self)
 
603
            result_format.repository_format = source_repository._format
 
604
        except errors.NoRepositoryPresent:
 
605
            pass
 
606
        return result_format
 
607
 
581
608
    def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
582
609
        """Create a copy of this bzrdir prepared for use as a new line of
583
610
        development.
593
620
            itself to download less data.
594
621
        """
595
622
        self._make_tail(url)
596
 
        result = self._format.initialize(url)
 
623
        cloning_format = self.cloning_metadir(basis)
 
624
        result = cloning_format.initialize(url)
597
625
        basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
598
626
        try:
599
627
            source_branch = self.open_branch()
1071
1099
        """
1072
1100
        return True
1073
1101
 
 
1102
    def same_model(self, target_format):
 
1103
        return (self.repository_format.rich_root_data == 
 
1104
            target_format.rich_root_data)
 
1105
 
1074
1106
    @classmethod
1075
1107
    def known_formats(klass):
1076
1108
        """Return all the known formats.
1192
1224
    def __return_repository_format(self):
1193
1225
        """Circular import protection."""
1194
1226
        from bzrlib.repository import RepositoryFormat4
1195
 
        return RepositoryFormat4(self)
 
1227
        return RepositoryFormat4()
1196
1228
    repository_format = property(__return_repository_format)
1197
1229
 
1198
1230
 
1252
1284
    def __return_repository_format(self):
1253
1285
        """Circular import protection."""
1254
1286
        from bzrlib.repository import RepositoryFormat5
1255
 
        return RepositoryFormat5(self)
 
1287
        return RepositoryFormat5()
1256
1288
    repository_format = property(__return_repository_format)
1257
1289
 
1258
1290
 
1311
1343
    def __return_repository_format(self):
1312
1344
        """Circular import protection."""
1313
1345
        from bzrlib.repository import RepositoryFormat6
1314
 
        return RepositoryFormat6(self)
 
1346
        return RepositoryFormat6()
1315
1347
    repository_format = property(__return_repository_format)
1316
1348
 
1317
1349
 
1556
1588
        assert rev_id not in self.converted_revs
1557
1589
        old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read()
1558
1590
        inv = serializer_v4.read_inventory_from_string(old_inv_xml)
 
1591
        inv.revision_id = rev_id
1559
1592
        rev = self.revisions[rev_id]
1560
1593
        if rev.inventory_sha1:
1561
1594
            assert rev.inventory_sha1 == sha_string(old_inv_xml), \