~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
        """Return true if this bzrdir is one whose format we can convert from."""
88
88
        return True
89
89
 
 
90
    def check_conversion_target(self, target_format):
 
91
        target_repo_format = target_format.repository_format
 
92
        source_repo_format = self._format.repository_format
 
93
        source_repo_format.check_conversion_target(target_repo_format)
 
94
 
90
95
    @staticmethod
91
96
    def _check_supported(format, allow_unsupported):
92
97
        """Check whether format is a supported format.
564
569
        except errors.NoWorkingTree:
565
570
            return False
566
571
 
 
572
    def cloning_metadir(self, basis=None):
 
573
        """Produce a metadir suitable for cloning with"""
 
574
        def related_repository(bzrdir):
 
575
            try:
 
576
                branch = bzrdir.open_branch()
 
577
                return branch.repository
 
578
            except errors.NotBranchError:
 
579
                source_branch = None
 
580
                return bzrdir.open_repository()
 
581
        result_format = self._format.__class__()
 
582
        try:
 
583
            try:
 
584
                source_repository = related_repository(self)
 
585
            except errors.NoRepositoryPresent:
 
586
                if basis is None:
 
587
                    raise
 
588
                source_repository = related_repository(self)
 
589
            result_format.repository_format = source_repository._format
 
590
        except errors.NoRepositoryPresent:
 
591
            pass
 
592
        return result_format
 
593
 
567
594
    def sprout(self, url, revision_id=None, basis=None, force_new_repo=False):
568
595
        """Create a copy of this bzrdir prepared for use as a new line of
569
596
        development.
579
606
            itself to download less data.
580
607
        """
581
608
        self._make_tail(url)
582
 
        result = self._format.initialize(url)
 
609
        cloning_format = self.cloning_metadir(basis)
 
610
        result = cloning_format.initialize(url)
583
611
        basis_repo, basis_branch, basis_tree = self._get_basis_components(basis)
584
612
        try:
585
613
            source_branch = self.open_branch()
1062
1090
        """
1063
1091
        return True
1064
1092
 
 
1093
    def same_model(self, target_format):
 
1094
        return (self.repository_format.rich_root_data == 
 
1095
            target_format.rich_root_data)
 
1096
 
1065
1097
    @classmethod
1066
1098
    def known_formats(klass):
1067
1099
        """Return all the known formats.
1183
1215
    def __return_repository_format(self):
1184
1216
        """Circular import protection."""
1185
1217
        from bzrlib.repository import RepositoryFormat4
1186
 
        return RepositoryFormat4(self)
 
1218
        return RepositoryFormat4()
1187
1219
    repository_format = property(__return_repository_format)
1188
1220
 
1189
1221
 
1243
1275
    def __return_repository_format(self):
1244
1276
        """Circular import protection."""
1245
1277
        from bzrlib.repository import RepositoryFormat5
1246
 
        return RepositoryFormat5(self)
 
1278
        return RepositoryFormat5()
1247
1279
    repository_format = property(__return_repository_format)
1248
1280
 
1249
1281
 
1302
1334
    def __return_repository_format(self):
1303
1335
        """Circular import protection."""
1304
1336
        from bzrlib.repository import RepositoryFormat6
1305
 
        return RepositoryFormat6(self)
 
1337
        return RepositoryFormat6()
1306
1338
    repository_format = property(__return_repository_format)
1307
1339
 
1308
1340
 
1547
1579
        assert rev_id not in self.converted_revs
1548
1580
        old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read()
1549
1581
        inv = serializer_v4.read_inventory_from_string(old_inv_xml)
 
1582
        inv.revision_id = rev_id
1550
1583
        rev = self.revisions[rev_id]
1551
1584
        if rev.inventory_sha1:
1552
1585
            assert rev.inventory_sha1 == sha_string(old_inv_xml), \