# # # patch "database.cc" # from [7249d3009e36b16ea76cd5140258a64a2f49f4ac] # to [22e4b9ab811ee3efcd5a166a67094e259ea8190a] # # patch "database.hh" # from [3f70833f9928db8ea4e9e944246318d21dcd341d] # to [5d4aef04a21ec365ba5aa77082d0dd83d915aaef] # # patch "outdated_indicator.cc" # from [ba676108726aaf7eba3b7e7e357165696e15a599] # to [d2a291d777cf8fc623aba344f077260aa5f6640d] # # patch "outdated_indicator.hh" # from [8f8a6bd36595e3c846be40ad59f550983a00f2a0] # to [8e9f3eda60d383421cf8e280722f83aada2ca29a] # # patch "project.cc" # from [1b6e35dad7b01bd6ba5561c2ccad1a330beb1684] # to [7f09669ff03f52d03219582eb0885e66fee42c57] # # patch "project.hh" # from [617e7b94d34649ffe5ea90f1d5e783ba0c7260c8] # to [a2f4dd3608d0bb80168a5aa41cef110a3f0c3af9] # ============================================================ --- database.cc 7249d3009e36b16ea76cd5140258a64a2f49f4ac +++ database.cc 22e4b9ab811ee3efcd5a166a67094e259ea8190a @@ -3936,7 +3936,7 @@ namespace { // the lua hook wants key_identity_info, but all that's been // pulled from the certs is key_id. So this is needed to translate. // use pointers for project and lua so bind() doesn't make copies - bool check_revision_cert_trust(project_t * const project, + bool check_revision_cert_trust(project_t const * const project, lua_hooks * const lua, set const & signers, id const & hash, @@ -3980,7 +3980,7 @@ void } // anonymous namespace void -database::erase_bogus_certs(project_t & project, vector & certs) +database::erase_bogus_certs(project_t const & project, vector & certs) { erase_bogus_certs_internal(certs, *this, boost::bind(&check_revision_cert_trust, ============================================================ --- database.hh 3f70833f9928db8ea4e9e944246318d21dcd341d +++ database.hh 5d4aef04a21ec365ba5aa77082d0dd83d915aaef @@ -344,7 +344,7 @@ public: cert_name const &, cert_value const &)> cert_trust_checker; // this takes a project_t so it can translate key names for the trust hook - void erase_bogus_certs(project_t & project, std::vector & certs); + void erase_bogus_certs(project_t const & project, std::vector & certs); // permit alternative trust functions void erase_bogus_certs(std::vector & certs, cert_trust_checker const & checker); ============================================================ --- outdated_indicator.cc ba676108726aaf7eba3b7e7e357165696e15a599 +++ outdated_indicator.cc d2a291d777cf8fc623aba344f077260aa5f6640d @@ -58,7 +58,7 @@ bool {} bool -outdated_indicator::outdated() +outdated_indicator::outdated() const { if (parent) { ============================================================ --- outdated_indicator.hh 8f8a6bd36595e3c846be40ad59f550983a00f2a0 +++ outdated_indicator.hh 8e9f3eda60d383421cf8e280722f83aada2ca29a @@ -33,7 +33,7 @@ public: public: outdated_indicator(); explicit outdated_indicator(boost::shared_ptr p); - bool outdated(); + bool outdated() const; }; ============================================================ --- project.cc 1b6e35dad7b01bd6ba5561c2ccad1a330beb1684 +++ project.cc 7f09669ff03f52d03219582eb0885e66fee42c57 @@ -62,7 +62,7 @@ project_t::get_branch_list(set & names, - bool check_heads) + bool check_heads) const { if (indicator.outdated()) { @@ -92,7 +92,7 @@ project_t::get_branch_list(globish const void project_t::get_branch_list(globish const & glob, set & names, - bool check_heads) + bool check_heads) const { vector got; db.get_branches(glob, got); @@ -118,9 +118,9 @@ namespace { struct not_in_branch : public is_failure { - project_t & project; + project_t const & project; branch_name const & branch; - not_in_branch(project_t & project, + not_in_branch(project_t const & project, branch_name const & branch) : project(project), branch(branch) {} @@ -138,9 +138,9 @@ namespace struct suspended_in_branch : public is_failure { - project_t & project; + project_t const & project; branch_name const & branch; - suspended_in_branch(project_t & project, + suspended_in_branch(project_t const & project, branch_name const & branch) : project(project), branch(branch) {} @@ -161,7 +161,7 @@ project_t::get_branch_heads(branch_name project_t::get_branch_heads(branch_name const & name, set & heads, bool ignore_suspend_certs, - multimap * inverse_graph_cache_ptr) + multimap * inverse_graph_cache_ptr) const { pair cache_index(name, ignore_suspend_certs); @@ -223,7 +223,7 @@ project_t::revision_is_in_branch(revisio bool project_t::revision_is_in_branch(revision_id const & id, - branch_name const & branch) + branch_name const & branch) const { vector certs; db.get_revision_certs(id, branch_cert_name, @@ -252,7 +252,7 @@ project_t::revision_is_suspended_in_bran bool project_t::revision_is_suspended_in_branch(revision_id const & id, - branch_name const & branch) + branch_name const & branch) const { vector certs; db.get_revision_certs(id, suspend_cert_name, @@ -282,14 +282,14 @@ project_t::get_revision_cert_hashes(revi outdated_indicator project_t::get_revision_cert_hashes(revision_id const & rid, - vector & hashes) + vector & hashes) const { return db.get_revision_certs(rid, hashes); } outdated_indicator project_t::get_revision_certs(revision_id const & id, - vector & certs) + vector & certs) const { return db.get_revision_certs(id, certs); } @@ -297,7 +297,7 @@ project_t::get_revision_certs_by_name(re outdated_indicator project_t::get_revision_certs_by_name(revision_id const & id, cert_name const & name, - vector & certs) + vector & certs) const { outdated_indicator i = db.get_revision_certs(id, name, certs); db.erase_bogus_certs(*this, certs); @@ -306,7 +306,7 @@ project_t::get_revision_branches(revisio outdated_indicator project_t::get_revision_branches(revision_id const & id, - set & branches) + set & branches) const { vector certs; outdated_indicator i = get_revision_certs_by_name(id, branch_cert_name, certs); @@ -320,7 +320,7 @@ project_t::get_branch_certs(branch_name outdated_indicator project_t::get_branch_certs(branch_name const & branch, - vector > & certs) + vector > & certs) const { return db.get_revision_certs(branch_cert_name, typecast_vocab(branch), certs); @@ -351,7 +351,7 @@ outdated_indicator } outdated_indicator -project_t::get_tags(set & tags) +project_t::get_tags(set & tags) const { vector certs; outdated_indicator i = db.get_revision_certs(tag_cert_name, certs); @@ -485,7 +485,7 @@ project_t::lookup_key_by_name(key_store project_t::lookup_key_by_name(key_store * const keys, lua_hooks & lua, key_name const & name, - key_id & id) + key_id & id) const { set ks_match_by_local_name; set db_match_by_local_name; @@ -568,7 +568,7 @@ project_t::get_given_name_of_key(key_sto void project_t::get_given_name_of_key(key_store * const keys, key_id const & id, - key_name & name) + key_name & name) const { if (keys && keys->key_pair_exists(id)) { @@ -590,7 +590,7 @@ project_t::complete_key_identity_from_id void project_t::complete_key_identity_from_id(key_store * const keys, lua_hooks & lua, - key_identity_info & info) + key_identity_info & info) const { MM(info.id); MM(info.official_name); @@ -603,14 +603,14 @@ project_t::complete_key_identity_from_id void project_t::complete_key_identity_from_id(key_store & keys, lua_hooks & lua, - key_identity_info & info) + key_identity_info & info) const { complete_key_identity_from_id(&keys, lua, info); } void project_t::complete_key_identity_from_id(lua_hooks & lua, - key_identity_info & info) + key_identity_info & info) const { complete_key_identity_from_id(0, lua, info); } @@ -619,7 +619,7 @@ project_t::get_key_identity(key_store * project_t::get_key_identity(key_store * const keys, lua_hooks & lua, external_key_name const & input, - key_identity_info & output) + key_identity_info & output) const { try { @@ -645,7 +645,7 @@ project_t::get_key_identity(key_store & project_t::get_key_identity(key_store & keys, lua_hooks & lua, external_key_name const & input, - key_identity_info & output) + key_identity_info & output) const { get_key_identity(&keys, lua, input, output); } @@ -653,7 +653,7 @@ project_t::get_key_identity(lua_hooks & void project_t::get_key_identity(lua_hooks & lua, external_key_name const & input, - key_identity_info & output) + key_identity_info & output) const { get_key_identity(0, lua, input, output); } @@ -662,7 +662,7 @@ project_t::get_key_identity(key_store & project_t::get_key_identity(key_store & keys, lua_hooks & lua, arg_type const & input, - key_identity_info & output) + key_identity_info & output) const { get_key_identity(&keys, lua, typecast_vocab(input), output); } @@ -670,7 +670,7 @@ project_t::get_key_identity(lua_hooks & void project_t::get_key_identity(lua_hooks & lua, arg_type const & input, - key_identity_info & output) + key_identity_info & output) const { get_key_identity(0, lua, typecast_vocab(input), output); } ============================================================ --- project.hh 617e7b94d34649ffe5ea90f1d5e783ba0c7260c8 +++ project.hh a2f4dd3608d0bb80168a5aa41cef110a3f0c3af9 @@ -59,8 +59,8 @@ public: class tag_t { public: - revision_id ident; - utf8 name; + revision_id const ident; + utf8 const name; key_id key; tag_t(revision_id const & ident, utf8 const & name, key_id const & key); }; @@ -80,47 +80,50 @@ private: database & db; private: - std::map, - std::pair > - > branch_heads; - std::set branches; - outdated_indicator indicator; + // These are caches of what's in the database. They are updated when + // they're noticed to be out of date, which will always be during a + // logically read-only operation. + mutable std::map, + std::pair > + > branch_heads; + mutable std::set branches; + mutable outdated_indicator indicator; public: project_t(database & db); void get_branch_list(std::set & names, - bool check_heads = false); + bool check_heads = false) const; void get_branch_list(globish const & glob, std::set & names, - bool check_heads = false); + bool check_heads = false) const; void get_branch_heads(branch_name const & name, std::set & heads, bool ignore_suspend_certs, - std::multimap *inverse_graph_cache_ptr = NULL); + std::multimap *inverse_graph_cache_ptr = NULL) const; - outdated_indicator get_tags(std::set & tags); + outdated_indicator get_tags(std::set & tags) const; void put_tag(key_store & keys, revision_id const & id, std::string const & name); - bool revision_is_in_branch(revision_id const & id, branch_name const & branch); + bool revision_is_in_branch(revision_id const & id, branch_name const & branch) const; void put_revision_in_branch(key_store & keys, revision_id const & id, branch_name const & branch); - bool revision_is_suspended_in_branch(revision_id const & id, branch_name const & branch); + bool revision_is_suspended_in_branch(revision_id const & id, branch_name const & branch) const; void suspend_revision_in_branch(key_store & keys, revision_id const & id, branch_name const & branch); outdated_indicator get_revision_cert_hashes(revision_id const & rid, - std::vector & hashes); + std::vector & hashes) const; outdated_indicator get_revision_certs(revision_id const & id, - std::vector & certs); + std::vector & certs) const; outdated_indicator get_revision_certs_by_name(revision_id const & id, cert_name const & name, - std::vector & certs); + std::vector & certs) const; outdated_indicator get_revision_branches(revision_id const & id, - std::set & branches); + std::set & branches) const; outdated_indicator get_branch_certs(branch_name const & branch, - std::vector > & certs); + std::vector > & certs) const; void put_standard_certs(key_store & keys, revision_id const & id, @@ -153,38 +156,38 @@ private: void lookup_key_by_name(key_store * const keys, lua_hooks & lua, key_name const & name, - key_id & id); + key_id & id) const; // get the name given when creating the key void get_given_name_of_key(key_store * const keys, key_id const & id, - key_name & name); + key_name & name) const; void complete_key_identity_from_id(key_store * const keys, lua_hooks & lua, - key_identity_info & info); + key_identity_info & info) const; void get_key_identity(key_store * const keys, lua_hooks & lua, external_key_name const & input, - key_identity_info & output); + key_identity_info & output) const; public: void complete_key_identity_from_id(key_store & keys, lua_hooks & lua, - key_identity_info & info); + key_identity_info & info) const; void complete_key_identity_from_id(lua_hooks & lua, - key_identity_info & info); + key_identity_info & info) const; void get_key_identity(key_store & keys, lua_hooks & lua, external_key_name const & input, - key_identity_info & output); + key_identity_info & output) const; void get_key_identity(lua_hooks & lua, external_key_name const & input, - key_identity_info & output); + key_identity_info & output) const; void get_key_identity(key_store & keys, lua_hooks & lua, arg_type const & input, - key_identity_info & output); + key_identity_info & output) const; void get_key_identity(lua_hooks & lua, arg_type const & input, - key_identity_info & output); + key_identity_info & output) const; }; std::string