~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-09-10 18:57:20 UTC
  • mfrom: (1910.2.48 format-bumps)
  • Revision ID: pqm@pqm.ubuntu.com-20060910185720-1bcc17b99fe77687
Add new format to support nested trees

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()
1057
1085
        """
1058
1086
        return True
1059
1087
 
 
1088
    def same_model(self, target_format):
 
1089
        return (self.repository_format.rich_root_data == 
 
1090
            target_format.rich_root_data)
 
1091
 
1060
1092
    @classmethod
1061
1093
    def known_formats(klass):
1062
1094
        """Return all the known formats.
1178
1210
    def __return_repository_format(self):
1179
1211
        """Circular import protection."""
1180
1212
        from bzrlib.repository import RepositoryFormat4
1181
 
        return RepositoryFormat4(self)
 
1213
        return RepositoryFormat4()
1182
1214
    repository_format = property(__return_repository_format)
1183
1215
 
1184
1216
 
1238
1270
    def __return_repository_format(self):
1239
1271
        """Circular import protection."""
1240
1272
        from bzrlib.repository import RepositoryFormat5
1241
 
        return RepositoryFormat5(self)
 
1273
        return RepositoryFormat5()
1242
1274
    repository_format = property(__return_repository_format)
1243
1275
 
1244
1276
 
1297
1329
    def __return_repository_format(self):
1298
1330
        """Circular import protection."""
1299
1331
        from bzrlib.repository import RepositoryFormat6
1300
 
        return RepositoryFormat6(self)
 
1332
        return RepositoryFormat6()
1301
1333
    repository_format = property(__return_repository_format)
1302
1334
 
1303
1335
 
1542
1574
        assert rev_id not in self.converted_revs
1543
1575
        old_inv_xml = self.branch.repository.inventory_store.get(rev_id).read()
1544
1576
        inv = serializer_v4.read_inventory_from_string(old_inv_xml)
 
1577
        inv.revision_id = rev_id
1545
1578
        rev = self.revisions[rev_id]
1546
1579
        if rev.inventory_sha1:
1547
1580
            assert rev.inventory_sha1 == sha_string(old_inv_xml), \