~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Patch Queue Manager
  • Date: 2016-02-01 19:13:13 UTC
  • mfrom: (6614.2.2 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20160201191313-wdfvmfff1djde6oq
(vila) Release 2.7.0 (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
 
18
17
"""Copying of history from one branch to another.
19
18
 
20
19
The basic plan is that every branch knows the history of everything
23
22
branch.
24
23
"""
25
24
 
 
25
from __future__ import absolute_import
 
26
 
26
27
import operator
27
28
 
28
29
from bzrlib.lazy_import import lazy_import
29
30
lazy_import(globals(), """
30
31
from bzrlib import (
31
 
    graph as _mod_graph,
32
32
    tsort,
33
33
    versionedfile,
 
34
    vf_search,
34
35
    )
35
36
""")
36
37
from bzrlib import (
37
38
    errors,
38
39
    ui,
39
40
    )
 
41
from bzrlib.i18n import gettext
40
42
from bzrlib.revision import NULL_REVISION
41
43
from bzrlib.trace import mutter
42
44
 
93
95
        pb = ui.ui_factory.nested_progress_bar()
94
96
        pb.show_pct = pb.show_count = False
95
97
        try:
96
 
            pb.update("Finding revisions", 0, 2)
 
98
            pb.update(gettext("Finding revisions"), 0, 2)
97
99
            search_result = self._revids_to_fetch()
98
100
            mutter('fetching: %s', search_result)
99
101
            if search_result.is_empty():
100
102
                return
101
 
            pb.update("Fetching revisions", 1, 2)
 
103
            pb.update(gettext("Fetching revisions"), 1, 2)
102
104
            self._fetch_everything_for_search(search_result)
103
105
        finally:
104
106
            pb.finished()
160
162
        elif self._last_revision == NULL_REVISION:
161
163
            # fetch_spec is None + last_revision is null => empty fetch.
162
164
            # explicit limit of no revisions needed
163
 
            return _mod_graph.EmptySearchResult()
 
165
            return vf_search.EmptySearchResult()
164
166
        elif self._last_revision is not None:
165
 
            return _mod_graph.NotInOtherForRevs(self.to_repository,
 
167
            return vf_search.NotInOtherForRevs(self.to_repository,
166
168
                self.from_repository, [self._last_revision],
167
169
                find_ghosts=self.find_ghosts).execute()
168
170
        else: # self._last_revision is None:
169
 
            return _mod_graph.EverythingNotInOther(self.to_repository,
 
171
            return vf_search.EverythingNotInOther(self.to_repository,
170
172
                self.from_repository,
171
173
                find_ghosts=self.find_ghosts).execute()
172
174
 
201
203
        revs = list(revs)
202
204
        while revs:
203
205
            for tree in self.source.revision_trees(revs[:100]):
204
 
                if tree.inventory.revision_id is None:
205
 
                    tree.inventory.revision_id = tree.get_revision_id()
 
206
                if tree.root_inventory.revision_id is None:
 
207
                    tree.root_inventory.revision_id = tree.get_revision_id()
206
208
                yield tree
207
209
            revs = revs[100:]
208
210
 
209
211
    def _find_root_ids(self, revs, parent_map, graph):
210
212
        revision_root = {}
211
213
        for tree in self.iter_rev_trees(revs):
212
 
            revision_id = tree.inventory.root.revision
213
214
            root_id = tree.get_root_id()
 
215
            revision_id = tree.get_file_revision(root_id, u"")
214
216
            revision_root[revision_id] = root_id
215
217
        # Find out which parents we don't already know root ids for
216
218
        parents = set()
388
390
                    "limit is only supported with a source branch set")
389
391
            # Caller hasn't specified any revisions or source branch
390
392
            if self.target_repo_kind == TargetRepoKinds.EMPTY:
391
 
                return _mod_graph.EverythingResult(self.source_repo)
 
393
                return vf_search.EverythingResult(self.source_repo)
392
394
            else:
393
395
                # We want everything not already in the target (or target's
394
396
                # fallbacks).
395
 
                return _mod_graph.EverythingNotInOther(
 
397
                return vf_search.EverythingNotInOther(
396
398
                    self.target_repo, self.source_repo).execute()
397
399
        heads_to_fetch = set(self._explicit_rev_ids)
398
400
        if self.source_branch is not None:
415
417
            # heads_to_fetch will almost certainly be present so this doesn't
416
418
            # matter much.
417
419
            all_heads = heads_to_fetch.union(if_present_fetch)
418
 
            ret = _mod_graph.PendingAncestryResult(all_heads, self.source_repo)
 
420
            ret = vf_search.PendingAncestryResult(all_heads, self.source_repo)
419
421
            if self.limit is not None:
420
422
                graph = self.source_repo.get_graph()
421
423
                topo_order = list(graph.iter_topo_order(ret.get_keys()))
423
425
                ret = self.source_repo.revision_ids_to_search_result(result_set)
424
426
            return ret
425
427
        else:
426
 
            return _mod_graph.NotInOtherForRevs(self.target_repo, self.source_repo,
 
428
            return vf_search.NotInOtherForRevs(self.target_repo, self.source_repo,
427
429
                required_ids=heads_to_fetch, if_present_ids=if_present_fetch,
428
430
                limit=self.limit).execute()