def test_is_compatible_and_registered(self): # InterWeaveRepo is compatible when either side # is a format 5/6/7 branch from bzrlib.repofmt import knitrepo formats = [ RepositoryFormat5(), RepositoryFormat6(), RepositoryFormat7() ] incompatible_formats = [ RepositoryFormat4(), knitrepo.RepositoryFormatKnit1(), ] repo_a = self.make_repository('a') repo_b = self.make_repository('b') is_compatible = InterWeaveRepo.is_compatible for source in incompatible_formats: # force incompatible left then right repo_a._format = source repo_b._format = formats[0] self.assertFalse(is_compatible(repo_a, repo_b)) self.assertFalse(is_compatible(repo_b, repo_a)) for source in formats: repo_a._format = source for target in formats: repo_b._format = target self.assertTrue(is_compatible(repo_a, repo_b)) self.assertEqual(InterWeaveRepo, InterRepository.get(repo_a, repo_b).__class__)
def is_compatible(source, target): """Be compatible with known Knit formats. We don't test for the stores being of specific types because that could lead to confusing results, and there is no need to be overly general. """ try: are_knits = (isinstance(source._format, RepositoryFormatKnit) and isinstance(target._format, RepositoryFormatKnit)) except AttributeError: return False return are_knits and InterRepository._same_model(source, target)
def is_compatible(source, target): """Be compatible with known Knit formats. We don't test for the stores being of specific types because that could lead to confusing results, and there is no need to be overly general. """ try: are_knits = isinstance(source._format, RepositoryFormatKnit) and isinstance( target._format, RepositoryFormatKnit ) except AttributeError: return False return are_knits and InterRepository._same_model(source, target)
@needs_read_lock def search_missing_revision_ids(self, find_ghosts=True, revision_ids=None, if_present_ids=None, limit=None): """See InterRepository.search_missing_revision_ids().""" source_ids_set = self._present_source_revisions_for(revision_ids, if_present_ids) # source_ids is the worst possible case we may need to pull. # now we want to filter source_ids against what we actually # have in target, but don't try to check for existence where we know # we do not have a revision as that would be pointless. target_ids = set(self.target.all_revision_ids()) possibly_present_revisions = target_ids.intersection(source_ids_set) actually_present_revisions = set(self.target._eliminate_revisions_not_present(possibly_present_revisions)) required_revisions = source_ids_set.difference(actually_present_revisions) if revision_ids is not None: # we used get_ancestry to determine source_ids then we are assured all # revisions referenced are present as they are installed in topological order. # and the tip revision was validated by get_ancestry. result_set = required_revisions else: # if we just grabbed the possibly available ids, then # we only have an estimate of whats available and need to validate # that against the revision records. result_set = set(self.source._eliminate_revisions_not_present(required_revisions)) if limit is not None: topo_ordered = self.source.get_graph().iter_topo_order(result_set) result_set = set(itertools.islice(topo_ordered, limit)) return self.source.revision_ids_to_search_result(result_set) InterRepository.register_optimiser(InterKnitRepo)
# we do not have a revision as that would be pointless. target_ids = set(self.target._all_possible_ids()) possibly_present_revisions = target_ids.intersection(source_ids_set) actually_present_revisions = set( self.target._eliminate_revisions_not_present(possibly_present_revisions)) required_revisions = source_ids_set.difference(actually_present_revisions) if revision_ids is not None: # we used get_ancestry to determine source_ids then we are assured all # revisions referenced are present as they are installed in topological order. # and the tip revision was validated by get_ancestry. result_set = required_revisions else: # if we just grabbed the possibly available ids, then # we only have an estimate of whats available and need to validate # that against the revision records. result_set = set( self.source._eliminate_revisions_not_present(required_revisions)) if limit is not None: topo_ordered = self.get_graph().iter_topo_order(result_set) result_set = set(itertools.islice(topo_ordered, limit)) return self.source.revision_ids_to_search_result(result_set) InterRepository.register_optimiser(InterWeaveRepo) def get_extra_interrepo_test_combinations(): from bzrlib.repofmt import knitrepo return [(InterRepository, RepositoryFormat5(), knitrepo.RepositoryFormatKnit3())]
"""See InterRepository.search_missing_revision_ids().""" source_ids_set = self._present_source_revisions_for( revision_ids, if_present_ids) # source_ids is the worst possible case we may need to pull. # now we want to filter source_ids against what we actually # have in target, but don't try to check for existence where we know # we do not have a revision as that would be pointless. target_ids = set(self.target.all_revision_ids()) possibly_present_revisions = target_ids.intersection(source_ids_set) actually_present_revisions = set( self.target._eliminate_revisions_not_present(possibly_present_revisions)) required_revisions = source_ids_set.difference(actually_present_revisions) if revision_ids is not None: # we used get_ancestry to determine source_ids then we are assured all # revisions referenced are present as they are installed in topological order. # and the tip revision was validated by get_ancestry. result_set = required_revisions else: # if we just grabbed the possibly available ids, then # we only have an estimate of whats available and need to validate # that against the revision records. result_set = set( self.source._eliminate_revisions_not_present(required_revisions)) if limit is not None: topo_ordered = self.source.get_graph().iter_topo_order(result_set) result_set = set(itertools.islice(topo_ordered, limit)) return self.source.revision_ids_to_search_result(result_set) InterRepository.register_optimiser(InterKnitRepo)
actually_present_revisions = set( self.target._eliminate_revisions_not_present( possibly_present_revisions)) required_revisions = source_ids_set.difference( actually_present_revisions) if revision_ids is not None: # we used get_ancestry to determine source_ids then we are assured all # revisions referenced are present as they are installed in topological order. # and the tip revision was validated by get_ancestry. result_set = required_revisions else: # if we just grabbed the possibly available ids, then # we only have an estimate of whats available and need to validate # that against the revision records. result_set = set( self.source._eliminate_revisions_not_present( required_revisions)) if limit is not None: topo_ordered = self.get_graph().iter_topo_order(result_set) result_set = set(itertools.islice(topo_ordered, limit)) return self.source.revision_ids_to_search_result(result_set) InterRepository.register_optimiser(InterWeaveRepo) def get_extra_interrepo_test_combinations(): from bzrlib.repofmt import knitrepo return [(InterRepository, RepositoryFormat5(), knitrepo.RepositoryFormatKnit3())]