diff options
-rw-r--r-- | bdep/config.cli | 16 | ||||
-rw-r--r-- | bdep/config.cxx | 47 | ||||
-rw-r--r-- | tests/config.testscript | 16 |
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 } |