aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-08-18 15:00:57 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-08-18 18:19:11 +0300
commitba8e0b9f9866b47bc61b49323e4293ba90826e80 (patch)
tree9a5f12da8767291124b139ad4ecccf328f56b446
parentfeb93edb4820feceb602b1e081f782e2e0bc45bc (diff)
Add support for config-unlink sub-command
-rw-r--r--bdep/config.cli16
-rw-r--r--bdep/config.cxx47
-rw-r--r--tests/config.testscript16
3 files changed, 73 insertions, 6 deletions
diff --git a/bdep/config.cli b/bdep/config.cli
index a1cdba2..17a8f41 100644
--- a/bdep/config.cli
+++ b/bdep/config.cli
@@ -20,6 +20,7 @@ namespace bdep
\c{\b{bdep config add} \ \ \ [<options>] [<prj-spec>] [\b{@}<cfg-name>] <cfg-dir>\n
\b{bdep config create} [<options>] [<prj-spec>] [\b{@}<cfg-name>] <cfg-dir> [<cfg-args>]\n
\b{bdep config link} \ \ [<options>] [<prj-spec>] <cfg-spec> <cfg-spec>\n
+ \b{bdep config unlink} [<options>] [<prj-spec>] <cfg-spec> <cfg-spec>\n
\b{bdep config list} \ \ [<options>] [<prj-spec>] [<cfg-spec>...]\n
\b{bdep config move} \ \ [<options>] [<prj-spec>] <cfg-spec> <cfg-dir>\n
\b{bdep config rename} [<options>] [<prj-spec>] <cfg-spec> <cfg-name>\n
@@ -113,9 +114,17 @@ namespace bdep
\li|\cb{link}
- The \cb{link} subcommand links one build configuration with another
- by executing the \l{bpkg-cfg-link(1)} command. See
- \l{bpkg-cfg-create(1)} for background on linked configurations.|
+ The \cb{link} subcommand links the first specified build
+ configuration with the second by executing the \l{bpkg-cfg-link(1)}
+ command. See \l{bpkg-cfg-create(1)} for background on linked
+ configurations.|
+
+ \li|\cb{unlink}
+
+ The \cb{unlink} subcommand unlinks the first specified build
+ configuration from the second by executing the \l{bpkg-cfg-unlink(1)}
+ command. See \l{bpkg-cfg-create(1)} for background on linked
+ configurations.|
\li|\cb{list}
@@ -165,6 +174,7 @@ namespace bdep
bool add;
bool create;
bool link;
+ bool unlink;
bool list;
bool move;
bool rename;
diff --git a/bdep/config.cxx b/bdep/config.cxx
index d62ad3e..d705355 100644
--- a/bdep/config.cxx
+++ b/bdep/config.cxx
@@ -320,9 +320,10 @@ namespace bdep
for (string l; !eof (getline (is, l)); )
{
if (l.empty ())
+ {
add_conf ();
-
- if (l.compare (0, 6, "path: ") == 0)
+ }
+ else if (l.compare (0, 6, "path: ") == 0)
{
try
{
@@ -709,6 +710,47 @@ namespace bdep
}
static int
+ cmd_config_unlink (const cmd_config_options& o, cli::scanner&)
+ {
+ tracer trace ("config_unlink");
+
+ // Load project configurations.
+ //
+ configurations cfgs;
+ {
+ dir_path prj (find_project (o));
+ database db (open (prj, trace));
+
+ transaction t (db.begin ());
+
+ cfgs = find_configurations (o,
+ prj,
+ t,
+ false /* fallback_default */,
+ true /* validate */).first;
+
+ t.commit ();
+ }
+
+ if (cfgs.size () != 2)
+ fail << "two configurations must be specified for config unlink";
+
+ // Call bpkg to unlink the configuration.
+ //
+ run_bpkg (2,
+ o,
+ "cfg-unlink",
+ "-d", cfgs[0]->path,
+ cfgs[1]->path);
+
+ if (verb)
+ text << "unlinked configuration " << *cfgs[0] << " from configuration "
+ << *cfgs[1];
+
+ return 0;
+ }
+
+ static int
cmd_config_list (const cmd_config_options& o, cli::scanner&)
{
tracer trace ("config_list");
@@ -1123,6 +1165,7 @@ namespace bdep
if (c.add ()) return cmd_config_add (o, scan);
if (c.create ()) return cmd_config_create (o, scan);
if (c.link ()) return cmd_config_link (o, scan);
+ if (c.unlink ()) return cmd_config_unlink (o, scan);
if (c.list ()) return cmd_config_list (o, scan);
if (c.move ()) return cmd_config_move (o, scan);
if (c.rename ()) return cmd_config_rename (o, scan);
diff --git a/tests/config.testscript b/tests/config.testscript
index b052a7b..f57e936 100644
--- a/tests/config.testscript
+++ b/tests/config.testscript
@@ -391,7 +391,21 @@ deinit += -d prj
$* create -- @cfg1 $config_cxx 2>! &prj-cfg1/***;
$* create -- @cfg2 $config_cxx 2>! &prj-cfg2/***;
- $* link @cfg1 @cfg2 2>>EOE
+ $* link @cfg1 @cfg2 2>>EOE;
linked configuration @cfg1 (target) with configuration @cfg2 (target)
EOE
+
+ $* link @cfg1 @cfg2 2>>/~%EOE% != 0;
+ %error: configuration with uuid .{36} is already linked as \.\./prj-cfg2/%
+ EOE
+
+ # While at it test the config-unlink subcommand.
+ #
+ $* unlink @cfg1 @cfg2 2>>EOE;
+ unlinked configuration @cfg1 from configuration @cfg2
+ EOE
+
+ $* unlink @cfg1 @cfg2 2>>/"EOE" != 0
+ error: no configuration with path $~/prj-cfg2/ is linked with $~/prj-cfg1/
+ EOE
}