1424
1424
def suspend_write_group(self):
1425
1425
raise errors.UnsuspendableWriteGroup(self)
1427
def get_missing_parent_inventories(self):
1428
"""Return the keys of missing inventory parents for revisions added in
1431
A revision is not complete if the inventory delta for that revision
1432
cannot be calculated. Therefore if the parent inventories of a
1433
revision are not present, the revision is incomplete, and e.g. cannot
1434
be streamed by a smart server. This method finds missing inventory
1435
parents for revisions added in this write group.
1437
if not self._format.supports_external_lookups:
1438
# This is only an issue for stacked repositories
1440
if not self.is_in_write_group():
1441
raise AssertionError('not in a write group')
1443
# XXX: We assume that every added revision already has its
1444
# corresponding inventory, so we only check for parent inventories that
1445
# might be missing, rather than all inventories.
1446
parents = set(self.revisions._index.get_missing_parents())
1447
parents.discard(_mod_revision.NULL_REVISION)
1448
unstacked_inventories = self.inventories._index
1449
present_inventories = unstacked_inventories.get_parent_map(
1450
key[-1:] for key in parents)
1451
parents.difference_update(present_inventories)
1452
missing_keys = set(('inventories', rev_id) for (rev_id,) in parents)
1427
1455
def refresh_data(self):
1428
1456
"""Re-read any data needed to to synchronise with disk.
3065
3093
target_graph = self.target.get_graph()
3066
3094
revision_ids = frozenset(revision_ids)
3067
# Fast path for the case where all the revisions are already in the
3069
# (Although this does incur an extra round trip for the
3070
# fairly common case where the target doesn't already have the revision
3072
if set(target_graph.get_parent_map(revision_ids)) == revision_ids:
3073
return graph.SearchResult(revision_ids, set(), 0, set())
3074
3095
missing_revs = set()
3075
3096
source_graph = self.source.get_graph()
3076
3097
# ensure we don't pay silly lookup costs.
3432
3453
# nothing to do:
3436
revision_ids = self.search_missing_revision_ids(revision_id,
3437
find_ghosts=find_ghosts).get_keys()
3438
except errors.NoSuchRevision:
3439
raise errors.InstallFailed([revision_id])
3456
revision_ids = self.search_missing_revision_ids(revision_id,
3457
find_ghosts=find_ghosts).get_keys()
3440
3458
if len(revision_ids) == 0:
3442
3460
return self._pack(self.source, self.target, revision_ids)
3998
4016
self.target_repo.signatures.insert_record_stream(substream)
4000
4018
raise AssertionError('kaboom! %s' % (substream_type,))
4019
# Find all the new revisions (including ones from resume_tokens)
4020
missing_keys = self.target_repo.get_missing_parent_inventories()
4002
missing_keys = set()
4003
4022
for prefix, versioned_file in (
4004
4023
('texts', self.target_repo.texts),
4005
4024
('inventories', self.target_repo.inventories),