2649
2649
def _make_parents_provider(self):
2650
2650
if not self._format.supports_external_lookups:
2652
return graph.StackedParentsProvider(_FallbacksList(self))
2652
return graph.StackedParentsProvider(_LazyListJoin(
2653
[self._make_parents_provider_unstacked()],
2654
self._fallback_repositories))
2654
def _make_parents_provider_with_no_fallbacks(self):
2656
def _make_parents_provider_unstacked(self):
2655
2657
return graph.CallableToParentsProviderAdapter(
2656
2658
self._get_parent_map_no_fallbacks)
4551
class _FallbacksList(object):
4552
"""An iterable yielding a repo followed by its fallbacks.
4553
class _LazyListJoin(object):
4554
"""An iterable yielding the contents of many lists as one list.
4554
Each iterator made from this will reflect the current list of
4555
fallbacks at the time the iterator is made.
4556
Each iterator made from this will reflect the current contents of the lists
4557
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::
4559
This is used by Repository's _make_parents_provider implementation so that
4560
pp = repo._make_parents_provider()
4561
pp.add_fallback_repository(other_repo)
4562
pp = repo._make_parents_provider() # uses a list of fallback repos
4563
pp.add_fallback_repository(other_repo) # appends to that list
4562
4564
result = pp.get_parent_map(...)
4563
4565
# The result will include revs from other_repo
4566
def __init__(self, repo):
4568
def __init__(self, *list_parts):
4569
self.list_parts = list_parts
4569
4571
def __iter__(self):
4570
repo_pp = self.repo._make_parents_provider_with_no_fallbacks()
4571
return iter([repo_pp] + self.repo._fallback_repositories)
4573
for list_part in self.list_parts:
4574
full_list.extend(list_part)
4575
return iter(full_list)