3522
3522
return deltas[0][1:]
3524
def _get_parent_keys(self, root_key, parent_map):
3525
"""Get the parent keys for a given root id."""
3526
root_id, rev_id = root_key
3527
# Include direct parents of the revision, but only if they used
3528
# the same root_id and are heads.
3530
for parent_id in parent_map[rev_id]:
3531
if parent_id == _mod_revision.NULL_REVISION:
3533
if parent_id not in self._revision_id_to_root_id:
3534
# We probably didn't read this revision, go spend the
3535
# extra effort to actually check
3537
tree = self.source.revision_tree(parent_id)
3538
except errors.NoSuchRevision:
3539
# Ghost, fill out _revision_id_to_root_id in case we
3540
# encounter this again.
3541
# But set parent_root_id to None since we don't really know
3542
parent_root_id = None
3544
parent_root_id = tree.get_root_id()
3545
self._revision_id_to_root_id[parent_id] = None
3547
parent_root_id = self._revision_id_to_root_id[parent_id]
3548
if root_id == parent_root_id:
3549
# With stacking we _might_ want to refer to a non-local
3550
# revision, but this code path only applies when we have the
3551
# full content available, so ghosts really are ghosts, not just
3552
# the edge of local data.
3553
parent_keys.append((parent_id,))
3555
# root_id may be in the parent anyway.
3557
tree = self.source.revision_tree(parent_id)
3558
except errors.NoSuchRevision:
3559
# ghost, can't refer to it.
3563
parent_keys.append((tree.inventory[root_id].revision,))
3564
except errors.NoSuchId:
3524
def _new_root_data_stream(self, root_keys_to_create, parent_map):
3525
from bzrlib.fetch import _parent_keys_for_root_version
3567
3526
g = graph.Graph(self.source.revisions)
3568
heads = g.heads(parent_keys)
3570
for key in parent_keys:
3571
if key in heads and key not in selected_keys:
3572
selected_keys.append(key)
3573
return tuple([(root_id,)+ key for key in selected_keys])
3575
def _new_root_data_stream(self, root_keys_to_create, parent_map):
3576
3527
for root_key in root_keys_to_create:
3577
parent_keys = self._get_parent_keys(root_key, parent_map)
3528
root_id, rev_id = root_key
3529
parent_keys = _parent_keys_for_root_version(
3530
root_id, rev_id, self._revision_id_to_root_id, parent_map, g,
3578
3532
yield versionedfile.FulltextContentFactory(root_key,
3579
3533
parent_keys, None, '')