# # # patch "automate.cc" # from [890d5b9b5d5929fac891089537877a2a83079467] # to [f3d75e458c1433e8c92877ef561830eac4bb3218] # # patch "cmd_diff_log.cc" # from [bd55c33e185979f03a6e5fe2d32188fac1dc0676] # to [2048454892054bae9414c4bb68924a31a942a55e] # # patch "cmd_list.cc" # from [622ac9ea93b781409604baa769cecad53a425e10] # to [3f8c3e27d4840eae7b4e729cb95f6991b601015f] # # patch "cmd_merging.cc" # from [d0cda85b132150409d50526aa1d38c001932866d] # to [2c3c295183c941c09ec25ad653c2d91ee1a13887] # # patch "cmd_ws_commit.cc" # from [ac1a5188bbc4545b8c1b17bebfada1e702349981] # to [5dd6669d7605204ce2d0707460eba3ce3355e417] # # patch "restrictions.cc" # from [3d9ac89c1367e0d40b1c197f39b8df1c7af316d0] # to [ec1b1645553b23e0daca1d3ca88baa415fdaf985] # # patch "restrictions.hh" # from [d588f4ba6876b51d61d3f37f4836bf2272434310] # to [e93a80c46b2d9e82263c988e4742c2e55e702803] # # patch "work.cc" # from [0bc477ba2407659797f6ea6d907012686f2390ec] # to [bb21460bb9c30ff19c93e378cdf5706cca93e30e] # # patch "work.hh" # from [e42fa101dd8ccc458f2170ace6e04b40c8f0fffc] # to [def9c5b6c7776dfa16c2bc9c0b83bc493ef56b04] # ============================================================ --- automate.cc 890d5b9b5d5929fac891089537877a2a83079467 +++ automate.cc f3d75e458c1433e8c92877ef561830eac4bb3218 @@ -638,16 +638,15 @@ struct inventory_itemizer : public tree_ { path_restriction const & mask; inventory_map & inventory; - app_state & app; inodeprint_map ipm; - inventory_itemizer(path_restriction const & m, inventory_map & i, app_state & a) : - mask(m), inventory(i), app(a) + inventory_itemizer(path_restriction const & m, inventory_map & i, workspace & w) : + mask(m), inventory(i) { - if (app.work.in_inodeprints_mode()) + if (w.in_inodeprints_mode()) { data dat; - app.work.read_inodeprints(dat); + w.read_inodeprints(dat); read_inodeprint_map(dat, ipm); } } @@ -686,9 +685,9 @@ static void } static void -inventory_filesystem(path_restriction const & mask, inventory_map & inventory, app_state & app) +inventory_filesystem(path_restriction const & mask, inventory_map & inventory, workspace & work) { - inventory_itemizer itemizer(mask, inventory, app); + inventory_itemizer itemizer(mask, inventory, work); file_path const root; // The constructor file_path() returns ""; the root directory. walk_tree // does not visit that node, so set fs_type now, if it meets the @@ -878,11 +877,11 @@ CMD_AUTOMATE(inventory, N_("[PATH]...") vector includes = args_to_paths(args); vector excludes = args_to_paths(app.opts.exclude_patterns); - node_restriction nmask(includes, excludes, app.opts.depth, old_roster, new_roster, app); + node_restriction nmask(includes, excludes, app.opts.depth, old_roster, new_roster, app.work); inventory_rosters(old_roster, new_roster, nmask, inventory); - path_restriction pmask(includes, excludes, app.opts.depth, app); - inventory_filesystem(pmask, inventory, app); + path_restriction pmask(includes, excludes, app.opts.depth, app.work); + inventory_filesystem(pmask, inventory, app.work); basic_io::printer pr; ============================================================ --- cmd_diff_log.cc bd55c33e185979f03a6e5fe2d32188fac1dc0676 +++ cmd_diff_log.cc 2048454892054bae9414c4bb68924a31a942a55e @@ -376,7 +376,7 @@ prepare_diff(cset & included, node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - old_roster, new_roster, app); + old_roster, new_roster, app.work); app.work.update_current_roster_from_filesystem(new_roster, mask); make_restricted_csets(old_roster, new_roster, @@ -403,7 +403,7 @@ prepare_diff(cset & included, node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - old_roster, new_roster, app); + old_roster, new_roster, app.work); app.work.update_current_roster_from_filesystem(new_roster, mask); make_restricted_csets(old_roster, new_roster, @@ -434,7 +434,7 @@ prepare_diff(cset & included, node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - old_roster, new_roster, app); + old_roster, new_roster, app.work); // FIXME: this is *possibly* a UI bug, insofar as we // look at the restriction name(s) you provided on the command @@ -683,7 +683,7 @@ CMD(log, "log", "", CMD_REF(informative) mask = node_restriction(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), - app.opts.depth, parents, new_roster, app); + app.opts.depth, parents, new_roster, app.work); } else { @@ -694,7 +694,7 @@ CMD(log, "log", "", CMD_REF(informative) mask = node_restriction(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), - app.opts.depth, roster, app); + app.opts.depth, roster, app.work); } } ============================================================ --- cmd_list.cc 622ac9ea93b781409604baa769cecad53a425e10 +++ cmd_list.cc 3f8c3e27d4840eae7b4e729cb95f6991b601015f @@ -360,7 +360,7 @@ CMD(known, "known", "", CMD_REF(list), " node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - new_roster, app); + new_roster, app.work); // to be printed sorted vector print_paths; @@ -394,7 +394,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); + app.opts.depth, app.work); set unknown, ignored; // if no starting paths have been specified use the workspace root @@ -426,7 +426,7 @@ CMD(missing, "missing", "", CMD_REF(list node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - current_roster_shape, app); + current_roster_shape, app.work); set missing; app.work.find_missing(current_roster_shape, mask, missing); @@ -455,7 +455,7 @@ CMD(changed, "changed", "", CMD_REF(list node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - parents, new_roster, app); + parents, new_roster, app.work); revision_t rrev; make_restricted_revision(parents, new_roster, mask, rrev); ============================================================ --- cmd_merging.cc d0cda85b132150409d50526aa1d38c001932866d +++ cmd_merging.cc 2c3c295183c941c09ec25ad653c2d91ee1a13887 @@ -873,7 +873,7 @@ CMD(pluck, "pluck", "", CMD_REF(workspac node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - *from_roster, to_true_roster, app); + *from_roster, to_true_roster, app.work); make_restricted_csets(*from_roster, to_true_roster, from_to_to, from_to_to_excluded, mask); ============================================================ --- cmd_ws_commit.cc ac1a5188bbc4545b8c1b17bebfada1e702349981 +++ cmd_ws_commit.cc 5dd6669d7605204ce2d0707460eba3ce3355e417 @@ -171,7 +171,7 @@ CMD(revert, "revert", "", CMD_REF(worksp node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - old_roster, new_roster, app); + old_roster, new_roster, app.work); if (app.opts.missing) { @@ -197,7 +197,7 @@ CMD(revert, "revert", "", CMD_REF(worksp // replace the original mask with a more restricted one mask = node_restriction(missing_files, std::vector(), app.opts.depth, - old_roster, new_roster, app); + old_roster, new_roster, app.work); } make_restricted_csets(old_roster, new_roster, @@ -385,7 +385,7 @@ CMD(add, "add", "", CMD_REF(workspace), if (app.opts.unknown) { path_restriction mask(roots, args_to_paths(app.opts.exclude_patterns), - app.opts.depth, app); + app.opts.depth, app.work); set ignored; // if no starting paths have been specified use the workspace root @@ -421,7 +421,7 @@ CMD(drop, "drop", "rm", CMD_REF(workspac node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - current_roster_shape, app); + current_roster_shape, app.work); app.work.find_missing(current_roster_shape, mask, paths); } else @@ -504,7 +504,7 @@ CMD(status, "status", "", CMD_REF(inform node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - old_rosters, new_roster, app); + old_rosters, new_roster, app.work); app.work.update_current_roster_from_filesystem(new_roster, mask); make_restricted_revision(old_rosters, new_roster, mask, rev); @@ -1014,7 +1014,7 @@ CMD(commit, "commit", "ci", CMD_REF(work node_restriction mask(args_to_paths(args), args_to_paths(app.opts.exclude_patterns), app.opts.depth, - old_rosters, new_roster, app); + old_rosters, new_roster, app.work); app.work.update_current_roster_from_filesystem(new_roster, mask); make_restricted_revision(old_rosters, new_roster, mask, restricted_rev, ============================================================ --- restrictions.cc 3d9ac89c1367e0d40b1c197f39b8df1c7af316d0 +++ restrictions.cc ec1b1645553b23e0daca1d3ca88baa415fdaf985 @@ -15,7 +15,8 @@ #include "revision.hh" #include "safe_map.hh" #include "transforms.hh" -#include "app_state.hh" +#include "work.hh" +#include "file_io.hh" using std::make_pair; using std::map; @@ -75,7 +76,7 @@ validate_roster_paths(set con validate_roster_paths(set const & included_paths, set const & excluded_paths, set const & known_paths, - app_state & app) + workspace & work) { int bad = 0; @@ -87,7 +88,7 @@ validate_roster_paths(set con // rosters if (known_paths.find(*i) == known_paths.end()) { - if (!app.work.ignore_file(*i)) + if (!work.ignore_file(*i)) { bad++; W(F("restriction includes unknown path '%s'") % *i); @@ -111,7 +112,7 @@ validate_workspace_paths(set void validate_workspace_paths(set const & included_paths, set const & excluded_paths, - app_state & app) + workspace & work) { int bad = 0; @@ -124,7 +125,7 @@ validate_workspace_paths(set // ignored paths are allowed into the restriction but are not // considered invalid if they are found in none of the restriction's // rosters - if (!path_exists(*i) && !app.work.ignore_file(*i)) + if (!path_exists(*i) && !work.ignore_file(*i)) { bad++; W(F("restriction includes unknown path '%s'") % *i); @@ -159,7 +160,7 @@ node_restriction::node_restriction(std:: std::vector const & excludes, long depth, roster_t const & roster, - app_state & a) : + workspace & w) : restriction(includes, excludes, depth) { map_nodes(node_map, roster, included_paths, known_paths, @@ -167,7 +168,7 @@ node_restriction::node_restriction(std:: map_nodes(node_map, roster, excluded_paths, known_paths, restricted_path::excluded); - validate_roster_paths(included_paths, excluded_paths, known_paths, a); + validate_roster_paths(included_paths, excluded_paths, known_paths, w); } node_restriction::node_restriction(std::vector const & includes, @@ -175,7 +176,7 @@ node_restriction::node_restriction(std:: long depth, roster_t const & roster1, roster_t const & roster2, - app_state & a) : + workspace & w) : restriction(includes, excludes, depth) { map_nodes(node_map, roster1, included_paths, known_paths, @@ -188,7 +189,7 @@ node_restriction::node_restriction(std:: map_nodes(node_map, roster2, excluded_paths, known_paths, restricted_path::excluded); - validate_roster_paths(included_paths, excluded_paths, known_paths, a); + validate_roster_paths(included_paths, excluded_paths, known_paths, w); } node_restriction::node_restriction(std::vector const & includes, @@ -196,7 +197,7 @@ node_restriction::node_restriction(std:: long depth, parent_map const & rosters1, roster_t const & roster2, - app_state & a) : + workspace & w) : restriction(includes, excludes, depth) { for (parent_map::const_iterator i = rosters1.begin(); @@ -214,20 +215,20 @@ node_restriction::node_restriction(std:: map_nodes(node_map, roster2, excluded_paths, known_paths, restricted_path::excluded); - validate_roster_paths(included_paths, excluded_paths, known_paths, a); + validate_roster_paths(included_paths, excluded_paths, known_paths, w); } path_restriction::path_restriction(std::vector const & includes, std::vector const & excludes, long depth, - app_state & a) : + workspace & w) : restriction(includes, excludes, depth) { map_paths(path_map, included_paths, restricted_path::included); map_paths(path_map, excluded_paths, restricted_path::excluded); - validate_workspace_paths(included_paths, excluded_paths, a); + validate_workspace_paths(included_paths, excluded_paths, w); } bool @@ -392,7 +393,6 @@ path_restriction::includes(file_path con /////////////////////////////////////////////////////////////////////// #ifdef BUILD_UNIT_TESTS -#include "app_state.hh" #include "unit_tests.hh" #include "roster.hh" #include "sanity.hh" @@ -606,11 +606,11 @@ UNIT_TEST(restrictions, simple_include) includes.push_back(file_path_internal("x/x")); includes.push_back(file_path_internal("y/y")); - app_state app; + workspace work; // check restricted nodes - node_restriction nmask(includes, excludes, -1, roster, app); + node_restriction nmask(includes, excludes, -1, roster, work); UNIT_TEST_CHECK(!nmask.empty()); @@ -640,7 +640,7 @@ UNIT_TEST(restrictions, simple_include) // check restricted paths - path_restriction pmask(includes, excludes, -1, app); + path_restriction pmask(includes, excludes, -1, work); UNIT_TEST_CHECK(!pmask.empty()); @@ -678,11 +678,11 @@ UNIT_TEST(restrictions, simple_exclude) excludes.push_back(file_path_internal("x/x")); excludes.push_back(file_path_internal("y/y")); - app_state app; + workspace work; // check restricted nodes - node_restriction nmask(includes, excludes, -1, roster, app); + node_restriction nmask(includes, excludes, -1, roster, work); UNIT_TEST_CHECK(!nmask.empty()); @@ -712,7 +712,7 @@ UNIT_TEST(restrictions, simple_exclude) // check restricted paths - path_restriction pmask(includes, excludes, -1, app); + path_restriction pmask(includes, excludes, -1, work); UNIT_TEST_CHECK(!pmask.empty()); @@ -752,11 +752,11 @@ UNIT_TEST(restrictions, include_exclude) excludes.push_back(file_path_internal("x/x")); excludes.push_back(file_path_internal("y/y")); - app_state app; + workspace work; // check restricted nodes - node_restriction nmask(includes, excludes, -1, roster, app); + node_restriction nmask(includes, excludes, -1, roster, work); UNIT_TEST_CHECK(!nmask.empty()); @@ -786,7 +786,7 @@ UNIT_TEST(restrictions, include_exclude) // check restricted paths - path_restriction pmask(includes, excludes, -1, app); + path_restriction pmask(includes, excludes, -1, work); UNIT_TEST_CHECK(!pmask.empty()); @@ -829,11 +829,11 @@ UNIT_TEST(restrictions, exclude_include) includes.push_back(file_path_internal("x/x")); includes.push_back(file_path_internal("y/y")); - app_state app; + workspace work; // check restricted nodes - node_restriction nmask(includes, excludes, -1, roster, app); + node_restriction nmask(includes, excludes, -1, roster, work); UNIT_TEST_CHECK(!nmask.empty()); @@ -863,7 +863,7 @@ UNIT_TEST(restrictions, exclude_include) // check restricted paths - path_restriction pmask(includes, excludes, -1, app); + path_restriction pmask(includes, excludes, -1, work); UNIT_TEST_CHECK(!pmask.empty()); @@ -901,8 +901,8 @@ UNIT_TEST(restrictions, invalid_roster_p includes.push_back(file_path_internal("foo")); excludes.push_back(file_path_internal("bar")); - app_state app; - UNIT_TEST_CHECK_THROW(node_restriction(includes, excludes, -1, roster, app), + workspace work; + UNIT_TEST_CHECK_THROW(node_restriction(includes, excludes, -1, roster, work), informative_failure); } @@ -915,8 +915,8 @@ UNIT_TEST(restrictions, invalid_workspac includes.push_back(file_path_internal("foo")); excludes.push_back(file_path_internal("bar")); - app_state app; - UNIT_TEST_CHECK_THROW(path_restriction(includes, excludes, -1, app), + workspace work; + UNIT_TEST_CHECK_THROW(path_restriction(includes, excludes, -1, work), informative_failure); } @@ -929,7 +929,7 @@ UNIT_TEST(restrictions, include_depth_0) includes.push_back(file_path_internal("x")); includes.push_back(file_path_internal("y")); - app_state app; + workspace work; // FIXME: depth == 0 currently means directory + immediate children // this should be changed to mean just the named directory but for // compatibility with old restrictions this behaviour has been preserved @@ -937,7 +937,7 @@ UNIT_TEST(restrictions, include_depth_0) // check restricted nodes - node_restriction nmask(includes, excludes, depth, roster, app); + node_restriction nmask(includes, excludes, depth, roster, work); UNIT_TEST_CHECK(!nmask.empty()); @@ -967,7 +967,7 @@ UNIT_TEST(restrictions, include_depth_0) // check restricted paths - path_restriction pmask(includes, excludes, depth, app); + path_restriction pmask(includes, excludes, depth, work); UNIT_TEST_CHECK(!pmask.empty()); @@ -1003,7 +1003,7 @@ UNIT_TEST(restrictions, include_depth_0_ vector includes, excludes; - app_state app; + workspace work; // FIXME: depth == 0 currently means directory + immediate children // this should be changed to mean just the named directory but for // compatibility with old restrictions this behaviour has been preserved @@ -1011,7 +1011,7 @@ UNIT_TEST(restrictions, include_depth_0_ // check restricted nodes - node_restriction nmask(includes, excludes, depth, roster, app); + node_restriction nmask(includes, excludes, depth, roster, work); UNIT_TEST_CHECK( nmask.empty()); @@ -1041,7 +1041,7 @@ UNIT_TEST(restrictions, include_depth_0_ // check restricted paths - path_restriction pmask(includes, excludes, depth, app); + path_restriction pmask(includes, excludes, depth, work); UNIT_TEST_CHECK( pmask.empty()); @@ -1079,7 +1079,7 @@ UNIT_TEST(restrictions, include_depth_1) includes.push_back(file_path_internal("x")); includes.push_back(file_path_internal("y")); - app_state app; + workspace work; // FIXME: depth == 1 currently means directory + children + grand children // this should be changed to mean directory + immediate children but for // compatibility with old restrictions this behaviour has been preserved @@ -1087,7 +1087,7 @@ UNIT_TEST(restrictions, include_depth_1) // check restricted nodes - node_restriction nmask(includes, excludes, depth, roster, app); + node_restriction nmask(includes, excludes, depth, roster, work); UNIT_TEST_CHECK(!nmask.empty()); @@ -1117,7 +1117,7 @@ UNIT_TEST(restrictions, include_depth_1) // check restricted paths - path_restriction pmask(includes, excludes, depth, app); + path_restriction pmask(includes, excludes, depth, work); UNIT_TEST_CHECK(!pmask.empty()); ============================================================ --- restrictions.hh d588f4ba6876b51d61d3f37f4836bf2272434310 +++ restrictions.hh e93a80c46b2d9e82263c988e4742c2e55e702803 @@ -30,7 +30,7 @@ #include "vocab.hh" #include "database.hh" // for parent_map -class app_state; +class workspace; // between any two related revisions, A and B, there is a set of changes (a // cset) that describes the operations required to get from A to B. for example: @@ -81,21 +81,21 @@ class node_restriction : public restrict std::vector const & excludes, long depth, roster_t const & roster, - app_state & a); + workspace & w); node_restriction(std::vector const & includes, std::vector const & excludes, long depth, roster_t const & roster1, roster_t const & roster2, - app_state & a); + workspace & w); node_restriction(std::vector const & includes, std::vector const & excludes, long depth, parent_map const & rosters1, roster_t const & roster2, - app_state & a); + workspace & w); bool includes(roster_t const & roster, node_id nid) const; @@ -122,7 +122,7 @@ class path_restriction : public restrict path_restriction(std::vector const & includes, std::vector const & excludes, long depth, - app_state & a); + workspace & w); bool includes(file_path const & sp) const; ============================================================ --- work.cc 0bc477ba2407659797f6ea6d907012686f2390ec +++ work.cc bb21460bb9c30ff19c93e378cdf5706cca93e30e @@ -124,7 +124,7 @@ get_roster_for_rid(revision_id const & r static void get_roster_for_rid(revision_id const & rid, database::cached_roster & cr, - database & db) + database * db) { // We may be asked for a roster corresponding to the null rid, which // is not in the database. In this situation, what is wanted is an empty @@ -136,9 +136,9 @@ get_roster_for_rid(revision_id const & r } else { - N(db.revision_exists(rid), + N(db->revision_exists(rid), F("base revision %s does not exist in database") % rid); - db.get_roster(rid, cr); + db->get_roster(rid, cr); } L(FL("base roster has %d entries") % cr.first->all_nodes().size()); } @@ -176,7 +176,7 @@ workspace::get_current_roster_shape(rost else { marking_map dummy; - make_roster_for_revision(rev, new_rid, ros, dummy, db, nis); + make_roster_for_revision(rev, new_rid, ros, dummy, *db, nis); } } @@ -492,11 +492,11 @@ workspace::ignore_file(file_path const & { if (!know_ignore_hook) { - have_ignore_hook = lua.obsolete_hook_ignore_file_defined(); + have_ignore_hook = lua->obsolete_hook_ignore_file_defined(); know_ignore_hook = true; } if (have_ignore_hook) - return lua.obsolete_hook_ignore_file(path); + return lua->obsolete_hook_ignore_file(path); return false; } @@ -504,7 +504,7 @@ workspace::init_attributes(file_path con workspace::init_attributes(file_path const & path, editable_roster_base & er) { map attrs; - lua.hook_init_attributes(path, attrs); + lua->hook_init_attributes(path, attrs); if (attrs.size() > 0) for (map::const_iterator i = attrs.begin(); i != attrs.end(); ++i) @@ -515,13 +515,13 @@ struct file_itemizer : public tree_walke struct file_itemizer : public tree_walker { - database & db; - workspace & work; + database * db; + workspace * work; set & known; set & unknown; set & ignored; path_restriction const & mask; - file_itemizer(database & db, workspace & work, + file_itemizer(database * db, workspace * work, set & k, set & u, set & i, @@ -544,7 +544,7 @@ file_itemizer::visit_file(file_path cons { if (mask.includes(path) && known.find(path) == known.end()) { - if (work.ignore_file(path) || db.is_dbfile(path)) + if (work->ignore_file(path) || db->is_dbfile(path)) ignored.insert(path); else unknown.insert(path); @@ -594,13 +594,13 @@ addition_builder addition_builder : public tree_walker { - database & db; - workspace & work; + database * db; + workspace * work; roster_t & ros; editable_roster_base & er; bool respect_ignore; public: - addition_builder(database & db, workspace & work, + addition_builder(database * db, workspace * work, roster_t & r, editable_roster_base & e, bool i = true) : db(db), work(work), ros(r), er(e), respect_ignore(i) @@ -647,7 +647,7 @@ addition_builder::add_nodes_for(file_pat I(nid != the_null_node); er.attach_node(nid, path); - work.init_attributes(path, er); + work->init_attributes(path, er); } bool @@ -660,7 +660,7 @@ addition_builder::visit_file(file_path c void addition_builder::visit_file(file_path const & path) { - if ((respect_ignore && work.ignore_file(path)) || db.is_dbfile(path)) + if ((respect_ignore && work->ignore_file(path)) || db->is_dbfile(path)) { P(F("skipping ignorable file %s") % path); return; @@ -679,7 +679,7 @@ struct editable_working_tree : public ed struct editable_working_tree : public editable_tree { - editable_working_tree(lua_hooks & lua, content_merge_adaptor const & source, + editable_working_tree(lua_hooks * lua, content_merge_adaptor const & source, bool const messages) : lua(lua), source(source), next_nid(1), root_dir_attached(true), messages(messages) @@ -705,7 +705,7 @@ private: virtual ~editable_working_tree(); private: - lua_hooks & lua; + lua_hooks * lua; content_merge_adaptor const & source; node_id next_nid; std::map rename_add_drop_map; @@ -1056,7 +1056,7 @@ add_parent_dirs(file_path const & dst, r static void add_parent_dirs(file_path const & dst, roster_t & ros, node_id_source & nis, - database & db, workspace & work) + database * db, workspace * work) { editable_roster_base er(ros, nis); addition_builder build(db, work, ros, er); @@ -1193,7 +1193,7 @@ workspace::find_unknown_and_ignored(path get_current_roster_shape(new_roster, nis); new_roster.extract_path_set(known); - file_itemizer u(db, *this, known, unknown, ignored, mask); + file_itemizer u(db, this, known, unknown, ignored, mask); for (vector::const_iterator i = roots.begin(); i != roots.end(); ++i) { @@ -1221,7 +1221,7 @@ workspace::perform_additions(set::const_iterator i = paths.begin(); i != paths.end(); ++i) { @@ -1410,7 +1410,7 @@ workspace::perform_rename(set } renames.insert(make_pair(src, dpath)); - add_parent_dirs(dpath, new_roster, nis, db, *this); + add_parent_dirs(dpath, new_roster, nis, db, this); } else { @@ -1433,7 +1433,7 @@ workspace::perform_rename(set renames.insert(make_pair(*i, d)); - add_parent_dirs(d, new_roster, nis, db, *this); + add_parent_dirs(d, new_roster, nis, db, this); } } @@ -1597,8 +1597,8 @@ workspace::update_any_attrs() for (full_attr_map_t::const_iterator j = n->attrs.begin(); j != n->attrs.end(); ++j) if (j->second.first) - lua.hook_apply_attribute (j->first(), fp, - j->second.second()); + lua->hook_apply_attribute (j->first(), fp, + j->second.second()); } } ============================================================ --- work.hh e42fa101dd8ccc458f2170ace6e04b40c8f0fffc +++ work.hh def9c5b6c7776dfa16c2bc9c0b83bc493ef56b04 @@ -203,13 +203,20 @@ struct workspace bool ignore_file(file_path const & path); // constructor and locals. by caching pointers to the database and the - // lua hooks, we don't have to know about app_state. + // lua hooks, we don't have to know about app_state. they are pointers + // for the sake of the unit-test constructor below. workspace(database & db, lua_hooks & lua) - : db(db), lua(lua), have_ignore_hook(false), know_ignore_hook(false) + : db(&db), lua(&lua), have_ignore_hook(false), know_ignore_hook(false) {}; + +#ifdef BUILD_UNIT_TESTS // this is for restrictions.cc + workspace() : db(0), lua(0), have_ignore_hook(false), know_ignore_hook(true) + {}; +#endif + private: - database & db; - lua_hooks & lua; + database * db; + lua_hooks * lua; bool have_ignore_hook; bool know_ignore_hook; };