# # # patch "policy.cc" # from [eaabf785c3962e7eec66465ada891b8e5becdbb2] # to [48d32a6adb58c25296fc25688a6c6f9e18bfb87f] # # patch "policy.hh" # from [8b03d80bf7d715c67d13a387b7cd8a4982a1e81b] # to [e1f8fbf5b500089012a4de045742fbc9a1620437] # # patch "project.cc" # from [13b39126ec8c39fc4ea9428b7092657b4f904420] # to [ed85ed558b26c5d9e0e63359c59bec7ba3f600f4] # # patch "project.hh" # from [cf47bf7a55c95d41af083cd7cb80085ed53dd987] # to [3c2a769f1897d909d9e18d6708aff10607b395ac] # ============================================================ --- policy.cc eaabf785c3962e7eec66465ada891b8e5becdbb2 +++ policy.cc 48d32a6adb58c25296fc25688a6c6f9e18bfb87f @@ -69,6 +69,14 @@ policy_branch::policy_branch(revision_id rev.reset(new policy_revision(db, rid, prefix)); } +policy_branch::policy_branch(std::map const & delegations, + branch_prefix const & my_prefix, + database & db) + : prefix(my_prefix), db(db) +{ + rev.reset(new policy_revision(delegations, db)); +} + void policy_branch::init(data const & spec) { @@ -213,6 +221,19 @@ policy_revision::policy_revision(databas } } +policy_revision::policy_revision(std::map const & del, + database & db) +{ + for (std::map::const_iterator i = del.begin(); + i != del.end(); ++i) + { + delegations.insert(std::make_pair(i->first, + policy_branch(i->second, + i->first, + db))); + } +} + map policy_revision::all_branches() { ============================================================ --- policy.hh 8b03d80bf7d715c67d13a387b7cd8a4982a1e81b +++ policy.hh e1f8fbf5b500089012a4de045742fbc9a1620437 @@ -90,6 +90,9 @@ public: policy_branch(revision_id const & rid, branch_prefix const & prefix, database & db); + policy_branch(std::map const & delegations, + branch_prefix const & my_prefix, + database & db); boost::shared_ptr get_policy(); std::map branches(); @@ -111,6 +114,8 @@ public: policy_revision(database & db, revision_id const & rev, branch_prefix const & prefix); + policy_revision(std::map const & del, + database & db); std::map all_branches(); void get_delegation_names(std::set & names) const; ============================================================ --- project.cc 13b39126ec8c39fc4ea9428b7092657b4f904420 +++ project.cc ed85ed558b26c5d9e0e63359c59bec7ba3f600f4 @@ -26,7 +26,6 @@ using boost::shared_ptr; using std::make_pair; using boost::shared_ptr; - class policy_info { public: @@ -48,6 +47,10 @@ public: : policy(policy_branch::empty_policy(db)), passthru(true) { } + policy_info(map const & delegations, database & db) + : policy(delegations, branch_prefix(), db), passthru(false) + { + } }; project_t::project_t(branch_prefix const & project_name, @@ -66,6 +69,35 @@ project_t::project_t(database & db) : db(db), project_policy(new policy_info(db)) {} +project_t::project_t(database & db, lua_hooks & lua, options & opts) + : db(db)//, project_policy(db, lua, opts) +{ + std::map delegations; + + + for (map >::const_iterator + i = opts.policy_revisions.begin(); + i != opts.policy_revisions.end(); ++i) + { + data dat("revision_id ["+i->second()+"]\n"); + delegations.insert(make_pair(i->first, + dat)); + } + + std::map defs; + lua.hook_get_projects(defs); + for (map::const_iterator i = defs.begin(); + i != defs.end(); ++i) + { + delegations.insert(make_pair(branch_prefix(i->first), + i->second)); + } + if (delegations.empty()) + project_policy.reset(new policy_info(db)); + else + project_policy.reset(new policy_info(delegations, db)); +} + bool project_t::get_policy_branch_policy_of(branch_name const & name, branch_policy & policy_branch_policy, @@ -637,24 +669,6 @@ project_t & } project_t & -project_set::get_project(branch_prefix const & name) -{ - project_t * const project = maybe_get_project(name); - I(project != NULL); - return *project; -} - -project_t * -project_set::maybe_get_project(branch_prefix const & name) -{ - map::iterator i = projects.find(name); - if (i != projects.end()) - return &i->second; - else - return NULL; -} - -project_t & project_set::get_project_of_branch(branch_name const & branch) { MM(branch); ============================================================ --- project.hh cf47bf7a55c95d41af083cd7cb80085ed53dd987 +++ project.hh 3c2a769f1897d909d9e18d6708aff10607b395ac @@ -62,6 +62,7 @@ public: project_t(branch_prefix const & project_name, revision_id const & policy_rev, database & db); + project_t(database & db, lua_hooks & lua, options & opts); bool get_policy_branch_policy_of(branch_name const & name, branch_policy & policy_branch_policy, @@ -149,10 +150,6 @@ public: project_map const & all_projects() const; - // Get a named project. - project_t & get_project(branch_prefix const & name); - project_t * maybe_get_project(branch_prefix const & name); - // Get the project containing a named branch. project_t & get_project_of_branch(branch_name const & branch); project_t * maybe_get_project_of_branch(branch_name const & branch);