3557
3557
"""Get the parent keys for a given root id."""
3558
3558
root_id, rev_id = root_key
3559
3559
# Include direct parents of the revision, but only if they used
3560
# the same root_id and are heads.
3561
3561
parent_keys = []
3562
3562
for parent_id in parent_map[rev_id]:
3563
3563
if parent_id == _mod_revision.NULL_REVISION:
3577
3577
self._revision_id_to_root_id[parent_id] = None
3579
3579
parent_root_id = self._revision_id_to_root_id[parent_id]
3580
if root_id == parent_root_id or parent_root_id is None:
3581
parent_keys.append((root_id, parent_id))
3582
return tuple(parent_keys)
3580
if root_id == parent_root_id:
3581
# With stacking we _might_ want to refer to a non-local
3582
# revision, but this code path only applies when we have the
3583
# full content available, so ghosts really are ghosts, not just
3584
# the edge of local data.
3585
parent_keys.append((parent_id,))
3587
# root_id may be in the parent anyway.
3589
tree = self.source.revision_tree(parent_id)
3590
except errors.NoSuchRevision:
3591
# ghost, can't refer to it.
3595
parent_keys.append((tree.inventory[root_id].revision,))
3596
except errors.NoSuchId:
3599
g = graph.Graph(self.source.revisions)
3600
heads = g.heads(parent_keys)
3602
for key in parent_keys:
3603
if key in heads and key not in selected_keys:
3604
selected_keys.append(key)
3605
return tuple([(root_id,)+ key for key in selected_keys])
3584
3607
def _new_root_data_stream(self, root_keys_to_create, parent_map):
3585
3608
for root_key in root_keys_to_create: