~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Robert Collins
  • Date: 2007-10-05 03:14:29 UTC
  • mfrom: (2889.1.1 knit-repo)
  • mto: This revision was merged to the branch mainline in revision 2933.
  • Revision ID: robertc@robertcollins.net-20071005031429-8zab3gybvpicu52l
Merge KnitRepository3 removal branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
    )
52
52
 
53
53
from bzrlib.decorators import needs_read_lock, needs_write_lock
54
 
from bzrlib.repofmt.knitrepo import KnitRepository, KnitRepository3
 
54
from bzrlib.repofmt.knitrepo import KnitRepository
55
55
from bzrlib.repository import (
56
56
    CommitBuilder,
57
57
    MetaDirRepository,
1310
1310
            # existing knit to be changed - its all behind 'repo.add_inventory'.
1311
1311
 
1312
1312
 
1313
 
class GraphKnitRepository1(KnitRepository):
 
1313
class GraphKnitRepository(KnitRepository):
1314
1314
    """Experimental graph-knit using repository."""
1315
1315
 
1316
 
    _commit_builder_class = PackCommitBuilder
1317
 
 
1318
1316
    def __init__(self, _format, a_bzrdir, control_files, _revision_store,
1319
 
                 control_store, text_store):
 
1317
        control_store, text_store, _commit_builder_class, _serializer):
1320
1318
        KnitRepository.__init__(self, _format, a_bzrdir, control_files,
1321
 
                              _revision_store, control_store, text_store)
 
1319
            _revision_store, control_store, text_store, _commit_builder_class,
 
1320
            _serializer)
1322
1321
        index_transport = control_files._transport.clone('indices')
1323
1322
        self._packs = RepositoryPackCollection(self, control_files._transport,
1324
1323
            index_transport,
1367
1366
        reconciler.reconcile()
1368
1367
        return reconciler
1369
1368
 
1370
 
    def reconcile_actions(self):
1371
 
        """Return a set of actions taken by reconcile on this repository.
1372
 
 
1373
 
        Pack repositories currently perform no reconciliation.
1374
 
 
1375
 
        :return: A set of actions. e.g. set(['inventory_gc']).
1376
 
        """
1377
 
        return set([])
1378
 
 
1379
 
 
1380
 
class GraphKnitRepository3(KnitRepository3):
1381
 
    """Experimental graph-knit using subtrees repository."""
1382
 
 
1383
 
    _commit_builder_class = PackRootCommitBuilder
1384
 
 
1385
 
    def __init__(self, _format, a_bzrdir, control_files, _revision_store,
1386
 
                 control_store, text_store):
1387
 
        KnitRepository3.__init__(self, _format, a_bzrdir, control_files,
1388
 
                              _revision_store, control_store, text_store)
1389
 
        index_transport = control_files._transport.clone('indices')
1390
 
        self._packs = RepositoryPackCollection(self, control_files._transport,
1391
 
            index_transport,
1392
 
            control_files._transport.clone('upload'),
1393
 
            control_files._transport.clone('packs'))
1394
 
        self._revision_store = GraphKnitRevisionStore(self, index_transport, self._revision_store)
1395
 
        self.weave_store = GraphKnitTextStore(self, index_transport, self.weave_store)
1396
 
        self._inv_thunk = InventoryKnitThunk(self, index_transport)
1397
 
        # for tests
1398
 
        self._reconcile_does_inventory_gc = False
1399
 
 
1400
 
    def _abort_write_group(self):
1401
 
        return self._packs._abort_write_group()
1402
 
 
1403
 
    def _refresh_data(self):
1404
 
        if self.control_files._lock_count==1:
1405
 
            self._revision_store.reset()
1406
 
            self.weave_store.reset()
1407
 
            self._inv_thunk.reset()
1408
 
            # forget what names there are
1409
 
            self._packs.reset()
1410
 
 
1411
 
    def _start_write_group(self):
1412
 
        self._packs._start_write_group()
1413
 
 
1414
 
    def _commit_write_group(self):
1415
 
        return self._packs._commit_write_group()
1416
 
 
1417
 
    def get_inventory_weave(self):
1418
 
        return self._inv_thunk.get_weave()
1419
 
 
1420
 
    @needs_write_lock
1421
 
    def pack(self):
1422
 
        """Compress the data within the repository.
1423
 
 
1424
 
        This will pack all the data to a single pack. In future it may
1425
 
        recompress deltas or do other such expensive operations.
1426
 
        """
1427
 
        self._packs.pack()
1428
 
 
1429
 
    @needs_write_lock
1430
 
    def reconcile(self, other=None, thorough=False):
1431
 
        """Reconcile this repository."""
1432
 
        from bzrlib.reconcile import PackReconciler
1433
 
        reconciler = PackReconciler(self, thorough=thorough)
1434
 
        reconciler.reconcile()
1435
 
        return reconciler
1436
 
 
1437
 
    def reconcile_actions(self):
1438
 
        """Return a set of actions taken by reconcile on this repository.
1439
 
        
1440
 
        :return: A set of actions. e.g. set(['inventory_gc']).
1441
 
        """
1442
 
        return set([])
1443
 
 
1444
1369
 
1445
1370
class RepositoryFormatPack(MetaDirRepositoryFormat):
1446
1371
    """Format logic for pack structured repositories.
1457
1382
     - a LockDir lock
1458
1383
    """
1459
1384
 
 
1385
    # Set this attribute in derived classes to control the repository class
 
1386
    # created by open and initialize.
 
1387
    repository_class = None
 
1388
    # Set this attribute in derived classes to control the
 
1389
    # _commit_builder_class that the repository objects will have passed to
 
1390
    # their constructor.
 
1391
    _commit_builder_class = None
 
1392
    # Set this attribute in derived clases to control the _serializer that the
 
1393
    # repository objects will have passed to their constructor.
 
1394
    _serializer = None
 
1395
 
1460
1396
    def _get_control_store(self, repo_transport, control_files):
1461
1397
        """Return the control store for this repository."""
1462
1398
        return VersionedFileStore(
1536
1472
                              control_files=control_files,
1537
1473
                              _revision_store=_revision_store,
1538
1474
                              control_store=control_store,
1539
 
                              text_store=text_store)
 
1475
                              text_store=text_store,
 
1476
                              _commit_builder_class=self._commit_builder_class,
 
1477
                              _serializer=self._serializer)
1540
1478
 
1541
1479
 
1542
1480
class RepositoryFormatGraphKnit1(RepositoryFormatPack):
1556
1494
    This format was introduced in bzr.dev.
1557
1495
    """
1558
1496
 
1559
 
    repository_class = GraphKnitRepository1
 
1497
    repository_class = GraphKnitRepository
 
1498
    _commit_builder_class = PackCommitBuilder
 
1499
    _serializer = xml5.serializer_v5
1560
1500
 
1561
1501
    def _get_matching_bzrdir(self):
1562
1502
        return bzrdir.format_registry.make_bzrdir('experimental')
1598
1538
     - support for recording tree-references
1599
1539
    """
1600
1540
 
1601
 
    repository_class = GraphKnitRepository3
 
1541
    repository_class = GraphKnitRepository
 
1542
    _commit_builder_class = PackRootCommitBuilder
1602
1543
    rich_root_data = True
1603
1544
    supports_tree_reference = True
 
1545
    _serializer = xml7.serializer_v7
1604
1546
 
1605
1547
    def _get_matching_bzrdir(self):
1606
1548
        return bzrdir.format_registry.make_bzrdir('experimental-subtree')