diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2023-10-24 20:21:22 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2023-11-02 14:04:09 +0300 |
commit | b28f172537ae14d0fd386de63f7b62bfa6612d3a (patch) | |
tree | 211c508b7544c0953802570e694816c79ccb7b93 | |
parent | f3279451bfa0152490df8d38a149b482dff6f810 (diff) |
Suppress constraints duplicates when merge build_package objects
-rw-r--r-- | bpkg/pkg-build-collect.cxx | 26 |
1 files 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". // |