aboutsummaryrefslogtreecommitdiff
path: root/bpkg/system-repository.cxx
blob: 229ebd362d903f822e4e429592268825b83b9f03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// file      : bpkg/system-repository.cxx -*- C++ -*-
// license   : MIT; see accompanying LICENSE file

#include <bpkg/system-repository.hxx>

namespace bpkg
{
  const system_package_versions& system_repository::
  insert (const package_name& name,
          const system_package_versions& vs,
          bool authoritative)
  {
    assert (!vs.empty ());

    auto p (map_.emplace (name, system_package {vs, authoritative}));

    if (!p.second)
    {
      system_package& sp (p.first->second);

      // We should not override authoritative information.
      //
      assert (!(authoritative && sp.authoritative));

      if (authoritative >= sp.authoritative)
      {
        sp.authoritative = authoritative;
        sp.versions = vs;
      }
    }

    return p.first->second.versions;
  }
}