aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bdep/sync.cli6
-rw-r--r--bdep/sync.cxx49
2 files changed, 35 insertions, 20 deletions
diff --git a/bdep/sync.cli b/bdep/sync.cli
index 503b930..8f806b6 100644
--- a/bdep/sync.cli
+++ b/bdep/sync.cli
@@ -51,7 +51,9 @@ namespace bdep
upgrades or patches immediate (by default or if
\c{\b{--immediate}|\b{-i}} is specified) or all (if
\c{\b{--recursive}|\b{-r}} is specified) dependencies of the specified
- project packages.
+ project packages. If no project packages are specified explicitly, then
+ this form upgrades or patches dependencies of all the initialized
+ packages in a project.
The third form (one or more <dep-spec> arguments are specified), in
addition to the first form's functionality, also upgrades (by default or
@@ -127,7 +129,7 @@ namespace bdep
Upgrade \cb{libx} and its immediate dependencies to the latest version:
\
- prj/$ bdep sync -i libx
+ prj/$ bdep sync -u -i libx
\
Upgrade \cb{libx} to the latest patch version:
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 ("}+");
+ }
}
}