~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Ian Clatworthy
  • Date: 2009-09-09 00:49:50 UTC
  • mto: (4634.37.2 prepare-2.0)
  • mto: This revision was merged to the branch mainline in revision 4689.
  • Revision ID: ian.clatworthy@canonical.com-20090909004950-43z4zdicb5u91iet
tweak quick reference naming to make it consistent with other PDFs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2010 Canonical Ltd
 
1
# Copyright (C) 2005, 2006, 2008, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
28
28
from bzrlib.lazy_import import lazy_import
29
29
lazy_import(globals(), """
30
30
from bzrlib import (
31
 
    graph as _mod_graph,
32
 
    static_tuple,
33
31
    tsort,
34
32
    versionedfile,
35
33
    )
38
36
from bzrlib import (
39
37
    errors,
40
38
    symbol_versioning,
41
 
    ui,
42
39
    )
43
40
from bzrlib.revision import NULL_REVISION
44
41
from bzrlib.trace import mutter
 
42
import bzrlib.ui
45
43
 
46
44
 
47
45
class RepoFetcher(object):
52
50
    """
53
51
 
54
52
    def __init__(self, to_repository, from_repository, last_revision=None,
55
 
        find_ghosts=True, fetch_spec=None):
 
53
        pb=None, find_ghosts=True, fetch_spec=None):
56
54
        """Create a repo fetcher.
57
55
 
58
56
        :param last_revision: If set, try to limit to the data this revision
59
57
            references.
60
58
        :param find_ghosts: If True search the entire history for ghosts.
 
59
        :param pb: ProgressBar object to use; deprecated and ignored.
 
60
            This method will just create one on top of the stack.
61
61
        """
 
62
        if pb is not None:
 
63
            symbol_versioning.warn(
 
64
                symbol_versioning.deprecated_in((1, 14, 0))
 
65
                % "pb parameter to RepoFetcher.__init__")
 
66
            # and for simplicity it is in fact ignored
62
67
        # repository.fetch has the responsibility for short-circuiting
63
68
        # attempts to copy between a repository and itself.
64
69
        self.to_repository = to_repository
91
96
        # assert not missing
92
97
        self.count_total = 0
93
98
        self.file_ids_names = {}
94
 
        pb = ui.ui_factory.nested_progress_bar()
 
99
        pb = bzrlib.ui.ui_factory.nested_progress_bar()
95
100
        pb.show_pct = pb.show_count = False
96
101
        try:
97
102
            pb.update("Finding revisions", 0, 2)
118
123
            raise errors.IncompatibleRepositories(
119
124
                self.from_repository, self.to_repository,
120
125
                "different rich-root support")
121
 
        pb = ui.ui_factory.nested_progress_bar()
 
126
        pb = bzrlib.ui.ui_factory.nested_progress_bar()
122
127
        try:
123
128
            pb.update("Get stream source")
124
129
            source = self.from_repository._get_source(
246
251
        # yet, and are unlikely to in non-rich-root environments anyway.
247
252
        root_id_order.sort(key=operator.itemgetter(0))
248
253
        # Create a record stream containing the roots to create.
249
 
        if len(revs) > 100:
250
 
            # XXX: not covered by tests, should have a flag to always run
251
 
            # this. -- mbp 20100129
252
 
            graph = _get_rich_root_heads_graph(self.source, revs)
 
254
        from bzrlib.graph import FrozenHeadsCache
 
255
        graph = FrozenHeadsCache(graph)
253
256
        new_roots_stream = _new_root_data_stream(
254
257
            root_id_order, rev_id_to_root_id, parent_map, self.source, graph)
255
258
        return [('texts', new_roots_stream)]
256
259
 
257
260
 
258
 
def _get_rich_root_heads_graph(source_repo, revision_ids):
259
 
    """Get a Graph object suitable for asking heads() for new rich roots."""
260
 
    st = static_tuple.StaticTuple
261
 
    revision_keys = [st(r_id).intern() for r_id in revision_ids]
262
 
    known_graph = source_repo.revisions.get_known_graph_ancestry(
263
 
                    revision_keys)
264
 
    return _mod_graph.GraphThunkIdsToKeys(known_graph)
265
 
 
266
 
 
267
261
def _new_root_data_stream(
268
262
    root_keys_to_create, rev_id_to_root_id_map, parent_map, repo, graph=None):
269
263
    """Generate a texts substream of synthesised root entries.