From b28f172537ae14d0fd386de63f7b62bfa6612d3a Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 24 Oct 2023 20:21:22 +0300 Subject: Suppress constraints duplicates when merge build_package objects --- bpkg/pkg-build-collect.cxx | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/bpkg/pkg-build-collect.cxx b/bpkg/pkg-build-collect.cxx index a20aa65..918242c 100644 --- a/bpkg/pkg-build-collect.cxx +++ b/bpkg/pkg-build-collect.cxx @@ -311,13 +311,27 @@ namespace bpkg if (p.required_by_dependents == required_by_dependents) required_by.insert (p.required_by.begin (), p.required_by.end ()); - // Copy constraints. + // Copy constraints, suppressing duplicates. // - // Note that we may duplicate them, but this is harmless. - // - constraints.insert (constraints.end (), - make_move_iterator (p.constraints.begin ()), - make_move_iterator (p.constraints.end ())); + if (!constraints.empty ()) + { + for (constraint_type& c: p.constraints) + { + if (find_if (constraints.begin (), constraints.end (), + [&c] (const constraint_type& v) + { + return v.db.get () == c.db.get () && + v.dependent == c.dependent && + v.value == c.value; + + }) == constraints.end ()) + { + constraints.push_back (move (c)); + } + } + } + else + constraints = move (p.constraints); // Copy hold_* flags if they are "stronger". // -- cgit v1.1