From 50a523f0ec503e7a32ec3732dc4b6f5c05170122 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 22 May 2018 06:24:04 +0200 Subject: Add --force option to deinit command --- bdep/deinit.cxx | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'bdep/deinit.cxx') diff --git a/bdep/deinit.cxx b/bdep/deinit.cxx index 2264d79..87f478f 100644 --- a/bdep/deinit.cxx +++ b/bdep/deinit.cxx @@ -21,6 +21,7 @@ namespace bdep const shared_ptr& c, const strings& pkgs) { + bool force (o.force ()); const dir_path& cfg (c->path); // Remove auto-synchronization build system hook. @@ -32,7 +33,8 @@ namespace bdep // have been removed from the configuration's repositories if that were // the case). // - if (c->auto_sync && + if (!force && + c->auto_sync && c->packages.empty () && configuration_projects (o, cfg, prj).empty ()) { @@ -41,7 +43,8 @@ namespace bdep rm (f); } - // Disfigure configuration forwarding. + // Disfigure configuration forwarding. Note that we have to do this even + // if forced. // if (c->forward) { @@ -76,14 +79,15 @@ namespace bdep // that are managed by bdep, then its view of what has been initialized // in the configuration will become invalid. // - run_bpkg (2, - o, - "drop", - "-d", cfg, - "--keep-dependent", - "--plan", "synchronizing:", - "--yes", - pkgs); + if (!force) + run_bpkg (2, + o, + "drop", + "-d", cfg, + "--keep-dependent", + "--plan", "synchronizing:", + "--yes", + pkgs); } int @@ -91,6 +95,8 @@ namespace bdep { tracer trace ("deinit"); + bool force (o.force ()); + // The same ignore/load story as in sync. // project_packages pp ( @@ -106,7 +112,12 @@ namespace bdep database db (open (prj, trace)); transaction t (db.begin ()); - configurations cfgs (find_configurations (o, prj, t)); + configurations cfgs ( + find_configurations (o, + prj, + t, + true /* fallback_default */, + !force /* validate */)); t.commit (); // If specified, verify packages are present in each configuration. @@ -197,7 +208,7 @@ namespace bdep // Remove our repository from the configuration if we have no more // packages that are initialized in it. // - if (c->packages.empty ()) + if (!force && c->packages.empty ()) run_bpkg (3, o, "remove", -- cgit v1.1