aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-03-14 14:58:54 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-03-14 14:58:54 +0200
commitb44b4088f48a27bff88f8f010b8cd42303cbdad0 (patch)
tree46c08c1f48a81c3a4dc4c6c59be300e5e40e6762
parent7acf8ce6111e3740decd39b92c3383fcbdd00e21 (diff)
Implement --fetch|-f and --fetch-full|-F in sync command
-rw-r--r--bdep/fetch.cxx23
-rw-r--r--bdep/fetch.hxx6
-rw-r--r--bdep/init.cli8
-rw-r--r--bdep/sync.cli12
-rw-r--r--bdep/sync.cxx37
-rw-r--r--bdep/sync.hxx6
6 files changed, 72 insertions, 20 deletions
diff --git a/bdep/fetch.cxx b/bdep/fetch.cxx
index 6231d8b..26a0292 100644
--- a/bdep/fetch.cxx
+++ b/bdep/fetch.cxx
@@ -11,6 +11,21 @@ using namespace std;
namespace bdep
{
+ void
+ cmd_fetch (const common_options& o,
+ const dir_path& prj,
+ const shared_ptr<configuration>& c,
+ bool full)
+ {
+ // Let's use the repository name rather than the location as a sanity
+ // check (the repository must have been added as part of init).
+ //
+ run_bpkg (o,
+ "fetch",
+ "-d", c->path,
+ (full ? nullptr : ("dir:" + prj.string ()).c_str ()));
+ }
+
int
cmd_fetch (const cmd_fetch_options& o, cli::scanner&)
{
@@ -45,13 +60,7 @@ namespace bdep
first = false;
}
- // Let's use the repository name rather than the location as a sanity
- // check (the repository must have been added as part of init).
- //
- run_bpkg (o,
- "fetch",
- "-d", c->path,
- (o.full () ? nullptr : ("dir:" + prj.string ()).c_str ()));
+ cmd_fetch (o, prj, c, o.full ());
}
return 0;
diff --git a/bdep/fetch.hxx b/bdep/fetch.hxx
index 0f036cd..fea40fc 100644
--- a/bdep/fetch.hxx
+++ b/bdep/fetch.hxx
@@ -13,6 +13,12 @@
namespace bdep
{
+ void
+ cmd_fetch (const common_options&,
+ const dir_path& prj,
+ const shared_ptr<configuration>&,
+ bool full);
+
int
cmd_fetch (const cmd_fetch_options&, cli::scanner& args);
}
diff --git a/bdep/init.cli b/bdep/init.cli
index d853010..617a5cc 100644
--- a/bdep/init.cli
+++ b/bdep/init.cli
@@ -50,10 +50,10 @@ namespace bdep
directories using the \cb{--config|-c} option.
The second and third variants are semantically equivalent to first
- performing \cb{config add} and \cb{config create} (\l{bdep-config(1)}),
- respectively, followed by the first variant. In both cases the
- \cb{--default|-d} option can be used to make the added/created
- configuration default.
+ performing the \cb{config add} and \cb{config create} commands
+ (\l{bdep-config(1)}), respectively, followed by the first variant. In
+ both cases the \cb{--default|-d} option can be used to make the
+ added/created configuration default.
"
}
diff --git a/bdep/sync.cli b/bdep/sync.cli
index bd19edf..9d2f4ca 100644
--- a/bdep/sync.cli
+++ b/bdep/sync.cli
@@ -34,6 +34,16 @@ namespace bdep
//
class cmd_sync_options: project_options
{
- //"\h|SYNC OPTIONS|"
+ "\h|SYNC OPTIONS|"
+
+ bool --fetch|-f
+ {
+ "Perform the \cb{fetch} command prior to synchronization."
+ }
+
+ bool --fetch-full|-F
+ {
+ "Perform the \cb{fetch --full} command prior to synchronization."
+ }
};
}
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index 257cd20..dff6489 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -7,6 +7,8 @@
#include <bdep/database.hxx>
#include <bdep/diagnostics.hxx>
+#include <bdep/fetch.hxx>
+
using namespace std;
namespace bdep
@@ -14,7 +16,8 @@ namespace bdep
void
cmd_sync (const common_options& co,
const dir_path& prj,
- const shared_ptr<configuration>& c)
+ const shared_ptr<configuration>& c,
+ bool fetch)
{
assert (!c->packages.empty ());
@@ -30,11 +33,12 @@ namespace bdep
// We also use the repository name rather than then location as a sanity
// check (the repository must have been added as part of init).
//
- run_bpkg (co,
- "fetch",
- "-d", c->path,
- "--shallow",
- "dir:" + prj.string ());
+ if (fetch)
+ run_bpkg (co,
+ "fetch",
+ "-d", c->path,
+ "--shallow",
+ "dir:" + prj.string ());
// Prepare the pkg-spec.
//
@@ -105,6 +109,7 @@ namespace bdep
// Synchronize each configuration skipping empty ones.
//
+ bool first (true);
for (const shared_ptr<configuration>& c: cfgs)
{
if (c->packages.empty ())
@@ -115,7 +120,25 @@ namespace bdep
continue;
}
- cmd_sync (o, prj, c);
+ // If we are synchronizing multiple configurations, separate them with a
+ // blank line and print the configuration name/directory.
+ //
+ if (verb && cfgs.size () > 1)
+ {
+ text << (first ? "" : "\n")
+ << "synchronizing with configuration " << *c;
+
+ first = false;
+ }
+
+ bool fetch (o.fetch () || o.fetch_full ());
+
+ if (fetch)
+ cmd_fetch (o, prj, c, o.fetch_full ());
+
+ // Don't re-fetch if we just fetched.
+ //
+ cmd_sync (o, prj, c, !fetch);
}
return 0;
diff --git a/bdep/sync.hxx b/bdep/sync.hxx
index e1fa7fb..741e519 100644
--- a/bdep/sync.hxx
+++ b/bdep/sync.hxx
@@ -13,10 +13,14 @@
namespace bdep
{
+ // If fetch is false, don't perform a (shallow) fetch of the project
+ // repository.
+ //
void
cmd_sync (const common_options&,
const dir_path& prj,
- const shared_ptr<configuration>&);
+ const shared_ptr<configuration>&,
+ bool fetch = true);
int
cmd_sync (const cmd_sync_options&, cli::scanner& args);