~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Martin Pool
  • Date: 2010-04-27 07:29:11 UTC
  • mto: This revision was merged to the branch mainline in revision 5295.
  • Revision ID: mbp@sourcefrog.net-20100427072911-hagcu863rqbu4mal
Add simple test case for ObjectWithCleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
864
864
# Repositories
865
865
 
866
866
 
867
 
class Repository(_RelockDebugMixin, bzrdir.ControlComponent):
 
867
class Repository(_RelockDebugMixin):
868
868
    """Repository holding history for one or more branches.
869
869
 
870
870
    The repository holds and retrieves historical information including
1291
1291
 
1292
1292
        :param _format: The format of the repository on disk.
1293
1293
        :param a_bzrdir: The BzrDir of the repository.
 
1294
 
 
1295
        In the future we will have a single api for all stores for
 
1296
        getting file texts, inventories and revisions, then
 
1297
        this construct will accept instances of those things.
1294
1298
        """
1295
 
        # In the future we will have a single api for all stores for
1296
 
        # getting file texts, inventories and revisions, then
1297
 
        # this construct will accept instances of those things.
1298
1299
        super(Repository, self).__init__()
1299
1300
        self._format = _format
1300
1301
        # the following are part of the public API for Repository:
1315
1316
        # rather copying them?
1316
1317
        self._safe_to_return_from_cache = False
1317
1318
 
1318
 
    @property
1319
 
    def user_transport(self):
1320
 
        return self.bzrdir.user_transport
1321
 
 
1322
 
    @property
1323
 
    def control_transport(self):
1324
 
        return self._transport
1325
 
 
1326
1319
    def __repr__(self):
1327
1320
        if self._fallback_repositories:
1328
1321
            return '%s(%r, fallback_repositories=%r)' % (
1476
1469
 
1477
1470
        # now gather global repository information
1478
1471
        # XXX: This is available for many repos regardless of listability.
1479
 
        if self.user_transport.listable():
 
1472
        if self.bzrdir.root_transport.listable():
1480
1473
            # XXX: do we want to __define len__() ?
1481
1474
            # Maybe the versionedfiles object should provide a different
1482
1475
            # method to get the number of keys.
1514
1507
 
1515
1508
        ret = []
1516
1509
        for branches, repository in bzrdir.BzrDir.find_bzrdirs(
1517
 
                self.user_transport, evaluate=Evaluator()):
 
1510
                self.bzrdir.root_transport, evaluate=Evaluator()):
1518
1511
            if branches is not None:
1519
1512
                ret.extend(branches)
1520
1513
            if not using and repository is not None:
2588
2581
            keys = tsort.topo_sort(parent_map)
2589
2582
        return [None] + list(keys)
2590
2583
 
2591
 
    def pack(self, hint=None, clean_obsolete_packs=False):
 
2584
    def pack(self, hint=None):
2592
2585
        """Compress the data within the repository.
2593
2586
 
2594
2587
        This operation only makes sense for some repository types. For other
2604
2597
            obtained from the result of commit_write_group(). Out of
2605
2598
            date hints are simply ignored, because concurrent operations
2606
2599
            can obsolete them rapidly.
2607
 
 
2608
 
        :param clean_obsolete_packs: Clean obsolete packs immediately after
2609
 
            the pack operation.
2610
2600
        """
2611
2601
 
2612
2602
    def get_transaction(self):
3178
3168
        """
3179
3169
        raise NotImplementedError(self.open)
3180
3170
 
3181
 
    def _run_post_repo_init_hooks(self, repository, a_bzrdir, shared):
3182
 
        from bzrlib.bzrdir import BzrDir, RepoInitHookParams
3183
 
        hooks = BzrDir.hooks['post_repo_init']
3184
 
        if not hooks:
3185
 
            return
3186
 
        params = RepoInitHookParams(repository, self, a_bzrdir, shared)
3187
 
        for hook in hooks:
3188
 
            hook(params)
3189
 
 
3190
3171
 
3191
3172
class MetaDirRepositoryFormat(RepositoryFormat):
3192
3173
    """Common base class for the new repositories using the metadir layout."""