# # # patch "database.cc" # from [e75158e921f61bc568fbc2b65ca2767b70dccb03] # to [b80c102ba2c3ac8f7cca7298b132b02083bea9fc] # # patch "database.hh" # from [06b5ded87a551927072f092bde8b6eb20dcecfb7] # to [0a1ebe34990baeff7a8f7dad5e89de7a647be8ca] # # patch "work.cc" # from [9dce7b32e4ae4bdc1d8f8c04c24232ef678baa51] # to [cebcdd33eb19bf15b3b2781d7362b7f8e8c4d752] # ============================================================ --- database.cc e75158e921f61bc568fbc2b65ca2767b70dccb03 +++ database.cc b80c102ba2c3ac8f7cca7298b132b02083bea9fc @@ -3250,6 +3250,30 @@ void } void +database::get_parent_map(revision_t const & rev, parent_map & parents) +{ + parents.clear(); + for (edge_map::const_iterator i = rev.edges.begin(); i != rev.edges.end(); i++) + { + cached_roster cr; + revision_id const & rid = edge_old_revision(i); + // We may be asked for a roster corresponding to the null rid, which + // is not in the database. In this situation, what is wanted is an + // empty roster (and marking map). + if (null_id(rid)) + { + cr.first = boost::shared_ptr(new roster_t); + cr.second = boost::shared_ptr(new marking_map); + } + else + { + db.get_roster(rid, cr); + } + safe_insert(parents, make_pair(rid, cr)); + } +} + +void database::put_roster(revision_id const & rev_id, roster_t_cp const & roster, marking_map_cp const & marking) ============================================================ --- database.hh 06b5ded87a551927072f092bde8b6eb20dcecfb7 +++ database.hh 0a1ebe34990baeff7a8f7dad5e89de7a647be8ca @@ -343,6 +343,12 @@ public: void get_roster(revision_id const & rid, cached_roster & cr); + // Maybe this shouldn't be part of this class? It is only a utility + // function. It also has some smarts, e.g. get_roster on a null + // revision_id will crash, but get_parent_map on a root revision will put + // an empty roster into the parent_map it returns. + void get_parent_map(revision_t const & rev, parent_map & parents); + // these are exposed for the use of database_check.cc bool roster_version_exists(revision_id const & ident); void get_roster_ids(std::set & ids); ============================================================ --- work.cc 9dce7b32e4ae4bdc1d8f8c04c24232ef678baa51 +++ work.cc cebcdd33eb19bf15b3b2781d7362b7f8e8c4d752 @@ -153,41 +153,12 @@ workspace::set_work_state(parent_map con // structures derived from the work revision, the database, and possibly // the workspace -static void -get_roster_for_rid(revision_id const & rid, - cached_roster & cr, - database & db) -{ - // We may be asked for a roster corresponding to the null rid, which - // is not in the database. In this situation, what is wanted is an empty - // roster (and marking map). - if (null_id(rid)) - { - cr.first = boost::shared_ptr(new roster_t); - cr.second = boost::shared_ptr(new marking_map); - } - else - { - N(db.revision_exists(rid), - F("base revision %s does not exist in database") % rid); - db.get_roster(rid, cr); - } - L(FL("base roster has %d entries") % cr.first->all_nodes().size()); -} - void workspace::get_parent_rosters(parent_map & parents) { revision_t rev; get_work_rev(rev); - - parents.clear(); - for (edge_map::const_iterator i = rev.edges.begin(); i != rev.edges.end(); i++) - { - cached_roster cr; - get_roster_for_rid(edge_old_revision(i), cr, db); - safe_insert(parents, make_pair(edge_old_revision(i), cr)); - } + db.get_parent_map(rev, parents); } void