# # patch "commands.cc" # from [4bfb60b6633e6f3356285330228ae08d6fc15df9] # to [7383884b486b17b0f6583a1b1a72d664e1c7dba2] # # patch "file_io.cc" # from [c328d2b14c072a853193222e836c5c4346a5f7c0] # to [ca4f1238f56c5fe6e55818f7d3e9b1b884ca7655] # # patch "restrictions.cc" # from [d8b858b9238bbdfcc874f17e0a8e342e3d520f5d] # to [e981dacae501e71af4c63b76d7b11b15295079d8] # # patch "roster.cc" # from [8c1ac29a4f3b2b2615accc8cbf32f669b62b9574] # to [f9d2876167485c049868abf1469f511779bab613] # # patch "roster.hh" # from [356168d5db89209841dfafc57a7b47fc708a9753] # to [540bab23bbee347f656926418b3c03a062091d00] # # patch "transforms.cc" # from [1873cfe37c0fb510e5129bb11e6358df5f8beaeb] # to [2ac91b4236887a082140fd0199ef0019c4bba67d] # # patch "work.cc" # from [53b12eecef51f3b52858f82796a917b775f660f8] # to [4e1526619651c3dc22f2ad082606acbbfae68445] # ======================================================================== --- commands.cc 4bfb60b6633e6f3356285330228ae08d6fc15df9 +++ commands.cc 7383884b486b17b0f6583a1b1a72d664e1c7dba2 @@ -1718,7 +1718,6 @@ app.require_working_copy(); - get_base_roster_and_working_cset(app, args, base_rid, base_roster, old_paths, new_paths, included_work, excluded_work); ======================================================================== --- file_io.cc c328d2b14c072a853193222e836c5c4346a5f7c0 +++ file_io.cc ca4f1238f56c5fe6e55818f7d3e9b1b884ca7655 @@ -456,9 +456,6 @@ } -void -tree_walker::visit_dir(file_path const & path) {} - tree_walker::~tree_walker() {} static void @@ -516,6 +513,12 @@ } } +void +tree_walker::visit_dir(file_path const & path) +{ +} + + // from some (safe) sub-entry of cwd void walk_tree(file_path const & path, ======================================================================== --- restrictions.cc d8b858b9238bbdfcc874f17e0a8e342e3d520f5d +++ restrictions.cc e981dacae501e71af4c63b76d7b11b15295079d8 @@ -197,7 +197,13 @@ *cs, excluded); calculate_ident(old_roster, old_manifest_id); - build_restricted_roster(new_paths, old_roster, new_roster, app); + + temp_node_id_source nis; + new_roster = old_roster; + editable_roster_base er(new_roster, nis); + cs->apply_to(er); + + update_restricted_roster_from_filesystem(new_roster, app); calculate_ident(new_roster, rev.new_manifest); L(F("new manifest_id is %s\n") % rev.new_manifest); ======================================================================== --- roster.cc 8c1ac29a4f3b2b2615accc8cbf32f669b62b9574 +++ roster.cc f9d2876167485c049868abf1469f511779bab613 @@ -1719,13 +1719,10 @@ } void -build_restricted_roster(path_set const & paths, - roster_t const & r_old, - roster_t & r_new, - app_state & app) +update_restricted_roster_from_filesystem(roster_t & ros, + app_state & app) { temp_node_id_source nis; - r_new = r_old; inodeprint_map ipm; if (in_inodeprints_mode()) @@ -1740,15 +1737,23 @@ // this code is speed critical, hence the use of inode fingerprints so be // careful when making changes in here and preferably do some timing tests - for (path_set::const_iterator i = paths.begin(); i != paths.end(); ++i) + if (!ros.has_root()) + return; + + node_map const & nodes = ros.all_nodes(); + for (node_map::const_iterator i = nodes.begin(); + i != nodes.end(); ++i) { - node_t new_n = r_new.get_node(*i); + node_id nid = i->first; + node_t node = i->second; // Only analyze files further, not dirs. - if (! is_file_t(new_n)) + if (! is_file_t(node)) continue; - file_path fp(*i); + split_path sp; + ros.get_name(nid, sp); + file_path fp(sp); // Only analyze restriction-included files. if (!app.restriction_includes(fp)) @@ -1759,8 +1764,8 @@ if (inodeprint_unchanged(ipm, fp)) continue; - file_t new_f = downcast_to_file_t(new_n); - if (!ident_existing_file(fp, new_f->content, app.lua)) + file_t file = downcast_to_file_t(node); + if (!ident_existing_file(fp, file->content, app.lua)) { W(F("missing %s") % (fp)); missing_files++; @@ -1773,23 +1778,24 @@ "'monotone drop FILE' to remove it permanently, or\n" "'monotone revert FILE' to restore it\n") % missing_files); - } void roster_t::extract_path_set(path_set & paths) const { paths.clear(); - I(has_root()); - for (dfs_iter i(root_dir); !i.finished(); ++i) + if (has_root()) { - node_t curr = *i; - split_path pth; - get_name(curr->self, pth); - if (pth.size() == 1) - I(null_name(idx(pth,0))); - else - paths.insert(pth); + for (dfs_iter i(root_dir); !i.finished(); ++i) + { + node_t curr = *i; + split_path pth; + get_name(curr->self, pth); + if (pth.size() == 1) + I(null_name(idx(pth,0))); + else + paths.insert(pth); + } } } ======================================================================== --- roster.hh 356168d5db89209841dfafc57a7b47fc708a9753 +++ roster.hh 540bab23bbee347f656926418b3c03a062091d00 @@ -272,10 +272,8 @@ cset & cs); void -build_restricted_roster(path_set const & paths, - roster_t const & r_old, - roster_t & r_new, - app_state & app); +update_restricted_roster_from_filesystem(roster_t & ros, + app_state & app); void extract_roster_path_set(roster_t const & ros, ======================================================================== --- transforms.cc 1873cfe37c0fb510e5129bb11e6358df5f8beaeb +++ transforms.cc 2ac91b4236887a082140fd0199ef0019c4bba67d @@ -330,8 +330,11 @@ { data tmp; hexenc tid; - write_manifest_of_roster(ros, tmp); - calculate_ident(tmp, tid); + if (!ros.all_nodes().empty()) + { + write_manifest_of_roster(ros, tmp); + calculate_ident(tmp, tid); + } ident = tid; } ======================================================================== --- work.cc 53b12eecef51f3b52858f82796a917b775f660f8 +++ work.cc 4e1526619651c3dc22f2ad082606acbbfae68445 @@ -63,9 +63,46 @@ {} virtual void visit_dir(file_path const & path); virtual void visit_file(file_path const & path); + void add_node_for(split_path const & sp); }; void +addition_builder::add_node_for(split_path const & sp) +{ + file_path path(sp); + + node_id nid = the_null_node; + switch (get_path_status(path)) + { + case path::nonexistent: + return; + case path::file: + { + file_id ident; + I(ident_existing_file(path, ident, app.lua)); + nid = er.create_file_node(ident); + } + break; + case path::directory: + nid = er.create_dir_node(); + break; + } + + I(nid != the_null_node); + er.attach_node(nid, sp); + + map attrs; + app.lua.hook_init_attributes(path, attrs); + if (attrs.size() > 0) + { + for (map::const_iterator i = attrs.begin(); + i != attrs.end(); ++i) + er.set_attr(sp, attr_key(i->first), attr_value(i->second)); + } +} + + +void addition_builder::visit_dir(file_path const & path) { this->visit_file(path); @@ -90,36 +127,21 @@ P(F("adding %s to working copy add set\n") % path); - node_id nid = the_null_node; - switch (get_path_status(path)) + split_path dirname, prefix; + path_component basename; + dirname_basename(sp, dirname, basename); + I(ros.has_root()); + for (split_path::const_iterator i = dirname.begin(); i != dirname.end(); + ++i) { - case path::nonexistent: - return; - case path::file: - { - file_id ident; - I(ident_existing_file(path, ident, app.lua)); - nid = er.create_file_node(ident); - } - break; - case path::directory: - nid = er.create_dir_node(); - break; + prefix.push_back(*i); + if (i == dirname.begin()) + continue; + if (!ros.has_node(prefix)) + add_node_for(prefix); } - I(nid != the_null_node); - er.attach_node(nid, sp); - - map attrs; - app.lua.hook_init_attributes(path, attrs); - if (attrs.size() > 0) - { - for (map::const_iterator i = attrs.begin(); - i != attrs.end(); ++i) - { - er.set_attr(sp, attr_key(i->first), attr_value(i->second)); - } - } + add_node_for(sp); } void