~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/fetch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-03-03 06:02:49 UTC
  • mfrom: (5672.1.7 branch-revs-to-fetch)
  • Revision ID: pqm@pqm.ubuntu.com-20110303060249-l2zou9i59742nrqf
(spiv) Add Branch.heads_to_fetch API and HPSS request. (Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
350
350
 
351
351
    Factors that go into determining the sort of fetch to perform:
352
352
     * did the caller specify any revision IDs?
353
 
     * did the caller specify a source branch (need to fetch the tip + tags)
 
353
     * did the caller specify a source branch (need to fetch its
 
354
       heads_to_fetch(), usually the tip + tags)
354
355
     * is there an existing target repo (don't need to refetch revs it
355
356
       already has)
356
357
     * target is stacked?  (similar to pre-existing target repo: even if
391
392
                return graph.EverythingNotInOther(
392
393
                    self.target_repo, self.source_repo).execute()
393
394
        heads_to_fetch = set(self._explicit_rev_ids)
394
 
        tags_to_fetch = set()
395
395
        if self.source_branch is not None:
396
 
            try:
397
 
                tags_to_fetch.update(
398
 
                    self.source_branch.tags.get_reverse_tag_dict())
399
 
            except errors.TagsNotSupported:
400
 
                pass
 
396
            must_fetch, if_present_fetch = self.source_branch.heads_to_fetch()
401
397
            if self.source_branch_stop_revision_id is not None:
402
 
                heads_to_fetch.add(self.source_branch_stop_revision_id)
403
 
            else:
404
 
                heads_to_fetch.add(self.source_branch.last_revision())
 
398
                # Replace the tip rev from must_fetch with the stop revision
 
399
                # XXX: this might be wrong if the tip rev is also in the
 
400
                # must_fetch set for other reasons (e.g. it's the tip of
 
401
                # multiple loom threads?), but then it's pretty unclear what it
 
402
                # should mean to specify a stop_revision in that case anyway.
 
403
                must_fetch.discard(self.source_branch.last_revision())
 
404
                must_fetch.add(self.source_branch_stop_revision_id)
 
405
            heads_to_fetch.update(must_fetch)
 
406
        else:
 
407
            if_present_fetch = set()
405
408
        if self.target_repo_kind == TargetRepoKinds.EMPTY:
406
409
            # PendingAncestryResult does not raise errors if a requested head
407
410
            # is absent.  Ideally it would support the
408
411
            # required_ids/if_present_ids distinction, but in practice
409
412
            # heads_to_fetch will almost certainly be present so this doesn't
410
413
            # matter much.
411
 
            all_heads = heads_to_fetch.union(tags_to_fetch)
 
414
            all_heads = heads_to_fetch.union(if_present_fetch)
412
415
            return graph.PendingAncestryResult(all_heads, self.source_repo)
413
416
        return graph.NotInOtherForRevs(self.target_repo, self.source_repo,
414
 
            required_ids=heads_to_fetch, if_present_ids=tags_to_fetch
 
417
            required_ids=heads_to_fetch, if_present_ids=if_present_fetch
415
418
            ).execute()
416
419
 
417
420