# # # patch "app_state.cc" # from [ecb7d18686acdb1d32aa797b861f75055f9604fa] # to [69a320265889e76fe5dcf52fe4bf44e3b6008795] # # patch "cert.cc" # from [9393def80ce527cdaca1dbbb57a1491bcc404eb5] # to [10432dc92f6585bbb161404793907839f0b132fb] # # patch "cert.hh" # from [0bad9418b419209e85f8a81aa59fa26ff6f547d7] # to [70debfdd578b64992c60e6b93a74b25232c5449b] # # patch "project.cc" # from [4d7e875349cf45cea1e4e34b82c372583431de02] # to [9a17da8bd61b30ed793dc81507eda3192c1456b5] # ============================================================ --- app_state.cc ecb7d18686acdb1d32aa797b861f75055f9604fa +++ app_state.cc 69a320265889e76fe5dcf52fe4bf44e3b6008795 @@ -226,11 +226,11 @@ app_state::get_project() projects.insert(make_pair(i->first, project_t(i->first, i->second, - *this))); + db))); } if (projects.empty()) { - projects.insert(std::make_pair("default", project_t(*this))); + projects.insert(std::make_pair("default", project_t(db))); } N(projects.size() == 1, F("multiple projects not supported yet")); } ============================================================ --- cert.cc 9393def80ce527cdaca1dbbb57a1491bcc404eb5 +++ cert.cc 10432dc92f6585bbb161404793907839f0b132fb @@ -161,12 +161,12 @@ void erase_bogus_certs(std::vector< revi } void erase_bogus_certs(std::vector< revision > & certs, - app_state & app) + database & db) { erase_bogus_certs(certs, - boost::bind(&lua_hooks::hook_get_revision_cert_trust, - &app.lua, _1, _2, _3, _4), - app); + boost::bind(&database::hook_get_revision_cert_trust, + &db, _1, _2, _3, _4), + db); } void erase_bogus_certs(vector< revision > & certs, ============================================================ --- cert.hh 0bad9418b419209e85f8a81aa59fa26ff6f547d7 +++ cert.hh 70debfdd578b64992c60e6b93a74b25232c5449b @@ -94,7 +94,7 @@ void erase_bogus_certs(std::vector< revi void erase_bogus_certs(std::vector< revision > & certs, trust_function trust_fn, - app_state & app); + database & db); void erase_bogus_certs(std::vector< revision > & certs, database & db); ============================================================ --- project.cc 4d7e875349cf45cea1e4e34b82c372583431de02 +++ project.cc 9a17da8bd61b30ed793dc81507eda3192c1456b5 @@ -9,6 +9,7 @@ #include "basic_io.hh" #include "cert.hh" #include "database.hh" +#include "file_io.hh" #include "globish.hh" #include "project.hh" #include "revision.hh" @@ -56,7 +57,7 @@ class policy_branch branch_name my_branch_cert_value; set my_committers; - app_state & app; + database & db; shared_ptr rev; void init(data const & spec) { @@ -91,15 +92,15 @@ public: public: policy_branch(data const & spec, branch_name const & prefix, - app_state & app) - : prefix(prefix), app(app) + database & db) + : prefix(prefix), db(db) { init(spec); } policy_branch(system_path const & spec_file, branch_name const & prefix, - app_state & app) - : prefix(prefix), app(app) + database & db) + : prefix(prefix), db(db) { require_path_is_file(spec_file, F("policy spec file %s does not exist") % spec_file, @@ -117,12 +118,12 @@ public: map branches; map delegations; public: - policy_revision(app_state & app, + policy_revision(database & db, revision_id const & rev, branch_name const & prefix) { roster_t roster; - app.db.get_roster(rev, roster); + db.get_roster(rev, roster); file_path branch_dir = file_path_internal("branches"); file_path delegation_dir = file_path_internal("delegations"); @@ -144,7 +145,7 @@ public: } file_id ident = downcast_to_file_t(i->second)->content; file_data spec; - app.db.get_file_version(ident, spec); + db.get_file_version(ident, spec); branch_name branch_cert_value; set committers; @@ -192,12 +193,12 @@ public: branch_name subprefix(prefix() + "." + i->first()); file_id ident = downcast_to_file_t(i->second)->content; file_data spec; - app.db.get_file_version(ident, spec); + db.get_file_version(ident, spec); delegations.insert(make_pair(subprefix, policy_branch(spec.inner(), subprefix, - app))); + db))); } } } @@ -224,7 +225,7 @@ namespace { struct not_in_policy_branch : public is_failure { - app_state & app; + database & db; base64 const & branch_encoded; set const & trusted_signers; bool is_trusted(set const & signers, @@ -241,41 +242,41 @@ namespace } return false; } - not_in_policy_branch(app_state & app, + not_in_policy_branch(database & db, base64 const & branch_encoded, set const & trusted) - : app(app), branch_encoded(branch_encoded), trusted_signers(trusted) + : db(db), branch_encoded(branch_encoded), trusted_signers(trusted) {} virtual bool operator()(revision_id const & rid) { vector< revision > certs; - app.db.get_revision_certs(rid, - cert_name(branch_cert_name), - branch_encoded, - certs); + db.get_revision_certs(rid, + cert_name(branch_cert_name), + branch_encoded, + certs); erase_bogus_certs(certs, boost::bind(¬_in_policy_branch::is_trusted, this, _1, _2, _3, _4), - app); + db); return certs.empty(); } }; revision_id policy_branch_head(branch_name const & name, set const & trusted_signers, - app_state & app) + database & db) { L(FL("getting heads of policy branch %s") % name); base64 branch_encoded; encode_base64(cert_value(name()), branch_encoded); set heads; - app.db.get_revisions_with_cert(cert_name(branch_cert_name), - branch_encoded, - heads); + db.get_revisions_with_cert(cert_name(branch_cert_name), + branch_encoded, + heads); - not_in_policy_branch p(app, branch_encoded, trusted_signers); - erase_ancestors_and_failures(heads, p, app, NULL); + not_in_policy_branch p(db, branch_encoded, trusted_signers); + erase_ancestors_and_failures(heads, p, db, NULL); E(heads.size() == 1, F("policy branch %s has %d heads, should have 1 head") @@ -291,8 +292,8 @@ shared_ptr policy_branc if (!rev) { revision_id rid; - rid = policy_branch_head(my_branch_cert_value, my_committers, app); - rev.reset(new policy_revision(app, rid, prefix)); + rid = policy_branch_head(my_branch_cert_value, my_committers, db); + rev.reset(new policy_revision(db, rid, prefix)); } return rev; } @@ -311,24 +312,24 @@ public: bool passthru; policy_info(system_path const & spec_file, branch_name const & prefix, - app_state & app) - : policy(spec_file, prefix, app), passthru(false) + database & db) + : policy(spec_file, prefix, db), passthru(false) { } - explicit policy_info(app_state & app) - : policy(data(""), branch_name(""), app), passthru(true) + explicit policy_info(database & db) + : policy(data(""), branch_name(""), db), passthru(true) { } }; project_t::project_t(string const & project_name, system_path const & spec_file, - app_state & app) - : project_policy(new policy_info(spec_file, branch_name(project_name), app)), app(app) + database & db) + : project_policy(new policy_info(spec_file, branch_name(project_name), db)), db(db) {} project_t::project_t(database & db) - : project_policy(new policy_info(app)), db(db) + : project_policy(new policy_info(db)), db(db) {} void