2623
2623
result[revision_id] = (_mod_revision.NULL_REVISION,)
2626
def _get_parent_map_no_fallbacks(self, revision_ids):
2627
"""Same as Repository.get_parent_map except doesn't query fallbacks."""
2628
# revisions index works in keys; this just works in revisions
2629
# therefore wrap and unwrap
2632
for revision_id in revision_ids:
2633
if revision_id == _mod_revision.NULL_REVISION:
2634
result[revision_id] = ()
2635
elif revision_id is None:
2636
raise ValueError('get_parent_map(None) is not valid')
2638
query_keys.append((revision_id ,))
2639
vf = self.revisions.without_fallbacks()
2640
for ((revision_id,), parent_keys) in \
2641
vf.get_parent_map(query_keys).iteritems():
2643
result[revision_id] = tuple([parent_revid
2644
for (parent_revid,) in parent_keys])
2646
result[revision_id] = (_mod_revision.NULL_REVISION,)
2626
2649
def _make_parents_provider(self):
2650
if not self._format.supports_external_lookups:
2652
return graph.StackedParentsProvider(_FallbacksList(self))
2654
def _make_parents_provider_with_no_fallbacks(self):
2655
return graph.CallableToParentsProviderAdapter(
2656
self._get_parent_map_no_fallbacks)
2629
2658
@needs_read_lock
2630
2659
def get_known_graph_ancestry(self, revision_ids):
4517
4546
except StopIteration:
4518
4547
# No more history
4551
class _FallbacksList(object):
4552
"""An iterable yielding a repo followed by its fallbacks.
4554
Each iterator made from this will reflect the current list of
4555
fallbacks at the time the iterator is made.
4557
i.e. if a _make_parents_provider implementation uses
4558
StackedParentsProvider(_FallbacksList(self)), then it is safe to do::
4560
pp = repo._make_parents_provider()
4561
pp.add_fallback_repository(other_repo)
4562
result = pp.get_parent_map(...)
4563
# The result will include revs from other_repo
4566
def __init__(self, repo):
4570
repo_pp = self.repo._make_parents_provider_with_no_fallbacks()
4571
return iter([repo_pp] + self.repo._fallback_repositories)