# # # patch "ChangeLog" # from [3fee00574e04881c0c4abfdb9c0f060115b1dad9] # to [1decf3f7a07eb7e5c669596fe7102d5b46289aa8] # # patch "automate.cc" # from [31010a960ddc85410dd8ce63c7e930ec32638a80] # to [e7926f73bc7cf89503f22a165db3e77ef29eff6f] # # patch "cmd_diff_log.cc" # from [322b4dd501b77931cac0b88538d8b51a10cf43a9] # to [bd8a6e152e16cf570c49ca4f1b818f3ea4fb6745] # # patch "cmd_merging.cc" # from [45ddec00c823fed34f1d06cbe8807df9a74999ef] # to [e256dd47ae468d206507fb2e13ae97bdd128dec1] # # patch "database.hh" # from [0d83dc83fd081a7af5bf057a73eba40b4b62a927] # to [2fef07493929d29e0fc5c5d5b1e7a0e96d3a7233] # # patch "work.cc" # from [1ec7ff6b263d869ba1e66d4c3716fd7b0c28a48e] # to [18ece2fa5e671e91177bd4ee11d3876e98acdbef] # # patch "work.hh" # from [19e655d50b16780d4c2571b4c88a428f319f6ff8] # to [b19ff1542b011ae6c1c32cb8b9455931cc5634f0] # ============================================================ --- ChangeLog 3fee00574e04881c0c4abfdb9c0f060115b1dad9 +++ ChangeLog 1decf3f7a07eb7e5c669596fe7102d5b46289aa8 @@ -1,5 +1,15 @@ 2007-02-09 Zack Weinberg + * work.cc (get_revision_id, get_base_revision, get_base_roster) + (get_base_and_current_roster_shape): Delete delete delete. + * work.hh: Likewise. Improve comments. + * database.hh (parent_cached_roster): New wrappers for parent_entries. + * automate.cc (attributes, get_base_revision_id) + * cmd_diff_log.cc (prepare_diff) + * cmd_merging.cc (update, merge_into_workspace) + Use parent_id/parent_roster/parent_cached_roster wrappers instead + of direct access to pair ->first and ->second. + * cmd_ws_commit.cc (revert): Remove the remaining use of get_revision_id. ============================================================ --- automate.cc 31010a960ddc85410dd8ce63c7e930ec32638a80 +++ automate.cc e7926f73bc7cf89503f22a165db3e77ef29eff6f @@ -233,7 +233,7 @@ AUTOMATE(attributes, N_("FILE"), options app.work.get_parent_rosters(parents); N(parents.size() == 1, F("this command can only be used in a single-parent workspace")); - base = *(parents.begin()->second.first); + base = parent_roster(parents.begin()); // escalate if the given path is unknown to the current roster N(current.has_node(path), @@ -965,7 +965,7 @@ AUTOMATE(get_base_revision_id, "", optio N(parents.size() == 1, F("this command can only be used in a single-parent workspace")); - output << parents.begin()->first << "\n"; + output << parent_id(parents.begin()) << "\n"; } // Name: get_current_revision_id ============================================================ --- cmd_diff_log.cc 322b4dd501b77931cac0b88538d8b51a10cf43a9 +++ cmd_diff_log.cc bd8a6e152e16cf570c49ca4f1b818f3ea4fb6745 @@ -368,8 +368,8 @@ prepare_diff(cset & included, F("this workspace has more than one parent\n" "(specify a revision to diff against with --revision)")); - old_rid = parents.begin()->first; - old_roster = *(parents.begin()->second.first); + old_rid = parent_id(parents.begin()); + old_roster = parent_roster(parents.begin()); app.work.get_current_roster_shape(new_roster, nis); node_restriction mask(args_to_paths(args), ============================================================ --- cmd_merging.cc 45ddec00c823fed34f1d06cbe8807df9a74999ef +++ cmd_merging.cc e256dd47ae468d206507fb2e13ae97bdd128dec1 @@ -146,7 +146,7 @@ CMD(update, N_("workspace"), "", N(parents.size() == 1, F("this command can only be used in a single-parent workspace")); - revision_id old_rid = parents.begin()->first; + revision_id old_rid = parent_id(parents.begin()); N(!null_id(old_rid), F("this workspace is a new project; cannot update")); @@ -226,7 +226,8 @@ CMD(update, N_("workspace"), "", temp_node_id_source nis; // Get the OLD and WORKING rosters - database::roster_t_cp old_roster = parents.begin()->second.first; + database::roster_t_cp old_roster + = parent_cached_roster(parents.begin()).first; MM(*old_roster); roster_t working_roster; MM(working_roster); app.work.get_current_roster_shape(working_roster, nis); @@ -627,8 +628,8 @@ CMD(merge_into_workspace, N_("tree"), N(parent_roster(parents.begin()) == working_roster, F("'%s' can only be used in a workspace with no pending changes") % name); - left_id = parents.begin()->first; - left = parents.begin()->second; + left_id = parent_id(parents.begin()); + left = parent_cached_roster(parents.begin()); } complete(app, idx(args, 0)(), right_id); ============================================================ --- database.hh 0d83dc83fd081a7af5bf057a73eba40b4b62a927 +++ database.hh 2fef07493929d29e0fc5c5d5b1e7a0e96d3a7233 @@ -596,6 +596,18 @@ inline revision_id const & parent_id(par return i->first; } +inline database::cached_roster const & +parent_cached_roster(parent_entry const & p) +{ + return p.second; +} + +inline database::cached_roster const & +parent_cached_roster(parent_map::const_iterator i) +{ + return i->second; +} + inline roster_t const & parent_roster(parent_entry const & p) { return *(p.second.first); ============================================================ --- work.cc 1ec7ff6b263d869ba1e66d4c3716fd7b0c28a48e +++ work.cc 18ece2fa5e671e91177bd4ee11d3876e98acdbef @@ -109,21 +109,6 @@ workspace::put_work_rev(revision_t const write_data(rev_path, rev_data); } -// base revision ID -void -workspace::get_revision_id(revision_id & c) -{ - revision_t rev; - get_work_rev(rev); - - // If you're using this interface, the revision must have only one - // ancestor. - I(rev.edges.size() == 1); - c = edge_old_revision(rev.edges.begin()); - N(null_id(c) || db.revision_exists(c), - F("workspace base revision %s does not exist in database") % c); -} - // structures derived from the work revision, the database, and possibly // the workspace @@ -150,35 +135,6 @@ void } void -workspace::get_base_revision(revision_id & rid, - roster_t & ros, - marking_map & mm) -{ - database::cached_roster cr; - get_revision_id(rid); - get_roster_for_rid(rid, cr, db); - ros = *cr.first; - mm = *cr.second; -} - -void -workspace::get_base_revision(revision_id & rid, - roster_t & ros) -{ - database::cached_roster cr; - get_revision_id(rid); - get_roster_for_rid(rid, cr, db); - ros = *cr.first; -} - -void -workspace::get_base_roster(roster_t & ros) -{ - revision_id rid; - get_base_revision(rid, ros); -} - -void workspace::get_parent_rosters(parent_map & parents) { revision_t rev; @@ -215,25 +171,6 @@ workspace::get_current_roster_shape(rost } } -void -workspace::get_base_and_current_roster_shape(roster_t & base_roster, - roster_t & current_roster, - node_id_source & nis) -{ - // If you're using this interface, the revision must have only one - // ancestor. - revision_t rev; - get_work_rev(rev); - I(rev.edges.size() == 1); - - database::cached_roster cr; - get_roster_for_rid(edge_old_revision(rev.edges.begin()), cr, db); - - base_roster = current_roster = *cr.first; - editable_roster_base er(current_roster, nis); - edge_changes(rev.edges.begin()).apply_to(er); -} - // user log file void ============================================================ --- work.hh 19e655d50b16780d4c2571b4c88a428f319f6ff8 +++ work.hh b19ff1542b011ae6c1c32cb8b9455931cc5634f0 @@ -106,14 +106,15 @@ struct workspace // read the (partial) revision describing the current workspace. void get_work_rev(revision_t & rev); - // convenience wrappers around the above functions. these interfaces are - // safe for use with multi-parent workspaces: + // convenience wrappers around the above functions. // This returns the current roster, except it does not bother updating the - // hashes in that roster -- the "shape" is correct, all files and dirs exist - // and under the correct names -- but do not trust file content hashes. - // If you need the current roster with correct file content hashes, call - // update_current_roster_from_filesystem on the result of this function. + // hashes in that roster -- the "shape" is correct, all files and dirs + // exist and under the correct names -- but do not trust file content + // hashes. If you need the current roster with correct file content + // hashes, call update_current_roster_from_filesystem on the result of + // this function. Under almost all conditions, NIS should be a + // temp_node_id_source. void get_current_roster_shape(roster_t & ros, node_id_source & nis); // This returns a map whose keys are revision_ids and whose values are @@ -121,23 +122,8 @@ struct workspace // revision. void get_parent_rosters(parent_map & parents); - // ... these interfaces can only be used with single-parent workspaces: - - // the base revision id that the current working copy was checked out from - void get_revision_id(revision_id & c); - - // structures derived from the above - void get_base_revision(revision_id & rid, roster_t & ros); - void get_base_revision(revision_id & rid, roster_t & ros, marking_map & mm); - void get_base_roster(roster_t & ros); - - // This returns both the base roster (as get_base_roster would) and the - // current roster shape (as get_current_roster_shape would). The caveats - // for get_current_roster_shape also apply to this function. - void get_base_and_current_roster_shape(roster_t & base_roster, - roster_t & current_roster, - node_id_source & nis); - + // Inspect the workspace and classify all the paths in it according to + // what ROS thinks of them. void classify_roster_paths(roster_t const & ros, path_set & unchanged, path_set & changed,