# # patch "commands.cc" # from [4bfb60b6633e6f3356285330228ae08d6fc15df9] # to [aa8e0a70612deaf609ae2e3434134f6093bebf0a] # # patch "work.cc" # from [53b12eecef51f3b52858f82796a917b775f660f8] # to [89675c09b108ac461d5f2ae5e687a1ab7ad95d42] # # patch "work.hh" # from [d5acb63e57d1c10431bf74bfded502517a8ef8a4] # to [eca715d5497910ca4852c123b099768634315014] # ======================================================================== --- commands.cc 4bfb60b6633e6f3356285330228ae08d6fc15df9 +++ commands.cc aa8e0a70612deaf609ae2e3434134f6093bebf0a @@ -1188,11 +1188,9 @@ update_any_attrs(app); } -static void find_missing (app_state & app, vector const & args, path_set & missing); +static void find_missing (app_state & app, + vector const & args, path_set & missing); -/* -FIXME_ROSTERS - CMD(drop, N_("working copy"), N_("[PATH]..."), N_("drop files from working copy"), OPT_EXECUTE % OPT_MISSING) { @@ -1201,32 +1199,36 @@ app.require_working_copy(); - manifest_map m_old; - get_base_manifest(app, m_old); + revision_id base_rid; + roster_t base_roster; + cset work; + + get_base_revision(app, base_rid, base_roster); + get_work_cset(work); - change_set::path_rearrangement work; - get_path_rearrangement(work); - - vector paths; + path_set paths; if (app.missing) - { - set missing; - find_missing(app, args, missing); - paths.insert(paths.end(), missing.begin(), missing.end()); - } + find_missing(app, args, paths); + else + for (vector::const_iterator i = args.begin(); i != args.end(); ++i) + { + split_path sp; + file_path_external(*i).split(sp); + paths.insert(sp); + } - for (vector::const_iterator i = args.begin(); i != args.end(); ++i) - paths.push_back(file_path_external(*i)); + build_deletions(paths, base_roster, app, work); - build_deletions(paths, m_old, app, work); + put_work_cset(work); - put_path_rearrangement(work); - update_any_attrs(app); } ALIAS(rm, drop); +/* +FIXME_ROSTERS + CMD(rename, N_("working copy"), N_("SRC DST"), N_("rename entries in the working copy"), OPT_EXECUTE) ======================================================================== --- work.cc 53b12eecef51f3b52858f82796a917b775f660f8 +++ work.cc 89675c09b108ac461d5f2ae5e687a1ab7ad95d42 @@ -152,104 +152,54 @@ make_cset(base_roster, new_roster, work); } -/* -// FIXME_ROSTERS: disabled until rewritten to use rosters - -static bool -known_path(file_path const & p, - path_set const & ps, - bool & path_is_directory) -{ - std::string path_as_dir = p.as_internal() + "/"; - for (path_set::const_iterator i = ps.begin(); i != ps.end(); ++i) - { - if (*i == p) - { - path_is_directory = false; - return true; - } - else if (i->as_internal().find(path_as_dir) == 0) - { - path_is_directory = true; - return true; - } - } - return false; -} - void -build_deletions(vector const & paths, - manifest_map const & man, +build_deletions(path_set const & paths, + roster_t const & base_roster, app_state & app, - change_set::path_rearrangement & pr) + cset & work) { - change_set::path_rearrangement pr_new, pr_concatenated; - path_set ps; - extract_path_set(man, ps); - apply_path_rearrangement(pr, ps); + temp_node_id_source nis; + roster_t new_roster(base_roster); + editable_roster_base er(new_roster, nis); - // read attribute map if available - file_path attr_path; - get_attr_path(attr_path); + work.apply_to(er); - data attr_data; - attr_map attrs; + // 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 + // 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) - if (path_exists(attr_path)) - { - read_data(attr_path, attr_data); - read_attr_map(attr_data, attrs); - } - - bool updated_attr_map = false; - - for (vector::const_iterator i = paths.begin(); i != paths.end(); ++i) + for (path_set::const_reverse_iterator i = paths.rbegin(); i != paths.rend(); ++i) { - bool dir_p = false; - - N(!i->empty(), F("invalid path ''")); + file_path name(*i); - if (! known_path(*i, ps, dir_p)) + if (!new_roster.has_node(*i)) + P(F("skipping %s, not currently tracked\n") % name); + else { - P(F("skipping %s, not currently tracked\n") % *i); - continue; - } - - P(F("adding %s to working copy delete set\n") % *i); - - if (dir_p) - { - E(false, F("sorry -- 'drop ' is currently broken.\n" - "try 'find %s -type f | monotone drop address@hidden'\n") % (*i)); - pr_new.deleted_dirs.insert(*i); - } - else - { - pr_new.deleted_files.insert(*i); - - // delete any associated attributes for this file - if (1 == attrs.erase(*i)) + node_t n = new_roster.get_node(*i); + if (is_dir_t(n)) { - updated_attr_map = true; - P(F("dropped attributes for file %s from %s\n") % (*i) % attr_file_name); + dir_t d = downcast_to_dir_t(n); + N(d->children.empty(), + F("cannot remove %s/, it is not empty") % name); } - if (app.execute && path_exists(*i)) - delete_file(*i); + P(F("adding %s to working copy delete set\n") % name); + node_id nid = new_roster.detach_node(*i); + I(nid == n->self); + new_roster.drop_detached_node(nid); } - } + } - normalize_path_rearrangement(pr_new); - concatenate_rearrangements(pr, pr_new, pr_concatenated); - pr = pr_concatenated; - - // write out updated map if necessary - if (updated_attr_map) - { - write_attr_map(attr_data, attrs); - write_data(attr_path, attr_data); - } + work.clear(); + make_cset(base_roster, new_roster, work); } +/* +// FIXME_ROSTERS: disabled until rewritten to use rosters + void build_rename(file_path const & src, file_path const & dst, ======================================================================== --- work.hh d5acb63e57d1c10431bf74bfded502517a8ef8a4 +++ work.hh eca715d5497910ca4852c123b099768634315014 @@ -66,15 +66,15 @@ app_state & app, cset & work); -/* -// FIXME_ROSTERS: disabled until rewritten to use rosters - void -build_deletions(std::vector const & args, - manifest_map const & m_old, +build_deletions(path_set const & targets, + roster_t const & base_roster, app_state & app, - change_set::path_rearrangement & pr); + cset & work); +/* +// FIXME_ROSTERS: disabled until rewritten to use rosters + void build_rename(file_path const & src, file_path const & dst,