/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Jelmer Vernooij
  • Date: 2010-04-30 11:35:43 UTC
  • mfrom: (5195 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5197.
  • Revision ID: jelmer@samba.org-20100430113543-tiqqhmqa3d8no4iu
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
    lru_cache,
41
41
    osutils,
42
42
    revision as _mod_revision,
 
43
    static_tuple,
43
44
    symbol_versioning,
44
45
    trace,
45
46
    tsort,
863
864
# Repositories
864
865
 
865
866
 
866
 
class Repository(_RelockDebugMixin):
 
867
class Repository(_RelockDebugMixin, bzrdir.ControlComponent):
867
868
    """Repository holding history for one or more branches.
868
869
 
869
870
    The repository holds and retrieves historical information including
1290
1291
 
1291
1292
        :param _format: The format of the repository on disk.
1292
1293
        :param a_bzrdir: The BzrDir of the repository.
1293
 
 
1294
 
        In the future we will have a single api for all stores for
1295
 
        getting file texts, inventories and revisions, then
1296
 
        this construct will accept instances of those things.
1297
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.
1298
1298
        super(Repository, self).__init__()
1299
1299
        self._format = _format
1300
1300
        # the following are part of the public API for Repository:
1315
1315
        # rather copying them?
1316
1316
        self._safe_to_return_from_cache = False
1317
1317
 
 
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
 
1318
1326
    def __repr__(self):
1319
1327
        if self._fallback_repositories:
1320
1328
            return '%s(%r, fallback_repositories=%r)' % (
1468
1476
 
1469
1477
        # now gather global repository information
1470
1478
        # XXX: This is available for many repos regardless of listability.
1471
 
        if self.bzrdir.root_transport.listable():
 
1479
        if self.user_transport.listable():
1472
1480
            # XXX: do we want to __define len__() ?
1473
1481
            # Maybe the versionedfiles object should provide a different
1474
1482
            # method to get the number of keys.
1506
1514
 
1507
1515
        ret = []
1508
1516
        for branches, repository in bzrdir.BzrDir.find_bzrdirs(
1509
 
                self.bzrdir.root_transport, evaluate=Evaluator()):
 
1517
                self.user_transport, evaluate=Evaluator()):
1510
1518
            if branches is not None:
1511
1519
                ret.extend(branches)
1512
1520
            if not using and repository is not None:
2580
2588
            keys = tsort.topo_sort(parent_map)
2581
2589
        return [None] + list(keys)
2582
2590
 
2583
 
    def pack(self, hint=None):
 
2591
    def pack(self, hint=None, clean_obsolete_packs=False):
2584
2592
        """Compress the data within the repository.
2585
2593
 
2586
2594
        This operation only makes sense for some repository types. For other
2596
2604
            obtained from the result of commit_write_group(). Out of
2597
2605
            date hints are simply ignored, because concurrent operations
2598
2606
            can obsolete them rapidly.
 
2607
 
 
2608
        :param clean_obsolete_packs: Clean obsolete packs immediately after
 
2609
            the pack operation.
2599
2610
        """
2600
2611
 
2601
2612
    def get_transaction(self):
2626
2637
    def _make_parents_provider(self):
2627
2638
        return self
2628
2639
 
 
2640
    @needs_read_lock
 
2641
    def get_known_graph_ancestry(self, revision_ids):
 
2642
        """Return the known graph for a set of revision ids and their ancestors.
 
2643
        """
 
2644
        st = static_tuple.StaticTuple
 
2645
        revision_keys = [st(r_id).intern() for r_id in revision_ids]
 
2646
        known_graph = self.revisions.get_known_graph_ancestry(revision_keys)
 
2647
        return graph.GraphThunkIdsToKeys(known_graph)
 
2648
 
2629
2649
    def get_graph(self, other_repository=None):
2630
2650
        """Return the graph walker for this repository format"""
2631
2651
        parents_provider = self._make_parents_provider()
3158
3178
        """
3159
3179
        raise NotImplementedError(self.open)
3160
3180
 
 
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
 
3161
3190
 
3162
3191
class MetaDirRepositoryFormat(RepositoryFormat):
3163
3192
    """Common base class for the new repositories using the metadir layout."""