# # # patch "automate.cc" # from [45bb2a401fc728830258f56c98a9031b0711d281] # to [4b00111afabfc8338bcbf975109e1cbf34987246] # # patch "cmd_list.cc" # from [9ecdfc62f2c06ccbf08599a34317edcec06d8e2d] # to [2fbe55a8c3d275301cbb1ddd8a73aec113c3ecee] # # patch "cmd_ws_commit.cc" # from [52864991081a260cdc9d7d08b8e5e8d4d855ddfd] # to [c1150f715d7c85d84903a45bfc10567c0a970c74] # # patch "work.cc" # from [ba49d44159b566894eafbc7db222b1716505dbb2] # to [7427fd015f653a597c9cad80c763f4053424d707] # # patch "work.hh" # from [8797491e6dd9884bbbb4a76dc00e87b5dfd9f7f9] # to [34a9af24a7439e5edb50a28a12bd10a11d8010f2] # ============================================================ --- automate.cc 45bb2a401fc728830258f56c98a9031b0711d281 +++ automate.cc 4b00111afabfc8338bcbf975109e1cbf34987246 @@ -562,13 +562,13 @@ inventory_node_state(inventory_map & inv static void inventory_node_state(inventory_map & inventory, - path_set const & paths, + set const & paths, inventory_item::nstate node_state) { - for (path_set::const_iterator i = paths.begin(); i != paths.end(); i++) + for (set::const_iterator i = paths.begin(); i != paths.end(); i++) { L(FL("%d %d %s") % inventory[*i].node_state - % node_state % file_path(*i)); + % node_state % *i); I(inventory[*i].node_state == inventory_item::UNCHANGED_NODE); inventory[*i].node_state = node_state; } @@ -664,7 +664,7 @@ CMD_AUTOMATE(inventory, "", revision_t rev; inventory_map inventory; cset cs; MM(cs); - path_set unchanged, changed, missing, unknown, ignored; + set unchanged, changed, missing, unknown, ignored; app.work.get_current_roster_shape(curr, nis); app.work.get_work_rev(rev); ============================================================ --- cmd_list.cc 9ecdfc62f2c06ccbf08599a34317edcec06d8e2d +++ cmd_list.cc 2fbe55a8c3d275301cbb1ddd8a73aec113c3ecee @@ -36,6 +36,7 @@ using std::sort; using std::pair; using std::set; using std::sort; +using std::copy; using std::string; using std::vector; @@ -368,7 +369,7 @@ CMD(known, "known", "", CMD_REF(list), " new_roster, app); // to be printed sorted - vector print_paths; + vector print_paths; node_map const & nodes = new_roster.all_nodes(); for (node_map::const_iterator i = nodes.begin(); @@ -381,16 +382,13 @@ CMD(known, "known", "", CMD_REF(list), " { split_path sp; new_roster.get_name(nid, sp); - print_paths.push_back(sp); + print_paths.push_back(file_path(sp)); } } sort(print_paths.begin(), print_paths.end()); - for (vector::const_iterator sp = print_paths.begin(); - sp != print_paths.end(); sp++) - { - cout << *sp << '\n'; - } + copy(print_paths.begin(), print_paths.end(), + ostream_iterator(cout, "\n")); } CMD(unknown, "unknown", "ignored", CMD_REF(list), "", @@ -403,7 +401,7 @@ CMD(unknown, "unknown", "ignored", CMD_R vector roots = args_to_paths(args); path_restriction mask(roots, args_to_paths(app.opts.exclude_patterns), app.opts.depth, app); - path_set unknown, ignored; + set unknown, ignored; // if no starting paths have been specified use the workspace root if (roots.empty()) @@ -413,15 +411,13 @@ CMD(unknown, "unknown", "ignored", CMD_R utf8 const & realname = execid[execid.size() - 1]; if (realname() == "ignored") - for (path_set::const_iterator i = ignored.begin(); - i != ignored.end(); ++i) - cout << file_path(*i) << '\n'; + copy(ignored.begin(), ignored.end(), + ostream_iterator(cout, "\n")); else { I(realname() == "unknown"); - for (path_set::const_iterator i = unknown.begin(); - i != unknown.end(); ++i) - cout << file_path(*i) << '\n'; + copy(unknown.begin(), unknown.end(), + ostream_iterator(cout, "\n")); } } @@ -438,14 +434,11 @@ CMD(missing, "missing", "", CMD_REF(list app.opts.depth, current_roster_shape, app); - path_set missing; + set missing; app.work.find_missing(current_roster_shape, mask, missing); - for (path_set::const_iterator i = missing.begin(); - i != missing.end(); ++i) - { - cout << file_path(*i) << '\n'; - } + copy(missing.begin(), missing.end(), + ostream_iterator(cout, "\n")); } @@ -474,7 +467,7 @@ CMD(changed, "changed", "", CMD_REF(list make_restricted_revision(parents, new_roster, mask, rrev); // to be printed sorted, with duplicates removed - set print_paths; + set print_paths; for (edge_map::const_iterator i = rrev.edges.begin(); i != rrev.edges.end(); i++) @@ -493,16 +486,12 @@ CMD(changed, "changed", "", CMD_REF(list new_roster.get_name(*i, sp); else old_roster.get_name(*i, sp); - print_paths.insert(sp); + print_paths.insert(file_path(sp)); } } - for (set::const_iterator sp = print_paths.begin(); - sp != print_paths.end(); sp++) - { - cout << *sp << '\n'; - } - + copy(print_paths.begin(), print_paths.end(), + ostream_iterator(cout, "\n")); } namespace ============================================================ --- cmd_ws_commit.cc 52864991081a260cdc9d7d08b8e5e8d4d855ddfd +++ cmd_ws_commit.cc c1150f715d7c85d84903a45bfc10567c0a970c74 @@ -178,7 +178,7 @@ CMD(revert, "revert", "", CMD_REF(worksp // restriction we first find all missing files included by the // specified args and then make a restriction that includes only // these missing files. - path_set missing; + set missing; app.work.find_missing(new_roster, mask, missing); if (missing.empty()) { @@ -187,11 +187,11 @@ CMD(revert, "revert", "", CMD_REF(worksp } std::vector missing_files; - for (path_set::const_iterator i = missing.begin(); i != missing.end(); i++) + for (set::const_iterator i = missing.begin(); + i != missing.end(); i++) { - file_path fp(*i); - L(FL("missing files are '%s'") % fp); - missing_files.push_back(fp); + L(FL("reverting missing file: %s") % *i); + missing_files.push_back(*i); } // replace the original mask with a more restricted one mask = node_restriction(missing_files, std::vector(), @@ -338,37 +338,29 @@ CMD(mkdir, "mkdir", "", CMD_REF(workspac app.require_workspace(); - path_set paths; - //spin through args and try to ensure that we won't have any collisions - //before doing any real filesystem modification. we'll also verify paths - //against .mtn-ignore here. - for (args_vector::const_iterator i = args.begin(); - i != args.end(); ++i) + set paths; + // spin through args and try to ensure that we won't have any collisions + // before doing any real filesystem modification. we'll also verify paths + // against .mtn-ignore here. + for (args_vector::const_iterator i = args.begin(); i != args.end(); ++i) { - split_path sp; - file_path_external(*i).split(sp); - file_path fp(sp); - + file_path fp = file_path_external(*i); require_path_is_nonexistent (fp, F("directory '%s' already exists") % fp); - //we'll treat this as a user (fatal) error. it really - //wouldn't make sense to add a dir to .mtn-ignore and then - //try to add it to the project with a mkdir statement, but - //one never can tell... + // we'll treat this as a user (fatal) error. it really wouldn't make + // sense to add a dir to .mtn-ignore and then try to add it to the + // project with a mkdir statement, but one never can tell... N(app.opts.no_ignore || !app.lua.hook_ignore_file(fp), F("ignoring directory '%s' [see .mtn-ignore]") % fp); - paths.insert(sp); + paths.insert(fp); } - //this time, since we've verified that there should be no collisions, - //we'll just go ahead and do the filesystem additions. - for (path_set::const_iterator i = paths.begin(); - i != paths.end(); ++i) - { - mkdir_p(file_path(*i)); - } + // this time, since we've verified that there should be no collisions, + // we'll just go ahead and do the filesystem additions. + for (set::const_iterator i = paths.begin(); i != paths.end(); ++i) + mkdir_p(*i); app.work.perform_additions(paths, false, !app.opts.no_ignore); } @@ -384,14 +376,15 @@ CMD(add, "add", "", CMD_REF(workspace), app.require_workspace(); - path_set paths; + vector roots = args_to_paths(args); + + set paths; bool add_recursive = app.opts.recursive; if (app.opts.unknown) { - vector roots = args_to_paths(args); path_restriction mask(roots, args_to_paths(app.opts.exclude_patterns), app.opts.depth, app); - path_set ignored; + set ignored; // if no starting paths have been specified use the workspace root if (roots.empty()) @@ -402,7 +395,7 @@ CMD(add, "add", "", CMD_REF(workspace), app.work.perform_additions(ignored, add_recursive, !app.opts.no_ignore); } else - split_paths(args_to_paths(args), paths); + paths = set(roots.begin(), roots.end()); app.work.perform_additions(paths, add_recursive, !app.opts.no_ignore); } @@ -417,7 +410,7 @@ CMD(drop, "drop", "rm", CMD_REF(workspac app.require_workspace(); - path_set paths; + set paths; if (app.opts.missing) { temp_node_id_source nis; @@ -430,7 +423,10 @@ CMD(drop, "drop", "rm", CMD_REF(workspac app.work.find_missing(current_roster_shape, mask, paths); } else - split_paths(args_to_paths(args), paths); + { + vector roots = args_to_paths(args); + paths = set(roots.begin(), roots.end()); + } app.work.perform_deletions(paths, app.opts.recursive, app.opts.bookkeep_only); } ============================================================ --- work.cc ba49d44159b566894eafbc7db222b1716505dbb2 +++ work.cc 7427fd015f653a597c9cad80c763f4053424d707 @@ -472,12 +472,14 @@ struct file_itemizer : public tree_walke { database & db; lua_hooks & lua; - path_set & known; - path_set & unknown; - path_set & ignored; + set & known; + set & unknown; + set & ignored; path_restriction const & mask; file_itemizer(database & db, lua_hooks & lua, - path_set & k, path_set & u, path_set & i, + set & k, + set & u, + set & i, path_restriction const & r) : db(db), lua(lua), known(k), unknown(u), ignored(i), mask(r) {} virtual bool visit_dir(file_path const & path); @@ -489,24 +491,18 @@ file_itemizer::visit_dir(file_path const file_itemizer::visit_dir(file_path const & path) { this->visit_file(path); - - split_path sp; - path.split(sp); - return known.find(sp) != known.end(); + return known.find(path) != known.end(); } void file_itemizer::visit_file(file_path const & path) { - split_path sp; - path.split(sp); - - if (mask.includes(sp) && known.find(sp) == known.end()) + if (mask.includes(path) && known.find(path) == known.end()) { if (lua.hook_ignore_file(path) || db.is_dbfile(path)) - ignored.insert(sp); + ignored.insert(path); else - unknown.insert(sp); + unknown.insert(path); } } @@ -514,17 +510,17 @@ struct workspace_itemizer : public tree_ struct workspace_itemizer : public tree_walker { roster_t & roster; - path_set const & known; + set const & known; node_id_source & nis; - workspace_itemizer(roster_t & roster, path_set const & paths, + workspace_itemizer(roster_t & roster, set const & paths, node_id_source & nis); virtual bool visit_dir(file_path const & path); virtual void visit_file(file_path const & path); }; workspace_itemizer::workspace_itemizer(roster_t & roster, - path_set const & paths, + set const & paths, node_id_source & nis) : roster(roster), known(paths), nis(nis) { @@ -541,7 +537,7 @@ workspace_itemizer::visit_dir(file_path path.split(sp); node_id nid = roster.create_dir_node(nis); roster.attach_node(nid, sp); - return known.find(sp) != known.end(); + return known.find(path) != known.end(); } void @@ -572,14 +568,12 @@ public: {} virtual bool visit_dir(file_path const & path); virtual void visit_file(file_path const & path); - void add_node_for(split_path const & sp); + void add_node_for(file_path const & path); }; void -addition_builder::add_node_for(split_path const & sp) +addition_builder::add_node_for(file_path const & path) { - file_path path(sp); - node_id nid = the_null_node; switch (get_path_status(path)) { @@ -598,6 +592,8 @@ addition_builder::add_node_for(split_pat } I(nid != the_null_node); + split_path sp; + path.split(sp); er.attach_node(nid, sp); map attrs; @@ -649,8 +645,8 @@ addition_builder::visit_file(file_path c if (!is_dir_t(ros.get_node(prefix))) { N(prefix == sp, - F("cannot add %s, because %s is recorded as a file in the workspace manifest") - % file_path(sp) % file_path(sp)); + F("cannot add %s, because %s is recorded as a file " + "in the workspace manifest") % path % file_path(prefix)); break; } } @@ -1030,15 +1026,16 @@ static void }; // anonymous namespace static void -add_parent_dirs(split_path const & dst, roster_t & ros, node_id_source & nis, +add_parent_dirs(file_path const & dst, roster_t & ros, node_id_source & nis, database & db, lua_hooks & lua) { editable_roster_base er(ros, nis); addition_builder build(db, lua, ros, er); - split_path dirname; + split_path sp, dirname; path_component basename; - dirname_basename(dst, dirname, basename); + dst.split(sp); + dirname_basename(sp, dirname, basename); // FIXME: this is a somewhat odd way to use the builder build.visit_dir(dirname); @@ -1070,9 +1067,9 @@ workspace::classify_roster_paths(roster_ void workspace::classify_roster_paths(roster_t const & ros, - path_set & unchanged, - path_set & changed, - path_set & missing) + set & unchanged, + set & changed, + set & missing) { temp_node_id_source nis; inodeprint_map ipm; @@ -1098,13 +1095,12 @@ workspace::classify_roster_paths(roster_ split_path sp; ros.get_name(nid, sp); - file_path fp(sp); // if this node is a file, check the inodeprint cache for changes if (!is_dir_t(node) && inodeprint_unchanged(ipm, fp)) { - unchanged.insert(sp); + unchanged.insert(fp); continue; } @@ -1114,9 +1110,9 @@ workspace::classify_roster_paths(roster_ if (is_dir_t(node)) { if (directory_exists(fp)) - unchanged.insert(sp); + unchanged.insert(fp); else - missing.insert(sp); + missing.insert(fp); continue; } @@ -1126,13 +1122,13 @@ workspace::classify_roster_paths(roster_ if (ident_existing_file(fp, fid)) { if (file->content == fid) - unchanged.insert(sp); + unchanged.insert(fp); else - changed.insert(sp); + changed.insert(fp); } else { - missing.insert(sp); + missing.insert(fp); } } } @@ -1233,21 +1229,22 @@ workspace::find_missing(roster_t const & void workspace::find_missing(roster_t const & new_roster_shape, node_restriction const & mask, - path_set & missing) + set & missing) { node_map const & nodes = new_roster_shape.all_nodes(); for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i) { node_id nid = i->first; - if (!new_roster_shape.is_root(nid) && mask.includes(new_roster_shape, nid)) + if (!new_roster_shape.is_root(nid) + && mask.includes(new_roster_shape, nid)) { split_path sp; new_roster_shape.get_name(nid, sp); file_path fp(sp); if (!path_exists(fp)) - missing.insert(sp); + missing.insert(fp); } } } @@ -1255,15 +1252,19 @@ workspace::find_unknown_and_ignored(path void workspace::find_unknown_and_ignored(path_restriction const & mask, vector const & roots, - path_set & unknown, path_set & ignored) + set & unknown, + set & ignored) { - path_set known; + path_set known_ps; roster_t new_roster; temp_node_id_source nis; get_current_roster_shape(new_roster, nis); + new_roster.extract_path_set(known_ps); - new_roster.extract_path_set(known); + set known; + for (path_set::const_iterator i = known_ps.begin(); i != known_ps.end(); i++) + known.insert(file_path(*i)); file_itemizer u(db, lua, known, unknown, ignored, mask); for (vector::const_iterator @@ -1274,7 +1275,7 @@ void } void -workspace::perform_additions(path_set const & paths, +workspace::perform_additions(set const & paths, bool recursive, bool respect_ignore) { if (paths.empty()) @@ -1297,28 +1298,27 @@ workspace::perform_additions(path_set co I(new_roster.has_root()); addition_builder build(db, lua, new_roster, er, respect_ignore); - for (path_set::const_iterator i = paths.begin(); i != paths.end(); ++i) + for (set::const_iterator i = paths.begin(); i != paths.end(); ++i) { if (recursive) { // NB.: walk_tree will handle error checking for non-existent paths - walk_tree(file_path(*i), build); + walk_tree(*i, build); } else { - // in the case where we're just handled a set of paths, we use the builder - // in this strange way. - file_path path(*i); - switch (get_path_status(path)) + // in the case where we're just handed a set of paths, we use the + // builder in this strange way. + switch (get_path_status(*i)) { case path::nonexistent: - N(false, F("no such file or directory: '%s'") % path); + N(false, F("no such file or directory: '%s'") % *i); break; case path::file: - build.visit_file(path); + build.visit_file(*i); break; case path::directory: - build.visit_dir(path); + build.visit_dir(*i); break; } } @@ -1348,7 +1348,7 @@ void } void -workspace::perform_deletions(path_set const & paths, +workspace::perform_deletions(set const & paths, bool recursive, bool bookkeep_only) { if (paths.empty()) @@ -1363,21 +1363,22 @@ workspace::perform_deletions(path_set co get_parent_rosters(parents); // we traverse the the paths backwards, so that we always hit deep paths - // before shallow paths (because path_set is lexicographically sorted). - // this is important in cases like + // before shallow paths (because set is lexicographically + // sorted). this is important in cases like // monotone drop foo/bar foo foo/baz // where, when processing 'foo', we need to know whether or not it is empty // (and thus legal to remove) - deque todo; - path_set::const_reverse_iterator i = paths.rbegin(); + deque todo; + set::const_reverse_iterator i = paths.rbegin(); todo.push_back(*i); ++i; while (todo.size()) { - split_path &p(todo.front()); - file_path name(p); + file_path const & name(todo.front()); + split_path p; + name.split(p); E(!name.empty(), F("unable to drop the root directory")); @@ -1396,22 +1397,20 @@ workspace::perform_deletions(path_set co F("cannot remove %s/, it is not empty") % name); for (dir_map::const_iterator j = d->children.begin(); j != d->children.end(); ++j) - { - split_path sp = p; - sp.push_back(j->first); - todo.push_front(sp); - } + todo.push_front(name / j->first()); continue; } } - if (!bookkeep_only && path_exists(name) && in_parent_roster(parents, n->self)) + if (!bookkeep_only && path_exists(name) + && in_parent_roster(parents, n->self)) { if (is_dir_t(n)) { if (directory_empty(name)) delete_file_or_dir_shallow(name); else - W(F("directory %s not empty - it will be dropped but not deleted") % name); + W(F("directory %s not empty - " + "it will be dropped but not deleted") % name); } else { @@ -1421,7 +1420,8 @@ workspace::perform_deletions(path_set co if (file->content == fid) delete_file_or_dir_shallow(name); else - W(F("file %s changed - it will be dropped but not deleted") % name); + W(F("file %s changed - " + "it will be dropped but not deleted") % name); } } P(F("dropping %s from workspace manifest") % name); @@ -1641,7 +1641,7 @@ workspace::perform_content_update(cset c { roster_t roster; temp_node_id_source nis; - path_set known; + path_set known_ps; roster_t new_roster; bookkeeping_path detached = path_for_detached_nids(); @@ -1651,8 +1651,12 @@ workspace::perform_content_update(cset c % detached); get_current_roster_shape(new_roster, nis); - new_roster.extract_path_set(known); + new_roster.extract_path_set(known_ps); + set known; + for (path_set::const_iterator i = known_ps.begin(); i != known_ps.end(); i++) + known.insert(file_path(*i)); + workspace_itemizer itemizer(roster, known, nis); walk_tree(file_path(), itemizer); ============================================================ --- work.hh 8797491e6dd9884bbbb4a76dc00e87b5dfd9f7f9 +++ work.hh 34a9af24a7439e5edb50a28a12bd10a11d8010f2 @@ -71,17 +71,18 @@ struct workspace { void find_missing(roster_t const & new_roster_shape, node_restriction const & mask, - path_set & missing); + std::set & missing); void find_unknown_and_ignored(path_restriction const & mask, std::vector const & roots, - path_set & unknown, path_set & ignored); + std::set & unknown, + std::set & ignored); - void perform_additions(path_set const & targets, + void perform_additions(std::set const & targets, bool recursive = false, bool respect_ignore = true); - void perform_deletions(path_set const & targets, bool recursive, + void perform_deletions(std::set const & targets, bool recursive, bool bookkeep_only); void perform_rename(std::set const & src_paths, @@ -126,9 +127,9 @@ struct workspace // 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, - path_set & missing); + std::set & unchanged, + std::set & changed, + std::set & missing); // This updates the file-content hashes in ROSTER, which is assumed to be // the "current" roster returned by one of the above get_*_roster_shape