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
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:
397
tags_to_fetch.update(
398
self.source_branch.tags.get_reverse_tag_dict())
399
except errors.TagsNotSupported:
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)
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)
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
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