# # # patch "annotate.cc" # from [dc5051843ce6406acbf2fadf151e9e9d52a36946] # to [f8bdcdefe26fbc19374b57c0cc971908ae56f88a] # # patch "automate.cc" # from [13931985b523348adcc5d79939d96d03a433bcbc] # to [497385b4a7d580444b7ad0755f629e0bb5316df6] # # patch "cert.cc" # from [1a96ec763ca93eb1030f15933253400605452b93] # to [d72920719f062aa2ba1e0a1694c4a1387cde1017] # # patch "cmd_diff_log.cc" # from [5db45374e646424aab11a5e822d204ad92eb3bca] # to [5a1f811289a1b1fc760623959877055bdc0c9e64] # # patch "cmd_list.cc" # from [b69a404855438771549c21fe10eba21d84141501] # to [80fe7cdf7a2816f956bc54e7b7cba6f023db1d84] # # patch "cmd_merging.cc" # from [3ef9847e6ff8415c6b5ad2a2f9c57310f8ae54d4] # to [65f25ddd571fda9bbab8938525cf817cc2a2b6ec] # # patch "cmd_ws_commit.cc" # from [cc19f101c180eca53c931d850ec31da23f6a5ad2] # to [dccf6cd4915b2d3d806c35124c82afcad4830d49] # # patch "commands.cc" # from [36bada37724baaddac588fc57fa399b73a96d331] # to [fa3aa8f033108be43ffb15c376b0f35484847b7e] # # patch "database.hh" # from [1d756ecc4f072ea6a163643d9ba1787a75675507] # to [2bf223083d3fb491d7cd28c3f68eaa43c1395f2e] # # patch "enumerator.cc" # from [9c5eea70933485bdf98e0775e548928dbe3fd764] # to [4d3be4e2bab1e951b2576b3a8111981800e6533e] # # patch "netsync.cc" # from [5c0cf0c90abf7f629193c65896ffae48182f9c24] # to [cec5aa9f9388baab0617a4497744ba9a8679039e] # # patch "project.cc" # from [604d146bc88be450386d755a1783533834d98361] # to [7f1dc2c76c92b3e2ced9fa2d70dc24e014404604] # # patch "project.hh" # from [0146006f7d817638f02fdf281f093e64dc5ff5aa] # to [d8d07d9efc0ae6e8ae723b3aab21370d85038d5c] # # patch "update.cc" # from [2fdc5718eb68ae58fb66378d1a8df34ed4dc42de] # to [75170a43066b7b681a8f134b0da79805d67d7c2c] # ============================================================ --- annotate.cc dc5051843ce6406acbf2fadf151e9e9d52a36946 +++ annotate.cc f8bdcdefe26fbc19374b57c0cc971908ae56f88a @@ -377,7 +377,7 @@ annotate_context::build_revisions_to_ann i != seen.end(); i++) { vector< revision > certs; - app.db.get_revision_certs(*i, certs); + app.project.get_revision_certs(*i, certs); erase_bogus_certs(certs, app); string author(cert_string_value(certs, author_cert_name, ============================================================ --- automate.cc 13931985b523348adcc5d79939d96d03a433bcbc +++ automate.cc 497385b4a7d580444b7ad0755f629e0bb5316df6 @@ -1111,7 +1111,7 @@ AUTOMATE(packets_for_certs, N_("REVID"), N(app.db.revision_exists(r_id), F("no such revision '%s'") % r_id); - app.db.get_revision_certs(r_id, certs); + app.project.get_revision_certs(r_id, certs); for (size_t i = 0; i < certs.size(); ++i) pw.consume_revision_cert(idx(certs,i)); } @@ -1318,46 +1318,39 @@ AUTOMATE(tags, N_("[BRANCH_PATTERN]"), o stz.push_str_pair(symbol("format_version"), "1"); prt.print_stanza(stz); - vector > tag_certs; - app.db.get_revision_certs(tag_cert_name, tag_certs); + set tags; + app.project.get_tags(tags); - for (vector >::const_iterator i = tag_certs.begin(); - i != tag_certs.end(); ++i) { - - cert tagcert(i->inner()); - vector > branch_certs; - app.db.get_revision_certs(tagcert.ident, branch_cert_name, branch_certs); + for (set::const_iterator tag = tags.begin(); + tag != tags.end(); ++tag) + { + set branches; + app.project.get_revision_branches(tag->ident, branches); - bool show(!filtering); - vector branch_names; + bool show(!filtering); + vector branch_names; - for (vector >::const_iterator j = branch_certs.begin(); - j != branch_certs.end(); ++j) { - - cert branchcert(j->inner()); - cert_value branch; - decode_base64(branchcert.value, branch); - string branch_name(branch()); + for (set::const_iterator branch = branches.begin(); + branch != branches.end(); ++branch) + { + if (app.lua.hook_ignore_branch((*branch)())) + continue; - if (app.lua.hook_ignore_branch(branch_name)) - continue; - - if (!show && match(branch_name)) - show = true; - branch_names.push_back(branch_name); - } + if (!show && match((*branch)())) + show = true; + branch_names.push_back((*branch)()); + } - if (show) { - basic_io::stanza stz; - cert_value tag; - decode_base64(tagcert.value, tag); - stz.push_str_pair(symbol("tag"), tag()); - stz.push_hex_pair(symbol("revision"), tagcert.ident); - stz.push_str_pair(symbol("signer"), tagcert.key()); - stz.push_str_multi(symbol("branches"), branch_names); - prt.print_stanza(stz); + if (show) + { + basic_io::stanza stz; + stz.push_str_pair(symbol("tag"), tag->name()); + stz.push_hex_pair(symbol("revision"), tag->ident.inner()); + stz.push_str_pair(symbol("signer"), tag->key()); + stz.push_str_multi(symbol("branches"), branch_names); + prt.print_stanza(stz); + } } - } output.write(prt.buf.data(), prt.buf.size()); } ============================================================ --- cert.cc 1a96ec763ca93eb1030f15933253400605452b93 +++ cert.cc d72920719f062aa2ba1e0a1694c4a1387cde1017 @@ -485,21 +485,21 @@ guess_branch(revision_id const & ident, F("no branch found for empty revision, " "please provide a branch name")); - vector< revision > certs; - cert_name branch(branch_cert_name); - app.db.get_revision_certs(ident, branch, certs); - erase_bogus_certs(certs, app); + set branches; + app.project.get_revision_branches(ident, branches); - N(certs.size() != 0, + N(branches.size() != 0, F("no branch certs found for revision %s, " "please provide a branch name") % ident); - N(certs.size() == 1, + N(branches.size() == 1, F("multiple branch certs found for revision %s, " "please provide a branch name") % ident); - decode_base64(certs[0].inner().value, branchname); - app.opts.branch_name = branchname(); + set::iterator i = branches.begin(); + I(i != branches.end()); + app.opts.branch_name = *i; + branchname = (*i)(); } } ============================================================ --- cmd_diff_log.cc 5db45374e646424aab11a5e822d204ad92eb3bca +++ cmd_diff_log.cc 5a1f811289a1b1fc760623959877055bdc0c9e64 @@ -541,8 +541,7 @@ log_certs(app_state & app, revision_id i if (multiline) newline = true; - app.db.get_revision_certs(id, name, certs); - erase_bogus_certs(certs, app); + app.project.get_revision_certs_by_name(id, name, certs); for (vector< revision >::const_iterator i = certs.begin(); i != certs.end(); ++i) { ============================================================ --- cmd_list.cc b69a404855438771549c21fe10eba21d84141501 +++ cmd_list.cc 80fe7cdf7a2816f956bc54e7b7cba6f023db1d84 @@ -51,7 +51,10 @@ ls_certs(string const & name, app_state revision_id ident; complete(app, idx(args, 0)(), ident); vector< revision > ts; - app.db.get_revision_certs(ident, ts); + // FIXME_PROJECTS: after projects are implemented, + // use the app.db version instead if no project is specified. + app.project.get_revision_certs(ident, ts); + for (size_t i = 0; i < ts.size(); ++i) certs.push_back(idx(ts, i).inner()); @@ -284,28 +287,15 @@ ls_tags(string name, app_state & app, ve static void ls_tags(string name, app_state & app, vector const & args) { - vector< revision > certs; - app.db.get_revision_certs(tag_cert_name, certs); + set tags; + app.project.get_tags(tags); - set< pair > > - sorted_vals; - - for (vector< revision >::const_iterator i = certs.begin(); - i != certs.end(); ++i) + for (set::const_iterator i = tags.begin(); i != tags.end(); ++i) { - cert_value name; - cert c = i->inner(); - decode_base64(c.value, name); - sorted_vals.insert(make_pair(name, make_pair(c.ident, c.key))); + cout << i->name << " " + << i->ident << " " + << i->key << "\n"; } - for (set > >::const_iterator i = sorted_vals.begin(); - i != sorted_vals.end(); ++i) - { - cout << i->first << " " - << i->second.first << " " - << i->second.second << "\n"; - } } static void @@ -687,7 +677,10 @@ AUTOMATE(certs, N_("REV"), options::opts hexenc ident(rid.inner()); vector< revision > ts; - app.db.get_revision_certs(rid, ts); + // FIXME_PROJECTS: after projects are implemented, + // use the app.db version instead if no project is specified. + app.project.get_revision_certs(rid, ts); + for (size_t i = 0; i < ts.size(); ++i) certs.push_back(idx(ts, i).inner()); ============================================================ --- cmd_merging.cc 3ef9847e6ff8415c6b5ad2a2f9c57310f8ae54d4 +++ cmd_merging.cc 65f25ddd571fda9bbab8938525cf817cc2a2b6ec @@ -149,18 +149,8 @@ CMD(update, N_("workspace"), "", bool switched_branch = false; { // figure out which branches the target is in - vector< revision > certs; - app.db.get_revision_certs(chosen_rid, branch_cert_name, certs); - erase_bogus_certs(certs, app); - set< utf8 > branches; - for (vector< revision >::const_iterator i = certs.begin(); - i != certs.end(); i++) - { - cert_value b; - decode_base64(i->inner().value, b); - branches.insert(utf8(b())); - } + app.project.get_revision_branches(chosen_rid, branches); if (branches.find(app.opts.branch_name) != branches.end()) { ============================================================ --- cmd_ws_commit.cc cc19f101c180eca53c931d850ec31da23f6a5ad2 +++ cmd_ws_commit.cc dccf6cd4915b2d3d806c35124c82afcad4830d49 @@ -526,19 +526,9 @@ CMD(checkout, N_("tree"), N_("[DIRECTORY guess_branch(ident, app, b); I(!app.opts.branch_name().empty()); - cert_value branch_name(app.opts.branch_name()); - base64 branch_encoded; - encode_base64(branch_name, branch_encoded); - vector< revision > certs; - app.db.get_revision_certs(ident, branch_cert_name, branch_encoded, certs); - - L(FL("found %d %s branch certs on revision %s") - % certs.size() - % app.opts.branch_name - % ident); - - N(certs.size() != 0, F("revision %s is not a member of branch %s") + N(app.project.revision_is_in_branch(ident, app.opts.branch_name), + F("revision %s is not a member of branch %s") % ident % app.opts.branch_name); } @@ -949,7 +939,7 @@ CMD(commit, N_("workspace"), N_("[PATH]. // later. map certs; vector< revision > ctmp; - app.db.get_revision_certs(restricted_rev_id, ctmp); + app.project.get_revision_certs(restricted_rev_id, ctmp); for (vector< revision >::const_iterator i = ctmp.begin(); i != ctmp.end(); ++i) { @@ -1014,19 +1004,9 @@ CMD_NO_WORKSPACE(import, N_("tree"), N_( guess_branch(ident, app, b); I(!app.opts.branch_name().empty()); - cert_value branch_name(app.opts.branch_name()); - base64 branch_encoded; - encode_base64(branch_name, branch_encoded); - vector< revision > certs; - app.db.get_revision_certs(ident, branch_cert_name, branch_encoded, certs); - - L(FL("found %d %s branch certs on revision %s") - % certs.size() - % app.opts.branch_name - % ident); - - N(certs.size() != 0, F("revision %s is not a member of branch %s") + N(app.project.revision_is_in_branch(ident, app.opts.branch_name), + F("revision %s is not a member of branch %s") % ident % app.opts.branch_name); } else ============================================================ --- commands.cc 36bada37724baaddac588fc57fa399b73a96d331 +++ commands.cc fa3aa8f033108be43ffb15c376b0f35484847b7e @@ -368,8 +368,7 @@ describe_revision(app_state & app, // append authors and date of this revision vector< revision > tmp; - app.db.get_revision_certs(id, author_name, tmp); - erase_bogus_certs(tmp, app); + app.project.get_revision_certs_by_name(id, author_name, tmp); for (vector< revision >::const_iterator i = tmp.begin(); i != tmp.end(); ++i) { @@ -378,8 +377,7 @@ describe_revision(app_state & app, description += " "; description += tv(); } - app.db.get_revision_certs(id, date_name, tmp); - erase_bogus_certs(tmp, app); + app.project.get_revision_certs_by_name(id, date_name, tmp); for (vector< revision >::const_iterator i = tmp.begin(); i != tmp.end(); ++i) { ============================================================ --- database.hh 1d756ecc4f072ea6a163643d9ba1787a75675507 +++ database.hh 2bf223083d3fb491d7cd28c3f68eaa43c1395f2e @@ -420,6 +420,7 @@ public: outdated_indicator get_revision_cert_nobranch_index(std::vector< std::pair, std::pair > > & idx); + // Only used by database_check.cc outdated_indicator get_revision_certs(std::vector< revision > & certs); outdated_indicator get_revision_certs(cert_name const & name, @@ -429,22 +430,28 @@ public: cert_name const & name, std::vector< revision > & certs); + // Only used by get_branch_certs (project.cc) outdated_indicator get_revision_certs(cert_name const & name, base64 const & val, std::vector< revision > & certs); + // Only used by revision_is_in_branch (project.cc) outdated_indicator get_revision_certs(revision_id const & ident, cert_name const & name, base64 const & value, std::vector< revision > & certs); + // Only used by get_branch_heads (project.cc) outdated_indicator get_revisions_with_cert(cert_name const & name, base64 const & value, std::set & revisions); + // Used through project.cc, and by + // anc_graph::add_node_for_oldstyle_revision (revision.cc) outdated_indicator get_revision_certs(revision_id const & ident, std::vector< revision > & certs); + // Used through get_revision_cert_hashes (project.cc) outdated_indicator get_revision_certs(revision_id const & ident, std::vector< hexenc > & hashes); ============================================================ --- enumerator.cc 9c5eea70933485bdf98e0775e548928dbe3fd764 +++ enumerator.cc 4d3be4e2bab1e951b2576b3a8111981800e6533e @@ -202,7 +202,7 @@ revision_enumerator::get_revision_certs( } if (!found_one) { - app.db.get_revision_certs(rid, hashes); + app.project.get_revision_cert_hashes(rid, hashes); } } ============================================================ --- netsync.cc 5c0cf0c90abf7f629193c65896ffae48182f9c24 +++ netsync.cc cec5aa9f9388baab0617a4497744ba9a8679039e @@ -3065,9 +3065,10 @@ session::rebuild_merkle_trees(app_state { // Get branch certs. vector< revision > certs; - base64 encoded_name; - encode_base64(cert_value((*i)()),encoded_name); - app.db.get_revision_certs(branch_cert_name, encoded_name, certs); + // FIXME_PROJECTS: probably something like + // app.get_project(i->project).get_branch_certs(i->branch) + // or so. + app.project.get_branch_certs(*i, certs); for (vector< revision >::const_iterator j = certs.begin(); j != certs.end(); j++) { ============================================================ --- project.cc 604d146bc88be450386d755a1783533834d98361 +++ project.cc 7f1dc2c76c92b3e2ced9fa2d70dc24e014404604 @@ -113,3 +113,118 @@ project_t::get_branch(utf8 const & name) res = known_branches.insert(std::make_pair(name, branch(app, name))); return res.first->second; } + +bool +project_t::revision_is_in_branch(revision_id const & id, + utf8 const & branch) +{ + base64 branch_encoded; + encode_base64(cert_value(branch()), branch_encoded); + + vector > certs; + app.db.get_revision_certs(id, branch_cert_name, branch_encoded, certs); + + int num = certs.size(); + + erase_bogus_certs(certs, app); + + L(FL("found %d (%d valid) %s branch certs on revision %s") + % num + % certs.size() + % branch + % id); + + return !certs.empty(); +} + +outdated_indicator +project_t::get_revision_cert_hashes(revision_id const & id, + std::vector > & hashes) +{ + return app.db.get_revision_certs(id, hashes); +} + +outdated_indicator +project_t::get_revision_certs(revision_id const & id, + std::vector > & certs) +{ + return app.db.get_revision_certs(id, certs); +} + +outdated_indicator +project_t::get_revision_certs_by_name(revision_id const & id, + cert_name const & name, + std::vector > & certs) +{ + outdated_indicator i = app.db.get_revision_certs(id, name, certs); + erase_bogus_certs(certs, app); + return i; +} + +outdated_indicator +project_t::get_revision_branches(revision_id const & id, + std::set & branches) +{ + std::vector > certs; + outdated_indicator i = get_revision_certs_by_name(id, branch_cert_name, certs); + branches.clear(); + for (std::vector >::const_iterator i = certs.begin(); + i != certs.end(); ++i) + { + cert_value b; + decode_base64(i->inner().value, b); + branches.insert(utf8(b())); + } + return i; +} + +outdated_indicator +project_t::get_branch_certs(utf8 const & branch, + std::vector > & certs) +{ + base64 branch_encoded; + encode_base64(cert_value(branch()), branch_encoded); + + return app.db.get_revision_certs(branch_cert_name, branch_encoded, certs); +} + +tag_t::tag_t(revision_id const & ident, + utf8 const & name, + rsa_keypair_id const & key) + : ident(ident), name(name), key(key) +{} + +bool +operator < (tag_t const & a, tag_t const & b) +{ + if (a.name < b.name) + return true; + else if (a.name == b.name) + { + if (a.ident < b.ident) + return true; + else if (a.ident == b.ident) + { + if (a.key < b.key) + return true; + } + } + return false; +} + +outdated_indicator +project_t::get_tags(set & tags) +{ + std::vector > certs; + outdated_indicator i = app.db.get_revision_certs(tag_cert_name, certs); + erase_bogus_certs(certs, app); + tags.clear(); + for (std::vector >::const_iterator i = certs.begin(); + i != certs.end(); ++i) + { + cert_value value; + decode_base64(i->inner().value, value); + tags.insert(tag_t(i->inner().ident, value(), i->inner().key)); + } + return i; +} ============================================================ --- project.hh 0146006f7d817638f02fdf281f093e64dc5ff5aa +++ project.hh d8d07d9efc0ae6e8ae723b3aab21370d85038d5c @@ -25,6 +25,16 @@ public: void heads(std::set & h); }; +class tag_t +{ +public: + revision_id ident; + utf8 name; + rsa_keypair_id key; + tag_t(revision_id const & ident, utf8 const & name, rsa_keypair_id const & key); +}; +bool operator < (tag_t const & a, tag_t const & b); + class project_t { app_state & app; @@ -38,6 +48,21 @@ public: void get_branch_list(std::set & names); void get_branch_list(utf8 const & glob, std::set & names); branch & get_branch(utf8 const & name); + + outdated_indicator get_tags(std::set & tags); + + bool revision_is_in_branch(revision_id const & id, utf8 const & branch); + outdated_indicator get_revision_cert_hashes(revision_id const & id, + std::vector > & hashes); + outdated_indicator get_revision_certs(revision_id const & id, + std::vector > & certs); + outdated_indicator get_revision_certs_by_name(revision_id const & id, + cert_name const & name, + std::vector > & certs); + outdated_indicator get_revision_branches(revision_id const & id, + std::set & branches); + outdated_indicator get_branch_certs(utf8 const & branch, + std::vector > & certs); }; #endif ============================================================ --- update.cc 2fdc5718eb68ae58fb66378d1a8df34ed4dc42de +++ update.cc 75170a43066b7b681a8f134b0da79805d67d7c2c @@ -55,8 +55,7 @@ get_test_results_for_revision(revision_i app_state & app) { vector< revision > certs; - app.db.get_revision_certs(id, testresult_cert_name, certs); - erase_bogus_certs(certs, app); + app.project.get_revision_certs_by_name(id, testresult_cert_name, certs); for (vector< revision >::const_iterator i = certs.begin(); i != certs.end(); ++i) { @@ -84,12 +83,7 @@ acceptable_descendent(cert_value const & L(FL("Considering update target %s") % target); // step 1: check the branch - base64 val; - encode_base64(branch, val); - vector< revision > certs; - app.db.get_revision_certs(target, branch_cert_name, val, certs); - erase_bogus_certs(certs, app); - if (certs.empty()) + if (!app.project.revision_is_in_branch(target, branch())) { L(FL("%s not in branch %s") % target % branch); return false;