~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Aaron Bentley
  • Date: 2006-08-17 19:51:54 UTC
  • mto: (1910.2.43 format-bumps)
  • mto: This revision was merged to the branch mainline in revision 1997.
  • Revision ID: abentley@panoramicfeedback.com-20060817195154-af960bfc59351ebf
Implement knit repo format 2

Show diffs side-by-side

added added

removed removed

Lines of Context:
399
399
        revision_ids. Each altered file-ids has the exact revision_ids that
400
400
        altered it listed explicitly.
401
401
        """
402
 
        assert isinstance(self._format, (RepositoryFormat5,
403
 
                                         RepositoryFormat6,
404
 
                                         RepositoryFormat7,
405
 
                                         RepositoryFormatKnit1)), \
 
402
        assert self._format.has_unnested_inventory(), \
406
403
            ("fileids_altered_by_revision_ids only supported for branches " 
407
404
             "which store inventory as unnested xml, not on %r" % self)
408
405
        selected_revision_ids = set(revision_ids)
1117
1114
        """
1118
1115
        return True
1119
1116
 
 
1117
    def has_unnested_inventory(self):
 
1118
        raise NotImplementedError(self.has_unnested_inventory)
 
1119
 
 
1120
    def check_conversion_target(self, target_format):
 
1121
        raise NotImplementedError(self.check_conversion_target)
 
1122
 
1120
1123
    def open(self, a_bzrdir, _found=False):
1121
1124
        """Return an instance of this format for the bzrdir a_bzrdir.
1122
1125
        
1210
1213
                                  control_store=control_store,
1211
1214
                                  text_store=text_store)
1212
1215
 
 
1216
    def check_conversion_target(self, target_format):
 
1217
        pass
 
1218
 
1213
1219
 
1214
1220
class RepositoryFormat4(PreSplitOutRepositoryFormat):
1215
1221
    """Bzr repository format 4.
1231
1237
        """See RepositoryFormat.get_format_description()."""
1232
1238
        return "Repository format 4"
1233
1239
 
 
1240
    def has_unnested_inventory(self):
 
1241
        return True
 
1242
 
1234
1243
    def initialize(self, url, shared=False, _internal=False):
1235
1244
        """Format 4 branches cannot be created."""
1236
1245
        raise errors.UninitializableFormat(self)
1280
1289
        """See RepositoryFormat.get_format_description()."""
1281
1290
        return "Weave repository format 5"
1282
1291
 
 
1292
    def has_unnested_inventory(self):
 
1293
        return True
 
1294
 
1283
1295
    def _get_revision_store(self, repo_transport, control_files):
1284
1296
        """See RepositoryFormat._get_revision_store()."""
1285
1297
        """Return the revision store object for this a_bzrdir."""
1310
1322
        """See RepositoryFormat.get_format_description()."""
1311
1323
        return "Weave repository format 6"
1312
1324
 
 
1325
    def has_unnested_inventory(self):
 
1326
        return True
 
1327
 
1313
1328
    def _get_revision_store(self, repo_transport, control_files):
1314
1329
        """See RepositoryFormat._get_revision_store()."""
1315
1330
        return self._get_text_rev_store(repo_transport,
1383
1398
        """See RepositoryFormat.get_format_description()."""
1384
1399
        return "Weave repository format 7"
1385
1400
 
 
1401
    def has_unnested_inventory(self):
 
1402
        return True
 
1403
 
 
1404
    def check_conversion_target(self, target_format):
 
1405
        pass
 
1406
 
1386
1407
    def _get_revision_store(self, repo_transport, control_files):
1387
1408
        """See RepositoryFormat._get_revision_store()."""
1388
1409
        return self._get_text_rev_store(repo_transport,
1493
1514
                                              versionedfile_class=KnitVersionedFile,
1494
1515
                                              escaped=True)
1495
1516
 
 
1517
    def has_unnested_inventory(self):
 
1518
        return True
 
1519
 
1496
1520
    def initialize(self, a_bzrdir, shared=False):
1497
1521
        """Create a knit format 1 repository.
1498
1522
 
1543
1567
                              control_store=control_store,
1544
1568
                              text_store=text_store)
1545
1569
 
 
1570
 
1546
1571
class RepositoryFormatKnit1(RepositoryFormatKnit):
1547
1572
    """Bzr repository knit format 1.
1548
1573
 
1566
1591
        """See RepositoryFormat.get_format_description()."""
1567
1592
        return "Knit repository format 1"
1568
1593
 
 
1594
    def check_conversion_target(self, target_format):
 
1595
        pass
 
1596
 
 
1597
 
 
1598
class RepositoryFormatKnit2(RepositoryFormatKnit):
 
1599
    """Bzr repository knit format 2.
 
1600
 
 
1601
    THIS FORMAT IS EXPERIMENTAL
 
1602
    This repository format has:
 
1603
     - knits for file texts and inventory
 
1604
     - hash subdirectory based stores.
 
1605
     - knits for revisions and signatures
 
1606
     - TextStores for revisions and signatures.
 
1607
     - a format marker of its own
 
1608
     - an optional 'shared-storage' flag
 
1609
     - an optional 'no-working-trees' flag
 
1610
     - a LockDir lock
 
1611
     - Support for recording full info about the tree root
 
1612
 
 
1613
    """
 
1614
    def get_format_string(self):
 
1615
        """See RepositoryFormat.get_format_string()."""
 
1616
        return "Bazaar Knit Repository Format 2"
 
1617
 
 
1618
    def get_format_description(self):
 
1619
        """See RepositoryFormat.get_format_description()."""
 
1620
        return "Knit repository format 2"
 
1621
 
 
1622
    def check_conversion_target(self, target_format):
 
1623
        if not getattr(target_format, 'rich_root_data', False):
 
1624
            raise errors.BadConversionTarget(
 
1625
                'Does not support rich root data.', target_format)
 
1626
 
 
1627
 
1569
1628
# formats which have no format string are not discoverable
1570
1629
# and not independently creatable, so are not registered.
1571
1630
RepositoryFormat.register_format(RepositoryFormat7())
1572
1631
_default_format = RepositoryFormatKnit1()
1573
1632
RepositoryFormat.register_format(_default_format)
 
1633
RepositoryFormat.register_format(RepositoryFormatKnit2())
1574
1634
RepositoryFormat.set_default_format(_default_format)
1575
1635
_legacy_formats = [RepositoryFormat4(),
1576
1636
                   RepositoryFormat5(),
1957
2017
        self.step('Moving repository to repository.backup')
1958
2018
        self.repo_dir.transport.move('repository', 'repository.backup')
1959
2019
        backup_transport =  self.repo_dir.transport.clone('repository.backup')
 
2020
        repo._format.check_conversion_target(self.target_format)
1960
2021
        self.source_repo = repo._format.open(self.repo_dir,
1961
2022
            _found=True,
1962
2023
            _override_transport=backup_transport)