/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/fetch.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

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,
31
33
    tsort,
32
34
    versionedfile,
33
35
    )
35
37
import bzrlib
36
38
from bzrlib import (
37
39
    errors,
 
40
    symbol_versioning,
38
41
    ui,
39
42
    )
40
43
from bzrlib.revision import NULL_REVISION
49
52
    """
50
53
 
51
54
    def __init__(self, to_repository, from_repository, last_revision=None,
52
 
        find_ghosts=True, fetch_spec=None):
 
55
        pb=None, find_ghosts=True, fetch_spec=None):
53
56
        """Create a repo fetcher.
54
57
 
55
58
        :param last_revision: If set, try to limit to the data this revision
56
59
            references.
57
60
        :param find_ghosts: If True search the entire history for ghosts.
 
61
        :param pb: ProgressBar object to use; deprecated and ignored.
 
62
            This method will just create one on top of the stack.
58
63
        """
 
64
        if pb is not None:
 
65
            symbol_versioning.warn(
 
66
                symbol_versioning.deprecated_in((1, 14, 0))
 
67
                % "pb parameter to RepoFetcher.__init__")
 
68
            # and for simplicity it is in fact ignored
59
69
        # repository.fetch has the responsibility for short-circuiting
60
70
        # attempts to copy between a repository and itself.
61
71
        self.to_repository = to_repository
244
254
        root_id_order.sort(key=operator.itemgetter(0))
245
255
        # Create a record stream containing the roots to create.
246
256
        if len(revs) > 100:
247
 
            # XXX: not covered by tests, should have a flag to always run
248
 
            # this. -- mbp 20100129
249
 
            graph = self.source_repo.get_known_graph_ancestry(revs)
 
257
            graph = _get_rich_root_heads_graph(self.source_repo, revs)
250
258
        new_roots_stream = _new_root_data_stream(
251
259
            root_id_order, rev_id_to_root_id, parent_map, self.source, graph)
252
260
        return [('texts', new_roots_stream)]
254
262
 
255
263
def _get_rich_root_heads_graph(source_repo, revision_ids):
256
264
    """Get a Graph object suitable for asking heads() for new rich roots."""
257
 
    return 
 
265
    st = static_tuple.StaticTuple
 
266
    revision_keys = [st(r_id).intern() for r_id in revision_ids]
 
267
    known_graph = source_repo.revisions.get_known_graph_ancestry(
 
268
                    revision_keys)
 
269
    return _mod_graph.GraphThunkIdsToKeys(known_graph)
258
270
 
259
271
 
260
272
def _new_root_data_stream(