diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-03-10 11:58:44 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-03-11 11:02:25 +0300 |
commit | 60fe5f8f374d9c680d0458394ac795830eb7e342 (patch) | |
tree | f9f6b4d8d6e43e07e7cc4f1ee8e87ef1ed5b05d8 /bdep/sync.cxx | |
parent | 9bcf92ef422999dca6c7fe00125c48065cbab977 (diff) |
Change bdep-sync form 2 to upgrade all initialized package dependencies if not specified explicitly
Diffstat (limited to 'bdep/sync.cxx')
-rw-r--r-- | bdep/sync.cxx | 49 |
1 files changed, 31 insertions, 18 deletions
diff --git a/bdep/sync.cxx b/bdep/sync.cxx index 471e190..2778010 100644 --- a/bdep/sync.cxx +++ b/bdep/sync.cxx @@ -262,26 +262,39 @@ namespace bdep { if (upgrade && !prj.implicit) { - // We synchronize all the init'ed packages but only upgrade the - // specified. + // We synchronize all the init'ed packages, including those from + // other projects. But if the dependencies are not specified, we + // only upgrade dependencies of the packages specified explicitly or + // init'ed in the origin project. // - if (find_if (prj_pkgs.begin (), - prj_pkgs.end (), - [&pkg] (const package_location& pl) - { - return pl.name == pkg.name; - }) != prj_pkgs.end ()) + if (dep_pkgs.empty ()) { - // The project package itself must always be upgraded to the - // latest version/iteration. So we have to translate to - // dependency-only --{upgrade,patch}-{recursive,immediate}. - // - args.push_back ("{"); - args.push_back ( - *upgrade - ? *recursive ? "--upgrade-recursive" : "--upgrade-immediate" - : *recursive ? "--patch-recursive" : "--patch-immediate"); - args.push_back ("}+"); + auto contains = [] (const auto& pkgs, const package_state& pkg) + { + return find_if (pkgs.begin (), pkgs.end (), + [&pkg] (const auto& p) + { + return p.name == pkg.name; + }) != pkgs.end (); + }; + + if (prj_pkgs.empty () && origin_config != nullptr + ? contains (origin_config->packages, pkg) + : contains (prj_pkgs, pkg)) + { + // The project package itself must always be upgraded to the + // latest version/iteration. So we have to translate to + // dependency-only --{upgrade,patch}-{recursive,immediate}. + // + assert (recursive); + + args.push_back ("{"); + args.push_back ( + *upgrade + ? *recursive ? "--upgrade-recursive" : "--upgrade-immediate" + : *recursive ? "--patch-recursive" : "--patch-immediate"); + args.push_back ("}+"); + } } } |