# # # patch "ChangeLog" # from [22ea2b7a70f2e65d3bc70b5f78785f38d052a994] # to [63b7efc47b89d714ed924eb4913381a77ca99ca2] # # patch "cmd_merging.cc" # from [4b53137d9efd6b8aab42639c05774cf34c562c4c] # to [2ffc506db55287542ea8ecf0adff067e00e4ef89] # # patch "diff_patch.cc" # from [eecf25071f8d089506b15358c160d018b18b0d07] # to [efa59b899d706e7bfdd2b3cca433eed5ebf844bb] # # patch "diff_patch.hh" # from [e1a61d6117d79bec3584a14d3994652911dd5ee7] # to [304204467c83bbf6a4e0563dbd25efbcba96f1ae] # # patch "work.cc" # from [5bf18d1b155da4c7816e3e82ad2fd82b35cb1336] # to [b18478ed77c1795975b7f8e35c963faa14bacff3] # ============================================================ --- ChangeLog 22ea2b7a70f2e65d3bc70b5f78785f38d052a994 +++ ChangeLog 63b7efc47b89d714ed924eb4913381a77ca99ca2 @@ -1,3 +1,22 @@ +2007-02-08 Derek Scherger + + * cmd_merging.cc (get_content_paths): new function + (update): + (pluck): put paths by content hash into workspace adapter + * diff_patch.{cc,hh} (content_merge_adaptor::get_version): remove + path argument from interface + (content_merge_workspace_adaptor): add map of paths by content + hash to workspace adaptor + (content_merge_workspace_adaptor::get_version): get path from map + * work.cc (attr_file_name): remove unused var + (editable_working_tree::written_content): remove + (content_merge_empty_adaptor::get_version): remove path argument + (editable_working_tree::create_file_node): write file content here + rather than deferring it to attach_node + (editable_working_tree::attach_node): remove deferred file content + (editable_working_tree::apply_delta): remove path argument from + get_version call + 2007-02-08 Zack Weinberg * configure.ac: Stick some goo in config.status to kill ============================================================ --- cmd_merging.cc 4b53137d9efd6b8aab42639c05774cf34c562c4c +++ cmd_merging.cc 2ffc506db55287542ea8ecf0adff067e00e4ef89 @@ -23,6 +23,7 @@ using std::cout; #include "safe_map.hh" using std::cout; +using std::make_pair; using std::map; using std::set; using std::string; @@ -69,6 +70,23 @@ three_way_merge(roster_t const & ancesto right_roster, right_markings, right_uncommon_ancestors, result); } + +static void +get_content_paths(roster_t const & roster, map & paths) +{ + node_map const & nodes = roster.all_nodes(); + for (node_map::const_iterator i = nodes.begin(); i != nodes.end(); ++i) + { + node_t node = roster.get_node(i->first); + if (is_file_t(node)) + { + split_path sp; + roster.get_name(i->first, sp); + file_t file = downcast_to_file_t(node); + paths.insert(make_pair(file->content, file_path(sp))); + } + } +} CMD(update, N_("workspace"), "", N_("update workspace.\n" @@ -224,7 +242,10 @@ CMD(update, N_("workspace"), "", roster_t & merged_roster = result.roster; - content_merge_workspace_adaptor wca(app, old_roster); + map paths; + get_content_paths(working_roster, paths); + + content_merge_workspace_adaptor wca(app, old_roster, paths); resolve_merge_conflicts(working_roster, chosen_roster, result, wca, app); @@ -763,7 +784,10 @@ CMD(pluck, N_("workspace"), N_("[-r FROM roster_t & merged_roster = result.roster; - content_merge_workspace_adaptor wca(app, from_roster); + map paths; + get_content_paths(working_roster, paths); + + content_merge_workspace_adaptor wca(app, from_roster, paths); resolve_merge_conflicts(working_roster, to_roster, result, wca, app); ============================================================ --- diff_patch.cc eecf25071f8d089506b15358c160d018b18b0d07 +++ diff_patch.cc efa59b899d706e7bfdd2b3cca433eed5ebf844bb @@ -560,8 +560,7 @@ void } void -content_merge_database_adaptor::get_version(file_path const & path, - file_id const & ident, +content_merge_database_adaptor::get_version(file_id const & ident, file_data & dat) const { app.db.get_file_version(ident, dat); @@ -597,8 +596,7 @@ void } void -content_merge_workspace_adaptor::get_version(file_path const & path, - file_id const & ident, +content_merge_workspace_adaptor::get_version(file_id const & ident, file_data & dat) const { map::const_iterator i = temporary_store.find(ident); @@ -610,14 +608,17 @@ content_merge_workspace_adaptor::get_ver { data tmp; file_id fid; - require_path_is_file(path, - F("file '%s' does not exist in workspace") % path, - F("'%s' in workspace is a directory, not a file") % path); - read_data(path, tmp); + map::const_iterator i = content_paths.find(ident); + I(i != content_paths.end()); + + require_path_is_file(i->second, + F("file '%s' does not exist in workspace") % i->second, + F("'%s' in workspace is a directory, not a file") % i->second); + read_data(i->second, tmp); calculate_ident(file_data(tmp), fid); E(fid == ident, F("file %s in workspace has id %s, wanted %s") - % path % fid % ident); + % i->second % fid % ident); dat = file_data(tmp); } } @@ -693,9 +694,9 @@ content_merger::try_to_merge_files(file_ file_data left_data, right_data, ancestor_data; data left_unpacked, ancestor_unpacked, right_unpacked, merged_unpacked; - adaptor.get_version(left_path, left_id, left_data); - adaptor.get_version(anc_path, ancestor_id, ancestor_data); - adaptor.get_version(right_path, right_id, right_data); + adaptor.get_version(left_id, left_data); + adaptor.get_version(ancestor_id, ancestor_data); + adaptor.get_version(right_id, right_data); left_unpacked = left_data.inner(); ancestor_unpacked = ancestor_data.inner(); ============================================================ --- diff_patch.hh e1a61d6117d79bec3584a14d3994652911dd5ee7 +++ diff_patch.hh 304204467c83bbf6a4e0563dbd25efbcba96f1ae @@ -55,8 +55,7 @@ content_merge_adaptor virtual void get_ancestral_roster(node_id nid, boost::shared_ptr & anc) = 0; - virtual void get_version(file_path const & path, - file_id const & ident, + virtual void get_version(file_id const & ident, file_data & dat) const = 0; virtual ~content_merge_adaptor() {} @@ -83,8 +82,7 @@ content_merge_database_adaptor void get_ancestral_roster(node_id nid, boost::shared_ptr & anc); - void get_version(file_path const & path, - file_id const & ident, + void get_version(file_id const & ident, file_data & dat) const; }; @@ -95,9 +93,11 @@ content_merge_workspace_adaptor std::map temporary_store; app_state & app; boost::shared_ptr base; + std::map content_paths; content_merge_workspace_adaptor (app_state & app, - boost::shared_ptr base) - : app(app), base(base) + boost::shared_ptr base, + std::map const & paths) + : app(app), base(base), content_paths(paths) {} void record_merge(file_id const & left_ident, file_id const & right_ident, @@ -108,8 +108,7 @@ content_merge_workspace_adaptor void get_ancestral_roster(node_id nid, boost::shared_ptr & anc); - void get_version(file_path const & path, - file_id const & ident, + void get_version(file_id const & ident, file_data & dat) const; }; ============================================================ --- work.cc 5bf18d1b155da4c7816e3e82ad2fd82b35cb1336 +++ work.cc b18478ed77c1795975b7f8e35c963faa14bacff3 @@ -41,7 +41,6 @@ using boost::lexical_cast; // workspace / book-keeping file code -static string const attr_file_name(".mt-attrs"); static string const inodeprints_file_name("inodeprints"); static string const local_dump_file_name("debug"); static string const options_file_name("options"); @@ -637,7 +636,6 @@ private: lua_hooks & lua; content_merge_adaptor const & source; node_id next_nid; - std::map written_content; std::map rename_add_drop_map; bool root_dir_attached; }; @@ -679,8 +677,7 @@ struct content_merge_empty_adaptor : pub struct content_merge_empty_adaptor : public content_merge_adaptor { - virtual void get_version(file_path const &, - file_id const &, file_data &) const + virtual void get_version(file_id const &, file_data &) const { I(false); } virtual void record_merge(file_id const &, file_id const &, file_id const &, file_data const &, @@ -773,9 +770,10 @@ editable_working_tree::create_file_node( bookkeeping_path pth = path_for_nid(nid); require_path_is_nonexistent(pth, F("path %s already exists") % pth); - safe_insert(written_content, make_pair(pth, content)); - // Defer actual write to moment of attachment, when we know the path - // and can thus determine encoding / linesep convention. + file_data dat; + source.get_version(content, dat); + write_data(pth, dat.inner()); + return nid; } @@ -785,39 +783,6 @@ editable_working_tree::attach_node(node_ bookkeeping_path src_pth = path_for_nid(nid); file_path dst_pth(dst); - // Possibly just write data out into the workspace, if we're doing - // a file-create (not a dir-create or file/dir rename). - if (!path_exists(src_pth)) - { - I(root_dir_attached); - map::const_iterator i - = written_content.find(src_pth); - if (i != written_content.end()) - { - P(F("adding %s") % dst_pth); - file_data dat; - source.get_version(dst_pth, i->second, dat); - write_data(dst_pth, dat.inner()); - return; - } - } - - // FIXME: it is weird to do this here, instead of up above, but if we do it - // up above a lot of tests break. those tests are arguably broken -- they - // depend on 'update' clobbering existing, non-versioned files -- but - // putting this up there doesn't actually help, since if we abort in the - // middle of an update to avoid clobbering a file, we just end up leaving - // the working copy in an inconsistent state instead. so for now, we leave - // this check down here. - // where are "here" and "there" ?!? - - if (!workspace_root(dst)) - { - require_path_is_nonexistent(dst_pth, - F("path '%s' already exists, cannot create") % dst_pth); - } - - // If we get here, we're doing a file/dir rename, or a dir-create. map::const_iterator i = rename_add_drop_map.find(src_pth); if (i != rename_add_drop_map.end()) @@ -868,7 +833,7 @@ editable_working_tree::apply_delta(split P(F("modifying %s") % pth_unsplit); file_data dat; - source.get_version(pth_unsplit, new_id, dat); + source.get_version(new_id, dat); write_data(pth_unsplit, dat.inner()); }