# # # patch "README.encapsulation" # from [3a8cbeb019e89f294ee5482970d33d42c319f97a] # to [55e2d2ddaefb7fe1c4b081ac2d50f8b2692e057b] # # patch "automate.cc" # from [0a3fc4c33d34dd6d2aa20f91283f79aac63929e6] # to [0a6a4f9410e74cf608a272948dc110b56a903d5e] # # patch "cert.cc" # from [a71052b8dd018498af561c20de7395d487ec97b0] # to [200f1c04f4b359ae1640ea2e1c66b666319de40b] # # patch "cert.hh" # from [e701aae7d97a2002010ca4b2ae34d71afc44e61f] # to [5e4120f4f615b11a298cea86dfee0e27c4a32b67] # # patch "cmd_key_cert.cc" # from [f86c02cb2c35fc5fcf0f230ce4401d2dbae80023] # to [543558de324168a743c957aba995dac76b185b13] # # patch "database.cc" # from [ae8f5f845996bd646d50045a974be43f9921ab20] # to [3763d91cc1b85dab06c0cb78cbcf695eb911a3fd] # # patch "database.hh" # from [c6c66cb8a819321627732b423f940f8a450cf8a5] # to [64e707abbe0f62b28b543e7d8a02bd75df04abab] # # patch "project.cc" # from [df1cb9edf0298e706d27a3416e872eba07f8994b] # to [98b70fd8d652825717df5f2ce37c427f0a2c6a2f] # # patch "revision.cc" # from [7ad90a9e362470d057f995bb361a0d80fab75870] # to [c558597ffa870a502669d0620dae8f6f1567b1b9] # ============================================================ --- README.encapsulation 3a8cbeb019e89f294ee5482970d33d42c319f97a +++ README.encapsulation 55e2d2ddaefb7fe1c4b081ac2d50f8b2692e057b @@ -12,9 +12,6 @@ revision.cc: struct anc_graph still uses app_state, while most methods only need the database, these functions are exceptions: - anc_graph::write_certs(): - needs: make_simple_cert() - anc_graph::construct_revisions_from_ancestry() app.opts.attrs_to_drop @@ -35,15 +32,7 @@ cert.cc: app.opts.branch_given + app.opts.branchname app.get_project().get_revision_branches() - make_simple_cert(): - needs: calculate_cert() - cert_revision_author_default(): - needs (thought other calls): make_simple_cert() - app.lua.hook_get_author - app.opts.branchname - - database.cc: __app is a member variable of class database, it's needed for the @@ -149,8 +138,6 @@ project.cc: project_t: app.db... - needs: cert_revision_{in_branch,tag,changelog,date_time,author}() - which in turn all need make_simple_cert() app.opts.date app.opts.author @@ -176,3 +163,8 @@ cmd_diff_log.cc: needs: complete() + + +next candidates for app_state removal: + project.cc: struct project_t + revision.cc: struct anc_graph ============================================================ --- automate.cc 0a3fc4c33d34dd6d2aa20f91283f79aac63929e6 +++ automate.cc 0a6a4f9410e74cf608a272948dc110b56a903d5e @@ -1734,7 +1734,7 @@ AUTOMATE(cert, N_("REVISION-ID NAME VALU N(app.db.revision_exists(rid), F("no such revision '%s'") % rid); make_simple_cert(rid.inner(), cert_name(idx(args, 1)()), - cert_value(idx(args, 2)()), app, c); + cert_value(idx(args, 2)()), app.db, c); revision rc(c); app.db.put_revision_cert(rc); guard.commit(); ============================================================ --- cert.cc a71052b8dd018498af561c20de7395d487ec97b0 +++ cert.cc 200f1c04f4b359ae1640ea2e1c66b666319de40b @@ -394,16 +394,16 @@ void } void -calculate_cert(app_state & app, cert & t) +calculate_cert(database & db, cert & t) { string signed_text; keypair kp; cert_signable_text(t, signed_text); - load_key_pair(app.keys, t.key, kp); - app.db.put_key(t.key, kp.pub); + load_key_pair(db.get_key_store(), t.key, kp); + db.put_key(t.key, kp.pub); - make_signature(app.keys, t.key, kp.priv, signed_text, t.sig); + make_signature(db.get_key_store(), t.key, kp.priv, signed_text, t.sig); } cert_status @@ -507,15 +507,15 @@ make_simple_cert(hexenc const & id, make_simple_cert(hexenc const & id, cert_name const & nm, cert_value const & cv, - app_state & app, + database & db, cert & c) { rsa_keypair_id key; - get_user_key(key, app.keys); + get_user_key(key, db.get_key_store()); base64 encoded_val; encode_base64(cv, encoded_val); cert t(id, nm, encoded_val, key); - calculate_cert(app, t); + calculate_cert(db, t); c = t; } @@ -523,21 +523,20 @@ put_simple_revision_cert(revision_id con put_simple_revision_cert(revision_id const & id, cert_name const & nm, cert_value const & val, - app_state & app) + database & db) { cert t; - make_simple_cert(id.inner(), nm, val, app, t); + make_simple_cert(id.inner(), nm, val, db, t); revision cc(t); - app.db.put_revision_cert(cc); + db.put_revision_cert(cc); } void cert_revision_in_branch(revision_id const & rev, branch_name const & branch, - app_state & app) + database & db) { - put_simple_revision_cert (rev, branch_cert_name, cert_value(branch()), - app); + put_simple_revision_cert(rev, branch_cert_name, cert_value(branch()), db); } @@ -546,64 +545,64 @@ cert_revision_date_time(revision_id cons void cert_revision_date_time(revision_id const & m, date_t const & t, - app_state & app) + database & db) { cert_value val = cert_value(t.as_iso_8601_extended()); - put_simple_revision_cert(m, date_cert_name, val, app); + put_simple_revision_cert(m, date_cert_name, val, db); } void cert_revision_author(revision_id const & m, string const & author, - app_state & app) + database & db) { - put_simple_revision_cert(m, author_cert_name, cert_value(author), app); + put_simple_revision_cert(m, author_cert_name, cert_value(author), db); } void cert_revision_author_default(revision_id const & m, - app_state & app) + database & db) { string author; rsa_keypair_id key; - get_user_key(key, app.keys); + get_user_key(key, db.get_key_store()); - if (!app.lua.hook_get_author(app.opts.branchname, key, author)) + if (!db.hook_get_author(key, author)) { author = key(); } - cert_revision_author(m, author, app); + cert_revision_author(m, author, db); } void cert_revision_tag(revision_id const & m, string const & tagname, - app_state & app) + database & db) { - put_simple_revision_cert(m, tag_cert_name, cert_value(tagname), app); + put_simple_revision_cert(m, tag_cert_name, cert_value(tagname), db); } void cert_revision_changelog(revision_id const & m, utf8 const & log, - app_state & app) + database & db) { - put_simple_revision_cert(m, changelog_cert_name, cert_value(log()), app); + put_simple_revision_cert(m, changelog_cert_name, cert_value(log()), db); } void cert_revision_comment(revision_id const & m, utf8 const & comment, - app_state & app) + database & db) { - put_simple_revision_cert(m, comment_cert_name, cert_value(comment()), app); + put_simple_revision_cert(m, comment_cert_name, cert_value(comment()), db); } void cert_revision_testresult(revision_id const & r, string const & results, - app_state & app) + database & db) { bool passed = false; if (lowercase(results) == "true" || @@ -622,7 +621,7 @@ cert_revision_testresult(revision_id con "'pass/fail'"); put_simple_revision_cert(r, testresult_cert_name, - cert_value(lexical_cast(passed)), app); + cert_value(lexical_cast(passed)), db); } // Local Variables: ============================================================ --- cert.hh e701aae7d97a2002010ca4b2ae34d71afc44e61f +++ cert.hh 5e4120f4f615b11a298cea86dfee0e27c4a32b67 @@ -75,13 +75,13 @@ void make_simple_cert(hexenc const & void make_simple_cert(hexenc const & id, cert_name const & nm, cert_value const & cv, - app_state & app, + database & db, cert & c); void put_simple_revision_cert(revision_id const & id, cert_name const & nm, cert_value const & val, - app_state & app); + database & db); void erase_bogus_certs(std::vector< revision > & certs, database & db); @@ -96,7 +96,7 @@ cert_revision_in_branch(revision_id cons void cert_revision_in_branch(revision_id const & ctx, branch_name const & branchname, - app_state & app); + database & db); // We also define some common cert types, to help establish useful @@ -122,36 +122,36 @@ cert_revision_date_time(revision_id cons void cert_revision_date_time(revision_id const & m, date_t const & t, - app_state & app); + database & db); void cert_revision_author(revision_id const & m, std::string const & author, - app_state & app); + database & db); void cert_revision_author_default(revision_id const & m, - app_state & app); + database & db); void cert_revision_tag(revision_id const & m, std::string const & tagname, - app_state & app); + database & db); void cert_revision_changelog(revision_id const & m, utf8 const & changelog, - app_state & app); + database & db); void cert_revision_comment(revision_id const & m, utf8 const & comment, - app_state & app); + database & db); void cert_revision_testresult(revision_id const & m, std::string const & results, - app_state & app); + database & db); // Local Variables: ============================================================ --- cmd_key_cert.cc f86c02cb2c35fc5fcf0f230ce4401d2dbae80023 +++ cmd_key_cert.cc 543558de324168a743c957aba995dac76b185b13 @@ -258,7 +258,7 @@ CMD(tag, N_("review"), N_("REVISION TAGN revision_id r; complete(app, idx(args, 0)(), r); - cert_revision_tag(r, idx(args, 1)(), app); + cert_revision_tag(r, idx(args, 1)(), app.db); } @@ -270,7 +270,7 @@ CMD(testresult, N_("review"), N_("ID (pa revision_id r; complete(app, idx(args, 0)(), r); - cert_revision_testresult(r, idx(args, 1)(), app); + cert_revision_testresult(r, idx(args, 1)(), app.db); } @@ -310,7 +310,7 @@ CMD(comment, N_("review"), N_("REVISION revision_id r; complete(app, idx(args, 0)(), r); - cert_revision_comment(r, comment, app); + cert_revision_comment(r, comment, app.db); } // Local Variables: ============================================================ --- database.cc ae8f5f845996bd646d50045a974be43f9921ab20 +++ database.cc 3763d91cc1b85dab06c0cb78cbcf695eb911a3fd @@ -3426,6 +3426,13 @@ database::hook_get_revision_cert_trust(s return __app->lua.hook_get_revision_cert_trust(signers, id, name, val); }; +bool +database::hook_get_author(rsa_keypair_id const & k, + string & author) +{ + return __app->lua.hook_get_author(__app->opts.branchname, k, author); +} + key_store & database::get_key_store() { ============================================================ --- database.hh c6c66cb8a819321627732b423f940f8a450cf8a5 +++ database.hh 64e707abbe0f62b28b543e7d8a02bd75df04abab @@ -597,6 +597,8 @@ public: hexenc const & id, cert_name const & name, cert_value const & val); bool hook_get_revision_cert_trust(std::set const & signers, hexenc const & id, cert_name const & name, cert_value const & val); + bool hook_get_author(rsa_keypair_id const & k, + std::string & author); key_store & get_key_store(); }; ============================================================ --- project.cc df1cb9edf0298e706d27a3416e872eba07f8994b +++ project.cc 98b70fd8d652825717df5f2ce37c427f0a2c6a2f @@ -122,7 +122,7 @@ project_t::put_revision_in_branch(revisi project_t::put_revision_in_branch(revision_id const & id, branch_name const & branch) { - cert_revision_in_branch(id, branch, app); + cert_revision_in_branch(id, branch, app.db); } @@ -222,7 +222,7 @@ project_t::put_tag(revision_id const & i project_t::put_tag(revision_id const & id, string const & name) { - cert_revision_tag(id, name, app); + cert_revision_tag(id, name, app.db); } @@ -233,13 +233,13 @@ project_t::put_standard_certs(revision_i date_t const & time, utf8 const & author) { - cert_revision_in_branch(id, branch, app); - cert_revision_changelog(id, changelog, app); - cert_revision_date_time(id, time, app); + cert_revision_in_branch(id, branch, app.db); + cert_revision_changelog(id, changelog, app.db); + cert_revision_date_time(id, time, app.db); if (!author().empty()) - cert_revision_author(id, author(), app); + cert_revision_author(id, author(), app.db); else - cert_revision_author_default(id, app); + cert_revision_author_default(id, app.db); } void @@ -258,7 +258,7 @@ project_t::put_cert(revision_id const & cert_name const & name, cert_value const & value) { - put_simple_revision_cert(id, name, value, app); + put_simple_revision_cert(id, name, value, app.db); } ============================================================ --- revision.cc 7ad90a9e362470d057f995bb361a0d80fab75870 +++ revision.cc c558597ffa870a502669d0620dae8f6f1567b1b9 @@ -923,7 +923,7 @@ void anc_graph::write_certs() cert_value val(j->second.second); cert new_cert; - make_simple_cert(rev.inner(), name, val, app, new_cert); + make_simple_cert(rev.inner(), name, val, app.db, new_cert); revision rcert(new_cert); if (app.db.put_revision_cert(rcert)) ++n_certs_out;