/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: Robert Collins
  • Date: 2010-05-04 06:22:51 UTC
  • mto: This revision was merged to the branch mainline in revision 5206.
  • Revision ID: robertc@robertcollins.net-20100504062251-1ocjhrl53mum9ehw
Minor local_abspath docstring improvement.

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()
3033
3053
    # Is the format experimental ?
3034
3054
    experimental = False
3035
3055
 
3036
 
    def __str__(self):
3037
 
        return "<%s>" % self.__class__.__name__
 
3056
    def __repr__(self):
 
3057
        return "%s()" % self.__class__.__name__
3038
3058
 
3039
3059
    def __eq__(self, other):
3040
3060
        # format objects are generally stateless
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."""
3372
3401
        :return: None.
3373
3402
        """
3374
3403
        ui.ui_factory.warn_experimental_format_fetch(self)
3375
 
        f = _mod_fetch.RepoFetcher(to_repository=self.target,
 
3404
        from bzrlib.fetch import RepoFetcher
 
3405
        # See <https://launchpad.net/bugs/456077> asking for a warning here
 
3406
        if self.source._format.network_name() != self.target._format.network_name():
 
3407
            ui.ui_factory.show_user_warning('cross_format_fetch',
 
3408
                from_format=self.source._format,
 
3409
                to_format=self.target._format)
 
3410
        f = RepoFetcher(to_repository=self.target,
3376
3411
                               from_repository=self.source,
3377
3412
                               last_revision=revision_id,
3378
3413
                               fetch_spec=fetch_spec,
3956
3991
        """See InterRepository.fetch()."""
3957
3992
        if fetch_spec is not None:
3958
3993
            raise AssertionError("Not implemented yet...")
3959
 
        # See <https://launchpad.net/bugs/456077> asking for a warning here
3960
 
        #
3961
 
        # nb this is only active for local-local fetches; other things using
3962
 
        # streaming.
3963
 
        ui.ui_factory.warn_cross_format_fetch(self.source._format,
3964
 
            self.target._format)
3965
3994
        ui.ui_factory.warn_experimental_format_fetch(self)
3966
3995
        if (not self.source.supports_rich_root()
3967
3996
            and self.target.supports_rich_root()):
3969
3998
            self._revision_id_to_root_id = {}
3970
3999
        else:
3971
4000
            self._converting_to_rich_root = False
 
4001
        # See <https://launchpad.net/bugs/456077> asking for a warning here
 
4002
        if self.source._format.network_name() != self.target._format.network_name():
 
4003
            ui.ui_factory.show_user_warning('cross_format_fetch',
 
4004
                from_format=self.source._format,
 
4005
                to_format=self.target._format)
3972
4006
        revision_ids = self.target.search_missing_revision_ids(self.source,
3973
4007
            revision_id, find_ghosts=find_ghosts).get_keys()
3974
4008
        if not revision_ids:
4257
4291
                    self._extract_and_insert_inventories(
4258
4292
                        substream, src_serializer)
4259
4293
            elif substream_type == 'inventory-deltas':
4260
 
                ui.ui_factory.warn_cross_format_fetch(src_format,
4261
 
                    self.target_repo._format)
4262
4294
                self._extract_and_insert_inventory_deltas(
4263
4295
                    substream, src_serializer)
4264
4296
            elif substream_type == 'chk_bytes':