# # # patch "cmd_ws_commit.cc" # from [f19eb71e76506b5ac8a706f610e6a34b595266a1] # to [b1f8e537df7b8a2736b9c38bb91686065a12f537] # # patch "restrictions.cc" # from [0c2ffb3ab668cac1628447353d5b0b3db82a9d78] # to [ad951fe6e51ba12fa53d049f64d2a8d8d51034c0] # # patch "restrictions.hh" # from [c64116376fe3f835fe40ca780a8fdde0d900ca91] # to [da2e7e471aa36ec3a5980fa98e301ed60afe2535] # # patch "work.cc" # from [39fcc1fec0b072c6ec588d59586b91b42b8e824c] # to [dd38abf686dce4e1ef5267b422419d1beae1ae3b] # # patch "work.hh" # from [cd117c8295b2bdf48db35e92aaf29842c27a1b7f] # to [1bce5844b7a330de41ac7dd1f6bb0c6a3b8c6a58] # ============================================================ --- cmd_ws_commit.cc f19eb71e76506b5ac8a706f610e6a34b595266a1 +++ cmd_ws_commit.cc b1f8e537df7b8a2736b9c38bb91686065a12f537 @@ -9,6 +9,7 @@ #include "base.hh" #include +#include #include #include "cmd.hh" @@ -32,6 +33,7 @@ using std::make_pair; using std::cout; using std::make_pair; +using std::ostream_iterator; using std::pair; using std::make_pair; using std::map; @@ -565,6 +567,26 @@ CMD(pivot_root, "pivot_root", "", CMD_RE app.opts.bookkeep_only); } +CMD(include, "include", "", CMD_REF(workspace), N_("[PATH]..."), + N_("Update or clear the workspace include list"), + "", + options::opts::none) +{ + workspace work(app); + vector paths = args_to_paths(args); + work.put_persistent_includes(paths); +} + +CMD(exclude, "exclude", "", CMD_REF(workspace), N_("[PATH]..."), + N_("Update or clear the workspace exclude list"), + "", + options::opts::none) +{ + workspace work(app); + vector paths = args_to_paths(args); + work.put_persistent_excludes(paths); +} + CMD(status, "status", "", CMD_REF(informative), N_("[PATH]..."), N_("Shows workspace's status information"), "", @@ -588,6 +610,27 @@ CMD(status, "status", "", CMD_REF(inform work.update_current_roster_from_filesystem(new_roster, mask); make_restricted_revision(old_rosters, new_roster, mask, rev); + vector includes, excludes; + work.get_persistent_includes(includes); + work.get_persistent_excludes(excludes); + + if (!includes.empty()) + { + cout << "Including:\n"; + for (vector::const_iterator i = includes.begin(); i != includes.end(); ++i) + { + cout << " " << *i << "\n"; + } + } + if (!excludes.empty()) + { + cout << "Excluding:\n"; + for (vector::const_iterator i = excludes.begin(); i != excludes.end(); ++i) + { + cout << " " << *i << "\n"; + } + } + utf8 summary; revision_summary(rev, app.opts.branchname, summary); external summary_external; ============================================================ --- restrictions.cc 0c2ffb3ab668cac1628447353d5b0b3db82a9d78 +++ restrictions.cc ad951fe6e51ba12fa53d049f64d2a8d8d51034c0 @@ -183,16 +183,27 @@ validate_paths(set const & in N(bad == 0, FP("%d unknown path", "%d unknown paths", bad) % bad); } -restriction::restriction(std::vector const & includes, - std::vector const & excludes, +restriction::restriction(vector const & includes, + vector const & excludes, long depth) : included_paths(includes.begin(), includes.end()), excluded_paths(excludes.begin(), excludes.end()), depth(depth) {} -node_restriction::node_restriction(std::vector const & includes, - std::vector const & excludes, +void +restriction::add_persistent_restriction(workspace & work) +{ + vector includes, excludes; + work.get_persistent_includes(includes); + work.get_persistent_excludes(excludes); + + included_paths.insert(includes.begin(), includes.end()); + excluded_paths.insert(excludes.begin(), excludes.end()); +} + +node_restriction::node_restriction(vector const & includes, + vector const & excludes, long depth, roster_t const & roster) : restriction(includes, excludes, depth) @@ -201,8 +212,8 @@ node_restriction::node_restriction(std:: validate_paths(included_paths, excluded_paths, unknown_node(known_paths)); } -node_restriction::node_restriction(std::vector const & includes, - std::vector const & excludes, +node_restriction::node_restriction(vector const & includes, + vector const & excludes, long depth, roster_t const & roster1, roster_t const & roster2) : @@ -213,8 +224,8 @@ node_restriction::node_restriction(std:: validate_paths(included_paths, excluded_paths, unknown_node(known_paths)); } -node_restriction::node_restriction(std::vector const & includes, - std::vector const & excludes, +node_restriction::node_restriction(vector const & includes, + vector const & excludes, long depth, parent_map const & rosters1, roster_t const & roster2) : @@ -229,8 +240,8 @@ node_restriction::node_restriction(std:: } -path_restriction::path_restriction(std::vector const & includes, - std::vector const & excludes, +path_restriction::path_restriction(vector const & includes, + vector const & excludes, long depth, validity_check vc) : restriction(includes, excludes, depth) @@ -247,25 +258,28 @@ node_restriction::node_restriction(works // leave work.o out of the unit_tester binary. #ifndef BUILD_UNIT_TESTS node_restriction::node_restriction(workspace & work, - std::vector const & includes, - std::vector const & excludes, + vector const & includes, + vector const & excludes, long depth, roster_t const & roster) : restriction(includes, excludes, depth) { + add_persistent_restriction(work); map_nodes(node_map, roster, included_paths, excluded_paths, known_paths); validate_paths(included_paths, excluded_paths, unknown_unignored_node(known_paths, work)); } node_restriction::node_restriction(workspace & work, - std::vector const & includes, - std::vector const & excludes, + vector const & includes, + vector const & excludes, long depth, roster_t const & roster1, roster_t const & roster2) : restriction(includes, excludes, depth) { + add_persistent_restriction(work); + map_nodes(node_map, roster1, included_paths, excluded_paths, known_paths); map_nodes(node_map, roster2, included_paths, excluded_paths, known_paths); @@ -274,13 +288,15 @@ node_restriction::node_restriction(works } node_restriction::node_restriction(workspace & work, - std::vector const & includes, - std::vector const & excludes, + vector const & includes, + vector const & excludes, long depth, parent_map const & rosters1, roster_t const & roster2) : restriction(includes, excludes, depth) { + add_persistent_restriction(work); + for (parent_map::const_iterator i = rosters1.begin(); i != rosters1.end(); i++) map_nodes(node_map, parent_roster(i), @@ -292,12 +308,14 @@ path_restriction::path_restriction(works path_restriction::path_restriction(workspace & work, - std::vector const & includes, - std::vector const & excludes, + vector const & includes, + vector const & excludes, long depth, validity_check vc) : restriction(includes, excludes, depth) { + add_persistent_restriction(work); + map_paths(path_map, included_paths, restricted_path::included); map_paths(path_map, excluded_paths, restricted_path::excluded); ============================================================ --- restrictions.hh c64116376fe3f835fe40ca780a8fdde0d900ca91 +++ restrictions.hh da2e7e471aa36ec3a5980fa98e301ed60afe2535 @@ -72,6 +72,8 @@ class restriction std::vector const & excludes, long depth); + void add_persistent_restriction(workspace & work); + std::set included_paths, excluded_paths; long depth; }; ============================================================ --- work.cc 39fcc1fec0b072c6ec588d59586b91b42b8e824c +++ work.cc dd38abf686dce4e1ef5267b422419d1beae1ae3b @@ -10,7 +10,7 @@ #include "base.hh" #include "work.hh" -#include +#include #include #include #include @@ -35,10 +35,12 @@ #include "roster.hh" #include "transforms.hh" +using std::cout; using std::deque; using std::exception; using std::make_pair; using std::map; +using std::ostringstream; using std::pair; using std::set; using std::string; @@ -53,6 +55,8 @@ static char const revision_file_name[] = static char const options_file_name[] = "options"; static char const user_log_file_name[] = "log"; static char const revision_file_name[] = "revision"; +static char const includes_file_name[] = "includes"; +static char const excludes_file_name[] = "excludes"; static void get_revision_path(bookkeeping_path & m_path) @@ -89,6 +93,20 @@ get_user_log_path(bookkeeping_path & ul_ L(FL("user log path is %s") % ul_path); } +static void +get_includes_path(bookkeeping_path & includes) +{ + includes = bookkeeping_root / includes_file_name; + L(FL("includes path is %s") % includes); +} + +static void +get_excludes_path(bookkeeping_path & excludes) +{ + excludes = bookkeeping_root / excludes_file_name; + L(FL("excludes path is %s") % excludes); +} + // bool @@ -191,6 +209,92 @@ workspace::workspace(options const & opt // routines for manipulating the bookkeeping directory +// persistent restriction in _MTN/includes and _MTN/excludes + +static void +read_persistent_restriction(bookkeeping_path const & file, vector & paths) +{ + if (path_exists(file)) + { + L(FL("reading %s") % file); + data dat; + read_data(file, dat); + vector lines; + split_into_lines(dat(), lines); + for (vector::const_iterator i = lines.begin(); i != lines.end(); ++i) + { + paths.push_back(file_path_internal(*i)); + } + } +} + +static void +write_persistent_restriction(bookkeeping_path const & file, vector const & paths) +{ + if (paths.empty()) + { + if (file_exists(file)) + { + L(FL("removing %s") % file); + delete_file(file); + } + } + else + { + L(FL("writing %s") % file); + vector combined(paths); + read_persistent_restriction(file, combined); + ostringstream stream; + for (vector::const_iterator i = combined.begin(); i != combined.end(); ++i) + { + cout << " " << *i << "\n"; + stream << *i << "\n"; + } + data dat(stream.str()); + write_data(file, dat); + } +} + +void +workspace::get_persistent_includes(vector & includes) +{ + bookkeeping_path includes_path; + get_includes_path(includes_path); + read_persistent_restriction(includes_path, includes); +} + +void +workspace::get_persistent_excludes(vector & excludes) +{ + bookkeeping_path excludes_path; + get_excludes_path(excludes_path); + read_persistent_restriction(excludes_path, excludes); +} + +void +workspace::put_persistent_includes(vector const & includes) +{ + bookkeeping_path includes_path; + get_includes_path(includes_path); + if (includes.empty()) + cout << "Includes cleared\n"; + else + cout << "Includes:\n"; + write_persistent_restriction(includes_path, includes); +} + +void +workspace::put_persistent_excludes(vector const & excludes) +{ + bookkeeping_path excludes_path; + get_excludes_path(excludes_path); + if (excludes.empty()) + cout << "Excludes cleared\n"; + else + cout << "Excludes:\n"; + write_persistent_restriction(excludes_path, excludes); +} + // revision file contains a partial revision describing the workspace void workspace::get_work_rev(revision_t & rev) ============================================================ --- work.hh cd117c8295b2bdf48db35e92aaf29842c27a1b7f +++ work.hh 1bce5844b7a330de41ac7dd1f6bb0c6a3b8c6a58 @@ -154,6 +154,14 @@ public: bool has_changes(database & db); + + void get_persistent_includes(std::vector & includes); + void get_persistent_excludes(std::vector & excludes); + + void put_persistent_includes(std::vector const & includes); + void put_persistent_excludes(std::vector const & excludes); + + // write out a new (partial) revision describing the current workspace; // the important pieces of this are the base revision id and the "shape" // changeset (representing tree rearrangements).