From 22165c649ca2c5ef216ae3f99fbfb2dc0fff99ab Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Mon, 30 Aug 2021 23:24:52 +0300 Subject: Make pkg-build to accept multiple current configurations --- bpkg/database.cxx | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'bpkg/database.cxx') diff --git a/bpkg/database.cxx b/bpkg/database.cxx index 863ada4..ab2bcfc 100644 --- a/bpkg/database.cxx +++ b/bpkg/database.cxx @@ -223,7 +223,8 @@ namespace bpkg odb::tracer& tr, bool pre_attach, bool sys_rep, - const dir_paths& pre_link) + const dir_paths& pre_link, + std::string str_repr) : sqlite::database ( cfg_path (d, create != nullptr).string (), SQLITE_OPEN_READWRITE | (create != nullptr ? SQLITE_OPEN_CREATE : 0), @@ -232,7 +233,8 @@ namespace bpkg unique_ptr ( new sqlite::serial_connection_factory)), // Single connection. config (normalize (d, "configuration")), - config_orig (d) + config_orig (d), + string (move (str_repr)) { bpkg::tracer trace ("database"); @@ -382,6 +384,9 @@ namespace bpkg else config_orig = config; + + string = '[' + config_orig.representation () + ']'; + try { tracer_guard tg (*this, trace); @@ -428,6 +433,7 @@ namespace bpkg type (move (db.type)), config (move (db.config)), config_orig (move (db.config_orig)), + string (move (db.string)), system_repository (move (db.system_repository)), impl_ (db.impl_), explicit_links_ (move (db.explicit_links_)), @@ -996,15 +1002,24 @@ namespace bpkg return r->db; } - database& database:: - find_dependency_config (const uuid_type& uid) + database* database:: + try_find_dependency_config (const uuid_type& uid) { for (database& ldb: dependency_configs ()) { if (uid == ldb.uuid) - return ldb; + return &ldb; } + return nullptr; + } + + database& database:: + find_dependency_config (const uuid_type& uid) + { + if (database* db = try_find_dependency_config (uid)) + return *db; + fail << "no configuration with uuid " << uid << " is linked with " << config_orig << endf; } @@ -1050,10 +1065,4 @@ namespace bpkg { return *this == main_database (); } - - string database:: - string () - { - return main () ? empty_string : '[' + config_orig.representation () + ']'; - } } -- cgit v1.1