~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Martin
  • Date: 2011-05-21 16:29:38 UTC
  • mto: This revision was merged to the branch mainline in revision 5907.
  • Revision ID: gzlist@googlemail.com-20110521162938-1vrw3hp0197l3vrl
Add tests for non-ascii conflict serialisation

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
    )
160
160
        elif self._last_revision == NULL_REVISION:
161
161
            # fetch_spec is None + last_revision is null => empty fetch.
162
162
            # explicit limit of no revisions needed
163
 
            return _mod_graph.EmptySearchResult()
 
163
            return graph.EmptySearchResult()
164
164
        elif self._last_revision is not None:
165
 
            return _mod_graph.NotInOtherForRevs(self.to_repository,
 
165
            return graph.NotInOtherForRevs(self.to_repository,
166
166
                self.from_repository, [self._last_revision],
167
167
                find_ghosts=self.find_ghosts).execute()
168
168
        else: # self._last_revision is None:
169
 
            return _mod_graph.EverythingNotInOther(self.to_repository,
 
169
            return graph.EverythingNotInOther(self.to_repository,
170
170
                self.from_repository,
171
171
                find_ghosts=self.find_ghosts).execute()
172
172
 
371
371
        self.source_repo = None
372
372
        self.target_repo = None
373
373
        self.target_repo_kind = None
374
 
        self.limit = None
375
374
 
376
375
    def add_revision_ids(self, revision_ids):
377
376
        """Add revision_ids to the set of revision_ids to be fetched."""
378
377
        self._explicit_rev_ids.update(revision_ids)
379
 
 
 
378
        
380
379
    def make_fetch_spec(self):
381
380
        """Build a SearchResult or PendingAncestryResult or etc."""
382
381
        if self.target_repo_kind is None or self.source_repo is None:
383
382
            raise AssertionError(
384
383
                'Incomplete FetchSpecFactory: %r' % (self.__dict__,))
385
384
        if len(self._explicit_rev_ids) == 0 and self.source_branch is None:
386
 
            if self.limit is not None:
387
 
                raise NotImplementedError(
388
 
                    "limit is only supported with a source branch set")
389
385
            # Caller hasn't specified any revisions or source branch
390
386
            if self.target_repo_kind == TargetRepoKinds.EMPTY:
391
 
                return _mod_graph.EverythingResult(self.source_repo)
 
387
                return graph.EverythingResult(self.source_repo)
392
388
            else:
393
389
                # We want everything not already in the target (or target's
394
390
                # fallbacks).
395
 
                return _mod_graph.EverythingNotInOther(
 
391
                return graph.EverythingNotInOther(
396
392
                    self.target_repo, self.source_repo).execute()
397
393
        heads_to_fetch = set(self._explicit_rev_ids)
398
394
        if self.source_branch is not None:
415
411
            # heads_to_fetch will almost certainly be present so this doesn't
416
412
            # matter much.
417
413
            all_heads = heads_to_fetch.union(if_present_fetch)
418
 
            ret = _mod_graph.PendingAncestryResult(all_heads, self.source_repo)
419
 
            if self.limit is not None:
420
 
                graph = self.source_repo.get_graph()
421
 
                topo_order = list(graph.iter_topo_order(ret.get_keys()))
422
 
                result_set = topo_order[:self.limit]
423
 
                ret = self.source_repo.revision_ids_to_search_result(result_set)
424
 
            return ret
425
 
        else:
426
 
            return _mod_graph.NotInOtherForRevs(self.target_repo, self.source_repo,
427
 
                required_ids=heads_to_fetch, if_present_ids=if_present_fetch,
428
 
                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