From bc1d3afa382beea209019c3e015fcc8e089e519a Mon Sep 17 00:00:00 2001 From: Niels Thykier <niels@thykier.net> Date: Sun, 12 Aug 2018 12:33:09 +0000 Subject: [PATCH] inst-builder: Make add_breaks a bulk call Signed-off-by: Niels Thykier <niels@thykier.net> --- britney2/installability/builder.py | 35 +++++++++++++++--------------- tests/__init__.py | 3 +-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/britney2/installability/builder.py b/britney2/installability/builder.py index 9c57e2e..17d0dde 100644 --- a/britney2/installability/builder.py +++ b/britney2/installability/builder.py @@ -53,14 +53,15 @@ def build_installability_tester(suite_info, archs): # Breaks/Conflicts are so simple that we do not need to keep align the relation # with the suite. This enables us to do a few optimizations. if conflicts: + rels = [] for dep_suite in suite_info: dep_binaries_s_a, dep_provides_s_a = dep_suite.binaries[arch] for block in (relation for relation in conflicts): # if a package satisfies its own conflicts relation, then it is using ยง7.6.2 - rels = (s.pkg_id for s in solvers(block, dep_binaries_s_a, dep_provides_s_a) + rels.extend(s.pkg_id for s in solvers(block, dep_binaries_s_a, dep_provides_s_a) if s.pkg_id != pkg_id) - for r in rels: - relations.add_breaks(r) + if rels: + relations.add_breaks(rels) for block in depends: sat = set() @@ -144,24 +145,24 @@ class _RelationBuilder(object): if not okay: itbuilder._broken.add(binary) + def add_breaks(self, breaks_relations): + """Add a Breaks/Conflict-clauses - def add_breaks(self, broken_binary): - """Add a Breaks-clause + Marks the given binary as being broken by any of the packages. + That is, the given package satisfies a relation + in either the "Breaks" or the "Conflicts" field for any of the + listed packages. - Marks the given binary as being broken by the current - package. That is, the given package satisfies a relation - in either the "Breaks" or the "Conflicts" field. The binary - given must be a (name, version, architecture)-tuple. - - The binary is not required to have been added to the - InstallabilityTesterBuilder when this method is called. However, - it must be added before the "build()" method is called. + :param breaks_relations: An list/set of BinaryPackageIDs that has a Breaks/Conflicts relation + on the current package + :return: None """ itbuilder = self._itbuilder - self._new_breaks.add(broken_binary) - reverse_relations = itbuilder._reverse_relations(broken_binary) - reverse_relations[1].add(self._binary) - + self._new_breaks.update(breaks_relations) + this_package = self._binary + for broken_binary in breaks_relations: + reverse_relations = itbuilder._reverse_relations(broken_binary) + reverse_relations[1].add(this_package) def _commit(self): itbuilder = self._itbuilder diff --git a/tests/__init__.py b/tests/__init__.py index d5bc809..fa30720 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -134,8 +134,7 @@ class UniverseBuilder(object): with builder.relation_builder(pkg_id) as rel: for or_clause in pkg_builder._dependencies: rel.add_dependency_clause(or_clause) - for break_pkg_id in pkg_builder._conflicts: - rel.add_breaks(break_pkg_id) + rel.add_breaks(pkg_builder._conflicts) return builder.build() def pkg_id(self, pkgish):