~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-09 22:14:24 UTC
  • mfrom: (5777.4.2 mutableinventorytree)
  • mto: This revision was merged to the branch mainline in revision 5787.
  • Revision ID: jelmer@samba.org-20110409221424-a2air35exbz50hi8
Mergemutableinventorytree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
from bzrlib.lazy_import import lazy_import
29
29
lazy_import(globals(), """
30
30
from bzrlib import (
31
 
    graph as _mod_graph,
 
31
    graph,
32
32
    tsort,
33
33
    versionedfile,
34
34
    )
37
37
    errors,
38
38
    ui,
39
39
    )
40
 
from bzrlib.i18n import gettext
41
40
from bzrlib.revision import NULL_REVISION
42
41
from bzrlib.trace import mutter
43
42
 
94
93
        pb = ui.ui_factory.nested_progress_bar()
95
94
        pb.show_pct = pb.show_count = False
96
95
        try:
97
 
            pb.update(gettext("Finding revisions"), 0, 2)
 
96
            pb.update("Finding revisions", 0, 2)
98
97
            search_result = self._revids_to_fetch()
99
98
            mutter('fetching: %s', search_result)
100
99
            if search_result.is_empty():
101
100
                return
102
 
            pb.update(gettext("Fetching revisions"), 1, 2)
 
101
            pb.update("Fetching revisions", 1, 2)
103
102
            self._fetch_everything_for_search(search_result)
104
103
        finally:
105
104
            pb.finished()
161
160
        elif self._last_revision == NULL_REVISION:
162
161
            # fetch_spec is None + last_revision is null => empty fetch.
163
162
            # explicit limit of no revisions needed
164
 
            return _mod_graph.EmptySearchResult()
 
163
            return graph.EmptySearchResult()
165
164
        elif self._last_revision is not None:
166
 
            return _mod_graph.NotInOtherForRevs(self.to_repository,
 
165
            return graph.NotInOtherForRevs(self.to_repository,
167
166
                self.from_repository, [self._last_revision],
168
167
                find_ghosts=self.find_ghosts).execute()
169
168
        else: # self._last_revision is None:
170
 
            return _mod_graph.EverythingNotInOther(self.to_repository,
 
169
            return graph.EverythingNotInOther(self.to_repository,
171
170
                self.from_repository,
172
171
                find_ghosts=self.find_ghosts).execute()
173
172
 
318
317
                pass
319
318
            else:
320
319
                try:
321
 
                    parent_ids.append(tree.get_file_revision(root_id))
 
320
                    parent_ids.append(tree.inventory[root_id].revision)
322
321
                except errors.NoSuchId:
323
322
                    # not in the tree
324
323
                    pass
372
371
        self.source_repo = None
373
372
        self.target_repo = None
374
373
        self.target_repo_kind = None
375
 
        self.limit = None
376
374
 
377
375
    def add_revision_ids(self, revision_ids):
378
376
        """Add revision_ids to the set of revision_ids to be fetched."""
379
377
        self._explicit_rev_ids.update(revision_ids)
380
 
 
 
378
        
381
379
    def make_fetch_spec(self):
382
380
        """Build a SearchResult or PendingAncestryResult or etc."""
383
381
        if self.target_repo_kind is None or self.source_repo is None:
384
382
            raise AssertionError(
385
383
                'Incomplete FetchSpecFactory: %r' % (self.__dict__,))
386
384
        if len(self._explicit_rev_ids) == 0 and self.source_branch is None:
387
 
            if self.limit is not None:
388
 
                raise NotImplementedError(
389
 
                    "limit is only supported with a source branch set")
390
385
            # Caller hasn't specified any revisions or source branch
391
386
            if self.target_repo_kind == TargetRepoKinds.EMPTY:
392
 
                return _mod_graph.EverythingResult(self.source_repo)
 
387
                return graph.EverythingResult(self.source_repo)
393
388
            else:
394
389
                # We want everything not already in the target (or target's
395
390
                # fallbacks).
396
 
                return _mod_graph.EverythingNotInOther(
 
391
                return graph.EverythingNotInOther(
397
392
                    self.target_repo, self.source_repo).execute()
398
393
        heads_to_fetch = set(self._explicit_rev_ids)
399
394
        if self.source_branch is not None:
416
411
            # heads_to_fetch will almost certainly be present so this doesn't
417
412
            # matter much.
418
413
            all_heads = heads_to_fetch.union(if_present_fetch)
419
 
            ret = _mod_graph.PendingAncestryResult(all_heads, self.source_repo)
420
 
            if self.limit is not None:
421
 
                graph = self.source_repo.get_graph()
422
 
                topo_order = list(graph.iter_topo_order(ret.get_keys()))
423
 
                result_set = topo_order[:self.limit]
424
 
                ret = self.source_repo.revision_ids_to_search_result(result_set)
425
 
            return ret
426
 
        else:
427
 
            return _mod_graph.NotInOtherForRevs(self.target_repo, self.source_repo,
428
 
                required_ids=heads_to_fetch, if_present_ids=if_present_fetch,
429
 
                limit=self.limit).execute()
 
414
            return graph.PendingAncestryResult(all_heads, self.source_repo)
 
415
        return graph.NotInOtherForRevs(self.target_repo, self.source_repo,
 
416
            required_ids=heads_to_fetch, if_present_ids=if_present_fetch
 
417
            ).execute()
 
418
 
 
419