509
510
def get_format_description(self):
510
511
"""See RepositoryFormat.get_format_description()."""
511
512
return "Knit repository format 4"
514
class InterKnitRepo(InterSameDataRepository):
515
"""Optimised code paths between Knit based repositories."""
518
def _get_repo_format_to_test(self):
519
return RepositoryFormatKnit1()
522
def is_compatible(source, target):
523
"""Be compatible with known Knit formats.
525
We don't test for the stores being of specific types because that
526
could lead to confusing results, and there is no need to be
530
are_knits = (isinstance(source._format, RepositoryFormatKnit) and
531
isinstance(target._format, RepositoryFormatKnit))
532
except AttributeError:
534
return are_knits and InterRepository._same_model(source, target)
537
def search_missing_revision_ids(self, revision_id=None, find_ghosts=True):
538
"""See InterRepository.missing_revision_ids()."""
539
if revision_id is not None:
540
source_ids = self.source.get_ancestry(revision_id)
541
if source_ids[0] is not None:
542
raise AssertionError()
545
source_ids = self.source.all_revision_ids()
546
source_ids_set = set(source_ids)
547
# source_ids is the worst possible case we may need to pull.
548
# now we want to filter source_ids against what we actually
549
# have in target, but don't try to check for existence where we know
550
# we do not have a revision as that would be pointless.
551
target_ids = set(self.target.all_revision_ids())
552
possibly_present_revisions = target_ids.intersection(source_ids_set)
553
actually_present_revisions = set(
554
self.target._eliminate_revisions_not_present(possibly_present_revisions))
555
required_revisions = source_ids_set.difference(actually_present_revisions)
556
if revision_id is not None:
557
# we used get_ancestry to determine source_ids then we are assured all
558
# revisions referenced are present as they are installed in topological order.
559
# and the tip revision was validated by get_ancestry.
560
result_set = required_revisions
562
# if we just grabbed the possibly available ids, then
563
# we only have an estimate of whats available and need to validate
564
# that against the revision records.
566
self.source._eliminate_revisions_not_present(required_revisions))
567
return self.source.revision_ids_to_search_result(result_set)
570
InterRepository.register_optimiser(InterKnitRepo)