From d557610c6f57340c0f76750e56b45facac8ffe7e Mon Sep 17 00:00:00 2001 From: Niels Thykier Date: Wed, 31 Oct 2018 06:55:55 +0000 Subject: [PATCH] BinaryPackageUniverse: Implement packages_equivalent_to() Signed-off-by: Niels Thykier --- britney2/installability/builder.py | 6 ++++-- britney2/installability/tester.py | 3 +-- britney2/installability/universe.py | 7 ++++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/britney2/installability/builder.py b/britney2/installability/builder.py index 65ca548..9adf5e7 100644 --- a/britney2/installability/builder.py +++ b/britney2/installability/builder.py @@ -373,6 +373,7 @@ class InstallabilityTesterBuilder(object): eqv_table = {} relations = {} emptyset = frozenset() + intern_set = self._intern_set for pkg in reverse_package_table: rdeps = reverse_package_table[pkg][2] @@ -385,7 +386,8 @@ class InstallabilityTesterBuilder(object): find_eqv_table[ekey].append(pkg) for pkg_relations, pkg_list in find_eqv_table.items(): - rel = BinaryPackageRelation(pkg_relations[0], pkg_relations[1], reverse_package_table[pkg_list[0]][0]) + rdeps = reverse_package_table[pkg_list[0]][0] + rel = BinaryPackageRelation(intern_set(pkg_list), pkg_relations[0], pkg_relations[1], rdeps) if len(pkg_list) < 2: relations[pkg_list[0]] = rel continue @@ -398,7 +400,7 @@ class InstallabilityTesterBuilder(object): for pkg, forward_relations in package_table.items(): if pkg in relations: continue - rel = BinaryPackageRelation(forward_relations[0], forward_relations[1], emptyset) + rel = BinaryPackageRelation(intern_set((pkg,)), forward_relations[0], forward_relations[1], emptyset) relations[pkg] = rel return relations, eqv_table diff --git a/britney2/installability/tester.py b/britney2/installability/tester.py index b6a2bab..ddbcc70 100644 --- a/britney2/installability/tester.py +++ b/britney2/installability/tester.py @@ -106,8 +106,7 @@ class InstallabilityTester(object): the package dependency graph (i.e. relations can not tell them apart semantically except for their name). Otherwise False """ - eqv_table = self._eqv_table - return pkg_id1 in eqv_table and pkg_id2 in eqv_table[pkg_id1] + return self._universe.are_equivalent(pkg_id1, pkg_id2) def reverse_dependencies_of(self, pkg_id): """Returns the set of reverse dependencies of a given package diff --git a/britney2/installability/universe.py b/britney2/installability/universe.py index 09bf474..12d304b 100644 --- a/britney2/installability/universe.py +++ b/britney2/installability/universe.py @@ -16,9 +16,10 @@ class BinaryPackageRelation(object): """All relations of a given binary package""" - __slots__ = ['dependencies', 'negative_dependencies', 'reverse_dependencies'] + __slots__ = ['pkg_ids', 'dependencies', 'negative_dependencies', 'reverse_dependencies'] - def __init__(self, dependencies, negative_dependencies, reverse_dependencies): + def __init__(self, pkg_ids, dependencies, negative_dependencies, reverse_dependencies): + self.pkg_ids = pkg_ids self.dependencies = dependencies self.negative_dependencies = negative_dependencies self.reverse_dependencies = reverse_dependencies @@ -97,7 +98,7 @@ class BinaryPackageUniverse(object): input package. Note that this set always includes the input package assuming it is a known package. """ - return NotImplemented + return self._relations[pkg_id].pkg_ids def relations_of(self, pkg_id): """Get the direct relations of a given packge